mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Fix talk command crash
This commit is contained in:
@@ -61,8 +61,8 @@ bool GossipHelloAction::Execute(Event event)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
menuToSelect = atoi(text.c_str());
|
menuToSelect = atoi(text.c_str());
|
||||||
if (menuToSelect > 0)
|
// if (menuToSelect > 0)
|
||||||
menuToSelect--;
|
// menuToSelect--;
|
||||||
|
|
||||||
ProcessGossip(menuToSelect);
|
ProcessGossip(menuToSelect);
|
||||||
}
|
}
|
||||||
@@ -104,11 +104,11 @@ void GossipHelloAction::TellGossipMenus()
|
|||||||
TellGossipText(textId);
|
TellGossipText(textId);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32 i = 0; i < menu.GetMenuItemCount(); i++)
|
GossipMenuItemContainer const &items = menu.GetMenuItems();
|
||||||
{
|
for (auto iter = items.begin(); iter != items.end(); iter++) {
|
||||||
GossipMenuItem const* item = menu.GetItem(i);
|
GossipMenuItem const* item = &(iter->second);
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "[" << (i+1) << "] " << item->Message;
|
out << "[" << iter->first << "] " << item->Message;
|
||||||
botAI->TellMasterNoFacing(out.str());
|
botAI->TellMasterNoFacing(out.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ void GossipHelloAction::TellGossipMenus()
|
|||||||
bool GossipHelloAction::ProcessGossip(int32 menuToSelect)
|
bool GossipHelloAction::ProcessGossip(int32 menuToSelect)
|
||||||
{
|
{
|
||||||
GossipMenu& menu = bot->PlayerTalkClass->GetGossipMenu();
|
GossipMenu& menu = bot->PlayerTalkClass->GetGossipMenu();
|
||||||
if (menuToSelect != -1 && menuToSelect >= menu.GetMenuItemCount())
|
if (menuToSelect != -1 && !menu.GetItem(menuToSelect))
|
||||||
{
|
{
|
||||||
botAI->TellError("Unknown gossip option");
|
botAI->TellError("Unknown gossip option");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user