diff --git a/src/modules/Bots/playerbot/PlayerbotMgr.cpp b/src/modules/Bots/playerbot/PlayerbotMgr.cpp index e1b5b908b..44c1c1c67 100644 --- a/src/modules/Bots/playerbot/PlayerbotMgr.cpp +++ b/src/modules/Bots/playerbot/PlayerbotMgr.cpp @@ -23,15 +23,15 @@ PlayerbotHolder::~PlayerbotHolder() } -void PlayerbotHolder::UpdateAIInternal(uint32 elapsed) +void PlayerbotHolder::UpdateAIInternal(__attribute__((unused)) uint32 elapsed) { } -void PlayerbotHolder::UpdateSessions(uint32 elapsed) +void PlayerbotHolder::UpdateSessions(__attribute__((unused)) uint32 elapsed) { - for (PlayerBotMap::const_iterator itr = playerBots.begin(); itr != playerBots.end(); ++itr) + for (auto itr : playerBots) { - Player* const bot = itr->second; + Player* const bot = itr.second; if (bot->IsBeingTeleported()) { bot->GetPlayerbotAI()->HandleTeleportAck(); @@ -45,28 +45,20 @@ void PlayerbotHolder::UpdateSessions(uint32 elapsed) void PlayerbotHolder::LogoutAllBots() { - while (true) + while (!playerBots.empty()) { - PlayerBotMap::const_iterator itr = GetPlayerBotsBegin(); - if (itr == GetPlayerBotsEnd()) - { - break; - } - Player* bot= itr->second; - - LogoutPlayerBot(bot->GetObjectGuid().GetRawValue()); + LogoutPlayerBot(playerBots.begin()->second->GetObjectGuid().GetRawValue()); } } void PlayerbotHolder::LogoutPlayerBot(uint64 guid) { - Player* bot = GetPlayerBot(guid); + Player* bot = GetBotByGUID(guid); if (bot) { bot->GetPlayerbotAI()->TellMaster("Goodbye!"); sPlayerbotDbStore.Save(bot->GetPlayerbotAI()); - sLog.outString("Bot %s logged out", bot->GetName()); - //bot->SaveToDB(); + DETAIL_LOG("Bot %s logged out", bot->GetName()); WorldSession * botWorldSessionPtr = bot->GetSession(); playerBots.erase(guid); // deletes bot player ptr inside this WorldSession PlayerBotMap @@ -75,15 +67,15 @@ void PlayerbotHolder::LogoutPlayerBot(uint64 guid) } } -Player* PlayerbotHolder::GetPlayerBot(uint64 playerGuid) const +Player* PlayerbotHolder::GetBotByGUID(uint64 playerGuid) const { - PlayerBotMap::const_iterator it = playerBots.find(playerGuid); - return (it == playerBots.end()) ? 0 : it->second; + auto bot = playerBots.find(playerGuid); + return (bot == playerBots.end()) ? 0 : bot->second; } void PlayerbotHolder::OnBotLogin(Player * const bot) { - PlayerbotAI* ai = new PlayerbotAI(bot); + auto ai = new PlayerbotAI(bot); bot->SetPlayerbotAI(ai); OnBotLoginInternal(bot); @@ -102,10 +94,9 @@ void PlayerbotHolder::OnBotLogin(Player * const bot) if (group) { bool groupValid = false; - Group::MemberSlotList const& slots = group->GetMemberSlots(); - for (Group::MemberSlotList::const_iterator i = slots.begin(); i != slots.end(); ++i) + for (const auto& slot : group->GetMemberSlots()) { - ObjectGuid member = i->guid; + ObjectGuid member = slot.guid; uint32 account = sObjectMgr.GetPlayerAccountIdByGUID(member); if (!sPlayerbotAIConfig.IsInRandomAccountList(account)) { @@ -129,16 +120,14 @@ void PlayerbotHolder::OnBotLogin(Player * const bot) uint32 account = sObjectMgr.GetPlayerAccountIdByGUID(bot->GetObjectGuid()); if (sPlayerbotAIConfig.IsInRandomAccountList(account)) { - sLog.outString("%d/%d Bot %s logged in", playerBots.size(), sRandomPlayerbotMgr.GetMaxAllowedBotCount(), bot->GetName()); - if (sConfig.GetBoolDefault("BeepAtStart", true) && playerBots.size() == sRandomPlayerbotMgr.GetMaxAllowedBotCount()) - { - printf("\a"); - } + DETAIL_LOG("%zu/%d Bot %s logged in", playerBots.size(), sRandomPlayerbotMgr.GetMaxAllowedBotCount(), bot->GetName()); + } + else { + DETAIL_LOG("Bot %s logged in", bot->GetName()); } - else sLog.outString("Bot %s logged in", bot->GetName()); } -string PlayerbotHolder::ProcessBotCommand(const string cmd, ObjectGuid guid, bool admin, uint32 masterAccountId, uint32 masterGuildId) +string PlayerbotHolder::ProcessBotCommand(const string& cmd, ObjectGuid guid, bool admin, uint32 masterAccountId, uint32 masterGuildId) { if (!sPlayerbotAIConfig.enabled || guid.IsEmpty()) { @@ -152,8 +141,7 @@ string PlayerbotHolder::ProcessBotCommand(const string cmd, ObjectGuid guid, boo if (isRandomAccount && !isRandomBot && !admin) { - Player* bot = sObjectMgr.GetPlayer(guid); - if (bot->GetGuildId() != masterGuildId) + if (sObjectMgr.GetPlayer(guid)->GetGuildId() != masterGuildId) { return "not in your guild"; } @@ -181,7 +169,7 @@ string PlayerbotHolder::ProcessBotCommand(const string cmd, ObjectGuid guid, boo return "player is offline"; } - if (!GetPlayerBot(guid.GetRawValue())) + if (!GetBotByGUID(guid.GetRawValue())) { return "not your bot"; } @@ -192,7 +180,7 @@ string PlayerbotHolder::ProcessBotCommand(const string cmd, ObjectGuid guid, boo if (admin) { - Player* bot = GetPlayerBot(guid.GetRawValue()); + Player* bot = GetBotByGUID(guid.GetRawValue()); if (!bot) { return "bot not found"; @@ -273,9 +261,9 @@ bool PlayerbotMgr::HandlePlayerbotMgrCommand(ChatHandler* handler, char const* a return true; } - for (list::iterator i = messages.begin(); i != messages.end(); ++i) + for (auto & message : messages) { - handler->PSendSysMessage(i->c_str()); + handler->PSendSysMessage("%s", message.c_str()); } return true; @@ -287,15 +275,15 @@ list PlayerbotHolder::HandlePlayerbotCommand(char const* args, Player* m if (!*args) { - messages.push_back("usage: list or add/init/remove PLAYERNAME"); + messages.emplace_back("usage: list or add/init/remove PLAYERNAME"); return messages; } - char *cmd = strtok ((char*)args, " "); - char *charname = strtok (NULL, " "); + char *cmd = strtok(const_cast(args), " "); + char *charname = strtok(nullptr, " "); if (!cmd) { - messages.push_back("usage: list or add/init/remove PLAYERNAME"); + messages.emplace_back("usage: list or add/init/remove PLAYERNAME"); return messages; } @@ -307,7 +295,7 @@ list PlayerbotHolder::HandlePlayerbotCommand(char const* args, Player* m if (!charname) { - messages.push_back("usage: list or add/init/remove PLAYERNAME"); + messages.emplace_back("usage: list or add/init/remove PLAYERNAME"); return messages; } @@ -320,14 +308,14 @@ list PlayerbotHolder::HandlePlayerbotCommand(char const* args, Player* m Group* group = master->GetGroup(); if (!group) { - messages.push_back("you must be in group"); + messages.emplace_back("you must be in group"); return messages; } Group::MemberSlotList slots = group->GetMemberSlots(); - for (Group::member_citerator i = slots.begin(); i != slots.end(); i++) + for (const auto& slot : group->GetMemberSlots()) { - ObjectGuid member = i->guid; + ObjectGuid member = slot.guid; if (member.GetRawValue() == master->GetObjectGuid().GetRawValue()) { @@ -344,7 +332,7 @@ list PlayerbotHolder::HandlePlayerbotCommand(char const* args, Player* m if (charnameStr == "!" && master && master->GetSession()->GetSecurity() > SEC_GAMEMASTER) { - for (PlayerBotMap::const_iterator i = GetPlayerBotsBegin(); i != GetPlayerBotsEnd(); ++i) + for (auto i = GetPlayerBotsBegin(); i != GetPlayerBotsEnd(); ++i) { Player* bot = i->second; if (bot && bot->IsInWorld()) @@ -355,10 +343,8 @@ list PlayerbotHolder::HandlePlayerbotCommand(char const* args, Player* m } vector chars = split(charnameStr, ','); - for (vector::iterator i = chars.begin(); i != chars.end(); i++) + for (const auto& s : chars) { - string s = *i; - uint32 accountId = GetAccountId(s); if (!accountId) { @@ -382,9 +368,8 @@ list PlayerbotHolder::HandlePlayerbotCommand(char const* args, Player* m } } - for (set::iterator i = bots.begin(); i != bots.end(); ++i) + for (const auto& bot : bots) { - string bot = *i; ostringstream out; out << cmdStr << ": " << bot << " - "; @@ -411,7 +396,7 @@ list PlayerbotHolder::HandlePlayerbotCommand(char const* args, Player* m return messages; } -uint32 PlayerbotHolder::GetAccountId(string name) +uint32 PlayerbotHolder::GetAccountId(const string& name) { uint32 accountId = 0; @@ -426,11 +411,12 @@ uint32 PlayerbotHolder::GetAccountId(string name) return accountId; } -string PlayerbotHolder::ListBots(Player* master) +string PlayerbotHolder::ListBots(Player* master) const { set bots; map classNames; classNames[CLASS_DRUID] = "Druid"; + classNames[CLASS_DEATH_KNIGHT] = "Death Knight"; classNames[CLASS_HUNTER] = "Hunter"; classNames[CLASS_MAGE] = "Mage"; classNames[CLASS_PALADIN] = "Paladin"; @@ -444,7 +430,7 @@ string PlayerbotHolder::ListBots(Player* master) list names; map classes; - for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) + for (auto it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; string name = bot->GetName(); @@ -459,7 +445,7 @@ string PlayerbotHolder::ListBots(Player* master) { QueryResult* results = CharacterDatabase.PQuery("SELECT class,name FROM characters where account = '%u'", master->GetSession()->GetAccountId()); - if (results != NULL) + if (results) { do { @@ -482,7 +468,7 @@ string PlayerbotHolder::ListBots(Player* master) ostringstream out; bool first = true; out << "Bot roster: "; - for (list::iterator i = names.begin(); i != names.end(); ++i) + for (const auto& name : names) { if (first) { @@ -492,7 +478,6 @@ string PlayerbotHolder::ListBots(Player* master) { out << ", "; } - string name = *i; out << online[name] << name << " " << classes[name]; } @@ -508,44 +493,44 @@ PlayerbotMgr::~PlayerbotMgr() { } -void PlayerbotMgr::UpdateAIInternal(uint32 elapsed) +void PlayerbotMgr::UpdateAIInternal(__attribute__((unused)) uint32 elapsed) { SetNextCheckDelay(sPlayerbotAIConfig.reactDelay); } void PlayerbotMgr::HandleCommand(uint32 type, const string& text) { - Player *master = GetMaster(); - if (!master) + Player *bmaster = GetMaster(); + if (!bmaster) { return; } - for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) + for (auto it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; - bot->GetPlayerbotAI()->HandleCommand(type, text, *master); + bot->GetPlayerbotAI()->HandleCommand(type, text, *bmaster); } - for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr.GetPlayerBotsBegin(); it != sRandomPlayerbotMgr.GetPlayerBotsEnd(); ++it) + for (auto it = sRandomPlayerbotMgr.GetPlayerBotsBegin(); it != sRandomPlayerbotMgr.GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; - if (bot->GetPlayerbotAI()->GetMaster() == master) + if (bot->GetPlayerbotAI()->GetMaster() == bmaster) { - bot->GetPlayerbotAI()->HandleCommand(type, text, *master); + bot->GetPlayerbotAI()->HandleCommand(type, text, *bmaster); } } } void PlayerbotMgr::HandleMasterIncomingPacket(const WorldPacket& packet) { - for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) + for (auto it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; bot->GetPlayerbotAI()->HandleMasterIncomingPacket(packet); } - for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr.GetPlayerBotsBegin(); it != sRandomPlayerbotMgr.GetPlayerBotsEnd(); ++it) + for (auto it = sRandomPlayerbotMgr.GetPlayerBotsBegin(); it != sRandomPlayerbotMgr.GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; if (bot->GetPlayerbotAI()->GetMaster() == GetMaster()) @@ -566,13 +551,13 @@ void PlayerbotMgr::HandleMasterIncomingPacket(const WorldPacket& packet) } void PlayerbotMgr::HandleMasterOutgoingPacket(const WorldPacket& packet) { - for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) + for (auto it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; bot->GetPlayerbotAI()->HandleMasterOutgoingPacket(packet); } - for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr.GetPlayerBotsBegin(); it != sRandomPlayerbotMgr.GetPlayerBotsEnd(); ++it) + for (auto it = sRandomPlayerbotMgr.GetPlayerBotsBegin(); it != sRandomPlayerbotMgr.GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; if (bot->GetPlayerbotAI()->GetMaster() == GetMaster()) @@ -584,12 +569,12 @@ void PlayerbotMgr::HandleMasterOutgoingPacket(const WorldPacket& packet) void PlayerbotMgr::SaveToDB() { - for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) + for (auto it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; bot->SaveToDB(); } - for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr.GetPlayerBotsBegin(); it != sRandomPlayerbotMgr.GetPlayerBotsEnd(); ++it) + for (auto it = sRandomPlayerbotMgr.GetPlayerBotsBegin(); it != sRandomPlayerbotMgr.GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; if (bot->GetPlayerbotAI()->GetMaster() == GetMaster()) @@ -605,7 +590,7 @@ void PlayerbotMgr::OnBotLoginInternal(Player * const bot) bot->GetPlayerbotAI()->ResetStrategies(); } -void PlayerbotMgr::OnPlayerLogin(Player* player) +__attribute__((unused)) void PlayerbotMgr::OnPlayerLogin(Player* player) { if (!sPlayerbotAIConfig.botAutologin) { diff --git a/src/modules/Bots/playerbot/PlayerbotMgr.h b/src/modules/Bots/playerbot/PlayerbotMgr.h index 87060b8e5..2fc6c754e 100644 --- a/src/modules/Bots/playerbot/PlayerbotMgr.h +++ b/src/modules/Bots/playerbot/PlayerbotMgr.h @@ -1,5 +1,5 @@ -#ifndef _PLAYERBOTMGR_H -#define _PLAYERBOTMGR_H +#ifndef PLAYERBOTMGR_H +#define PLAYERBOTMGR_H #include "Common.h" #include "PlayerbotAIBase.h" @@ -20,26 +20,26 @@ class PlayerbotHolder : public PlayerbotAIBase virtual ~PlayerbotHolder(); void AddPlayerBot(uint64 guid, uint32 masterAccountId); - void HandlePlayerBotLoginCallback(QueryResult * dummy, SqlQueryHolder * holder); +// void HandlePlayerBotLoginCallback(QueryResult * dummy, SqlQueryHolder * holder); void LogoutPlayerBot(uint64 guid); - Player* GetPlayerBot (uint64 guid) const; + Player* GetBotByGUID (uint64 playerGuid) const; PlayerBotMap::const_iterator GetPlayerBotsBegin() const { return playerBots.begin(); } PlayerBotMap::const_iterator GetPlayerBotsEnd() const { return playerBots.end(); } - virtual void UpdateAIInternal(uint32 elapsed); - void UpdateSessions(uint32 elapsed); + void UpdateAIInternal(__attribute__((unused)) uint32 elapsed) override; + void UpdateSessions(__attribute__((unused)) uint32 elapsed); void LogoutAllBots(); - void OnBotLogin(Player * const bot); + void OnBotLogin(Player* bot); - list HandlePlayerbotCommand(char const* args, Player* master = NULL); - string ProcessBotCommand(string cmd, ObjectGuid guid, bool admin, uint32 masterAccountId, uint32 masterGuildId); - uint32 GetAccountId(string name); - string ListBots(Player* master); + list HandlePlayerbotCommand(char const* args, Player* master = nullptr); + string ProcessBotCommand(const string& cmd, ObjectGuid guid, bool admin, uint32 masterAccountId, uint32 masterGuildId); + static uint32 GetAccountId(const string& name); + string ListBots(Player* master) const; protected: - virtual void OnBotLoginInternal(Player * const bot) = 0; + __attribute__((unused)) virtual void OnBotLoginInternal(Player* bot) = 0; protected: PlayerBotMap playerBots; @@ -48,23 +48,24 @@ class PlayerbotHolder : public PlayerbotAIBase class PlayerbotMgr : public PlayerbotHolder { public: - PlayerbotMgr(Player* const master); - virtual ~PlayerbotMgr(); + explicit PlayerbotMgr(Player* master); + ~PlayerbotMgr() override; static bool HandlePlayerbotMgrCommand(ChatHandler* handler, char const* args); void HandleMasterIncomingPacket(const WorldPacket& packet); void HandleMasterOutgoingPacket(const WorldPacket& packet); void HandleCommand(uint32 type, const string& text); - void OnPlayerLogin(Player* player); - virtual void UpdateAIInternal(uint32 elapsed); + __attribute__((unused)) void OnPlayerLogin(Player* player); + + void UpdateAIInternal(uint32 elapsed) override; Player* GetMaster() const { return master; }; void SaveToDB(); protected: - virtual void OnBotLoginInternal(Player * const bot); + void OnBotLoginInternal(Player* bot) override; private: Player* const master; diff --git a/src/modules/Bots/playerbot/RandomPlayerbotFactory.cpp b/src/modules/Bots/playerbot/RandomPlayerbotFactory.cpp index 12d7f68c9..4ff89fa72 100644 --- a/src/modules/Bots/playerbot/RandomPlayerbotFactory.cpp +++ b/src/modules/Bots/playerbot/RandomPlayerbotFactory.cpp @@ -415,6 +415,7 @@ void RandomPlayerbotFactory::DeleteRandomGuilds() ObjectGuid leader(HIGHGUID_PLAYER, randomBot); Guild* guild = sGuildMgr.GetGuildByLeader(leader); if (guild) guild->Disband(); + delete guild; } BASIC_LOG("Random bot guilds deleted"); } \ No newline at end of file diff --git a/src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp b/src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp index 7cab5d6b2..9818f45f3 100644 --- a/src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp +++ b/src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp @@ -25,6 +25,8 @@ map > RandomPlayerbotMgr::locsPerLevelCache; RandomPlayerbotMgr::RandomPlayerbotMgr() : PlayerbotHolder() { sPlayerbotCommandServer.Start(); + CharacterDatabase.PExecute("DELETE FROM ai_playerbot_random_bots WHERE `validIn` < (SELECT MAX(`time`) FROM ai_playerbot_random_bots)"); + CharacterDatabase.PExecute("UPDATE ai_playerbot_random_bots SET `validIn` = validIn - (SELECT MAX(`time`) FROM ai_playerbot_random_bots), `time` = '0' "); } RandomPlayerbotMgr::~RandomPlayerbotMgr() @@ -35,7 +37,7 @@ uint32 RandomPlayerbotMgr::GetMaxAllowedBotCount() return GetEventValue(0, "bot_count"); } -void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed) +void RandomPlayerbotMgr::UpdateAIInternal(__attribute__((unused)) uint32 elapsed) { SetNextCheckDelay(sPlayerbotAIConfig.randomBotUpdateInterval * 1000); @@ -102,14 +104,14 @@ void RandomPlayerbotMgr::AddRandomBots(set &bots) { if (!sAccountMgr.GetCharactersCount(accountId)) { - DEBUG_LOG("No character in rndbot account %d.", accountId); + DEBUG_LOG("No character in rndbot account %u.", accountId); continue; } - QueryResult* result = CharacterDatabase.PQuery("SELECT 'guid', 'race', 'class' FROM characters WHERE account = '%u'", accountId); + QueryResult* result = CharacterDatabase.PQuery("SELECT guid, race, class FROM characters WHERE account = '%u'", accountId); if (!result) { - DEBUG_LOG("Unable to fetch characters for rndbot account %d", accountId); + DEBUG_LOG("Unable to fetch characters for rndbot account %u", accountId); continue; } @@ -123,6 +125,7 @@ void RandomPlayerbotMgr::AddRandomBots(set &bots) if (cls == 6 && sPlayerbotAIConfig.randomBotMaxLevel < sWorld.getConfig(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL)) { + DEBUG_LOG("Max player level lower than minimum heroic level."); continue; } @@ -160,7 +163,7 @@ void RandomPlayerbotMgr::ScheduleTeleport(uint32 bot, uint32 time) bool RandomPlayerbotMgr::ProcessBot(uint32 bot) { DEBUG_LOG("Processing bot %d", bot); - Player* player = GetPlayerBot(bot); + Player* player = GetBotByGUID(bot); if (!IsRandomBot(bot)) { if (!player || !player->GetGroup()) @@ -563,7 +566,7 @@ uint32 RandomPlayerbotMgr::GetEventValue(uint32 bot, const string& event) value = fields[0].GetUInt32(); uint32 lastChangeTime = fields[1].GetUInt32(); uint32 validIn = fields[2].GetUInt32(); - if ((time(nullptr) - lastChangeTime) >= validIn) + if (((GameTime::GetGameTimeMS() / 1000) - lastChangeTime) >= validIn) { value = 0; } @@ -580,8 +583,8 @@ uint32 RandomPlayerbotMgr::SetEventValue(uint32 bot, const string& event, uint32 if (value) { CharacterDatabase.PExecute( - "INSERT INTO `ai_playerbot_random_bots` (`owner`, `bot`, `time`, `validIn`, `event`, `value`) VALUES ('%u', '%u', '%ld', '%u', '%s', '%u')", - 0, bot, time(nullptr), validIn, event.c_str(), value); + "INSERT INTO `ai_playerbot_random_bots` (`owner`, `bot`, `time`, `validIn`, `event`, `value`) VALUES ('%u', '%u', '%u', '%u', '%s', '%u')", + 0, bot, GameTime::GetGameTimeMS() / 1000, validIn, event.c_str(), value); } return value; @@ -697,18 +700,18 @@ bool RandomPlayerbotMgr::HandlePlayerbotConsoleCommand(char const *args) void RandomPlayerbotMgr::HandleCommand(uint32 type, const string& text, Player& fromPlayer) { - for (auto it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) + for (auto it : playerBots) { - Player* const bot = it->second; + Player* const bot = it.second; bot->GetPlayerbotAI()->HandleCommand(type, text, fromPlayer); } } void RandomPlayerbotMgr::OnPlayerLogout(Player* player) { - for (auto it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) + for (auto it : playerBots) { - Player* const bot = it->second; + Player* const bot = it.second; PlayerbotAI* ai = bot->GetPlayerbotAI(); if (player == ai->GetMaster()) { @@ -726,9 +729,9 @@ void RandomPlayerbotMgr::OnPlayerLogout(Player* player) void RandomPlayerbotMgr::OnPlayerLogin(Player* player) { - for (auto it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) + for (auto it : playerBots) { - Player* const bot = it->second; + Player* const bot = it.second; if (player == bot || player->GetPlayerbotAI()) { continue; @@ -973,7 +976,7 @@ string RandomPlayerbotMgr::HandleRemoteCommand(string request) string command = string(request.begin(), pos); uint64 guid = atoi(string(pos + 1, request.end()).c_str()); - Player* bot = GetPlayerBot(guid); + Player* bot = GetBotByGUID(guid); if (!bot) { return "invalid guid"; diff --git a/src/modules/Bots/playerbot/RandomPlayerbotMgr.h b/src/modules/Bots/playerbot/RandomPlayerbotMgr.h index 7cb772a2e..c5bfae40d 100644 --- a/src/modules/Bots/playerbot/RandomPlayerbotMgr.h +++ b/src/modules/Bots/playerbot/RandomPlayerbotMgr.h @@ -24,7 +24,7 @@ class RandomPlayerbotMgr : public PlayerbotHolder return instance; } - void UpdateAIInternal(uint32 elapsed) override; + void UpdateAIInternal(__attribute__((unused)) uint32 elapsed) override; public: static bool HandlePlayerbotConsoleCommand(char const *args); @@ -53,7 +53,7 @@ class RandomPlayerbotMgr : public PlayerbotHolder static void Revive(Player* player); protected: - void OnBotLoginInternal(Player * const bot) override {} + void OnBotLoginInternal(__attribute__((unused)) Player * const bot) override {} private: static uint32 GetEventValue(uint32 bot, const string& event);