mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-20 18:10:02 +01:00
Chat: Fix index out of bounds crash in case verb_pos equals zero (#1115)
Prevents invalid accesses to the word[] array, preventing possible crashes. Improves the message selection logic in bot chat. Fixes an error in the switch-case structure, ensuring that all possible messages are used correctly.
This commit is contained in:
parent
c83cf0706a
commit
08b77acd8d
@ -969,7 +969,7 @@ std::string ChatReplyAction::GenerateReplyMessage(Player* bot, std::string& inco
|
||||
msg = "ya %s but thats in the past";
|
||||
break;
|
||||
case 2:
|
||||
msg = word[verb_pos - 1] + " will " + word[verb_pos + 1] + " again though %s";
|
||||
msg = word[verb_pos ? verb_pos - 1 : verb_pos + 1] + " will " + word[verb_pos + 1] + " again though %s";
|
||||
break;
|
||||
}
|
||||
msg = std::regex_replace(msg, std::regex("%s"), name);
|
||||
@ -1013,7 +1013,7 @@ std::string ChatReplyAction::GenerateReplyMessage(Player* bot, std::string& inco
|
||||
msg = "%s, what will happen %s?";
|
||||
break;
|
||||
case 2:
|
||||
msg = "are you saying " + word[verb_pos - 1] + " will " + word[verb_pos + 1] + " " + word[verb_pos + 2] + " %s?";
|
||||
msg = "are you saying " + word[verb_pos ? verb_pos - 1 : verb_pos + 1] + " will " + word[verb_pos + 1] + " " + word[verb_pos + 2] + " %s?";
|
||||
break;
|
||||
}
|
||||
msg = std::regex_replace(msg, std::regex("%s"), name);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user