Skip to content

Commit

Permalink
Chat: Fix index out of bounds crash in case verb_pos equals zero (#131
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Exxenoz authored Jan 30, 2025
1 parent 1b16f38 commit 09c43ce
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions playerbot/strategy/actions/SayAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ std::string ChatReplyAction::GenerateReplyMessage(Player* bot, std::string incom
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);
Expand Down Expand Up @@ -1432,7 +1432,7 @@ std::string ChatReplyAction::GenerateReplyMessage(Player* bot, std::string incom
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);
Expand Down

0 comments on commit 09c43ce

Please sign in to comment.