mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-15 09:50:27 +00:00
Run clang-format
This commit is contained in:
@@ -1,47 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it
|
||||
* and/or modify it under version 2 of the License, or (at your option), any later version.
|
||||
*/
|
||||
|
||||
#include "GossipHelloAction.h"
|
||||
#include "GossipDef.h"
|
||||
|
||||
#include "Event.h"
|
||||
#include "GossipDef.h"
|
||||
#include "Playerbots.h"
|
||||
|
||||
bool GossipHelloAction::Execute(Event event)
|
||||
{
|
||||
ObjectGuid guid;
|
||||
ObjectGuid guid;
|
||||
|
||||
WorldPacket &p = event.getPacket();
|
||||
if (p.empty())
|
||||
{
|
||||
Player* master = GetMaster();
|
||||
if (master)
|
||||
guid = master->GetTarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
p.rpos(0);
|
||||
p >> guid;
|
||||
}
|
||||
WorldPacket& p = event.getPacket();
|
||||
if (p.empty())
|
||||
{
|
||||
Player* master = GetMaster();
|
||||
if (master)
|
||||
guid = master->GetTarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
p.rpos(0);
|
||||
p >> guid;
|
||||
}
|
||||
|
||||
if (!guid)
|
||||
return false;
|
||||
if (!guid)
|
||||
return false;
|
||||
|
||||
Creature* pCreature = bot->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
|
||||
if (!pCreature)
|
||||
{
|
||||
LOG_DEBUG("playerbots", "[PlayerbotMgr]: HandleMasterIncomingPacket - Received CMSG_GOSSIP_HELLO {} not found or you can't interact with him.", guid.ToString().c_str());
|
||||
return false;
|
||||
}
|
||||
Creature* pCreature = bot->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
|
||||
if (!pCreature)
|
||||
{
|
||||
LOG_DEBUG("playerbots",
|
||||
"[PlayerbotMgr]: HandleMasterIncomingPacket - Received CMSG_GOSSIP_HELLO {} not found or you can't "
|
||||
"interact with him.",
|
||||
guid.ToString().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
GossipMenuItemsMapBounds pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBounds(pCreature->GetCreatureTemplate()->GossipMenuId);
|
||||
if (pMenuItemBounds.first == pMenuItemBounds.second)
|
||||
return false;
|
||||
GossipMenuItemsMapBounds pMenuItemBounds =
|
||||
sObjectMgr->GetGossipMenuItemsMapBounds(pCreature->GetCreatureTemplate()->GossipMenuId);
|
||||
if (pMenuItemBounds.first == pMenuItemBounds.second)
|
||||
return false;
|
||||
|
||||
std::string const text = event.getParam();
|
||||
int32 menuToSelect = -1;
|
||||
if (text.empty())
|
||||
{
|
||||
std::string const text = event.getParam();
|
||||
int32 menuToSelect = -1;
|
||||
if (text.empty())
|
||||
{
|
||||
WorldPacket p1;
|
||||
p1 << guid;
|
||||
bot->GetSession()->HandleGossipHelloOpcode(p1);
|
||||
@@ -52,23 +58,23 @@ bool GossipHelloAction::Execute(Event event)
|
||||
botAI->TellMasterNoFacing(out.str());
|
||||
|
||||
TellGossipMenus();
|
||||
}
|
||||
else if (!bot->PlayerTalkClass)
|
||||
{
|
||||
botAI->TellError("I need to talk first");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
menuToSelect = atoi(text.c_str());
|
||||
// if (menuToSelect > 0)
|
||||
}
|
||||
else if (!bot->PlayerTalkClass)
|
||||
{
|
||||
botAI->TellError("I need to talk first");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
menuToSelect = atoi(text.c_str());
|
||||
// if (menuToSelect > 0)
|
||||
// menuToSelect--;
|
||||
|
||||
ProcessGossip(menuToSelect);
|
||||
}
|
||||
}
|
||||
|
||||
bot->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
|
||||
return true;
|
||||
bot->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
void GossipHelloAction::TellGossipText(uint32 textId)
|
||||
@@ -104,8 +110,9 @@ void GossipHelloAction::TellGossipMenus()
|
||||
TellGossipText(textId);
|
||||
}
|
||||
|
||||
GossipMenuItemContainer const &items = menu.GetMenuItems();
|
||||
for (auto iter = items.begin(); iter != items.end(); iter++) {
|
||||
GossipMenuItemContainer const& items = menu.GetMenuItems();
|
||||
for (auto iter = items.begin(); iter != items.end(); iter++)
|
||||
{
|
||||
GossipMenuItem const* item = &(iter->second);
|
||||
std::ostringstream out;
|
||||
out << "[" << iter->first << "] " << item->Message;
|
||||
@@ -113,7 +120,6 @@ void GossipHelloAction::TellGossipMenus()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool GossipHelloAction::ProcessGossip(int32 menuToSelect)
|
||||
{
|
||||
GossipMenu& menu = bot->PlayerTalkClass->GetGossipMenu();
|
||||
|
||||
Reference in New Issue
Block a user