Fix crash when bot unable to find valid reply.

This commit is contained in:
郑佩茹
2022-09-27 18:39:30 -06:00
parent d33a28954f
commit 0b599de6bd

View File

@@ -118,6 +118,9 @@ std::string PlayerbotTextMgr::GetBotText(ChatReplyType replyType, std::map<std::
proper_list.push_back(text); proper_list.push_back(text);
} }
if (proper_list.empty())
return "";
BotTextEntry textEntry = proper_list[urand(0, proper_list.size() - 1)]; BotTextEntry textEntry = proper_list[urand(0, proper_list.size() - 1)];
std::string botText = !textEntry.m_text[GetLocalePriority()].empty() ? textEntry.m_text[GetLocalePriority()] : textEntry.m_text[0]; std::string botText = !textEntry.m_text[GetLocalePriority()].empty() ? textEntry.m_text[GetLocalePriority()] : textEntry.m_text[0];
for (auto & placeholder : placeholders) for (auto & placeholder : placeholders)