diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 3d8ddf73..1b8aef8f 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -29,6 +29,7 @@ #include "Unit.h" #include "World.h" +#include #include #include #include @@ -347,7 +348,7 @@ uint32 RandomPlayerbotMgr::AddRandomBots() PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) continue; - + std::vector guids; do { Field* fields = result->Fetch(); @@ -364,10 +365,15 @@ uint32 RandomPlayerbotMgr::AddRandomBots() if (std::find(currentBots.begin(), currentBots.end(), guid) != currentBots.end()) continue; - + guids.push_back(guid); + } while (result->NextRow()); + + std::random_shuffle(guids.begin(), guids.end()); + + for (uint32 &guid : guids) { uint32 add_time = sPlayerbotAIConfig->enableRotation ? - urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime) : - sPlayerbotAIConfig->randomBotInWorldWithRotaionDisabled; + urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime) : + sPlayerbotAIConfig->randomBotInWorldWithRotaionDisabled; SetEventValue(guid, "add", 1, add_time); SetEventValue(guid, "logout", 0, 0); @@ -376,8 +382,7 @@ uint32 RandomPlayerbotMgr::AddRandomBots() maxAllowedBotCount--; if (!maxAllowedBotCount) break; - - } while (result->NextRow()); + } if (!maxAllowedBotCount) break; diff --git a/src/strategy/actions/ChangeTalentsAction.cpp b/src/strategy/actions/ChangeTalentsAction.cpp index e7fc79cf..6b41b747 100644 --- a/src/strategy/actions/ChangeTalentsAction.cpp +++ b/src/strategy/actions/ChangeTalentsAction.cpp @@ -81,7 +81,7 @@ std::string ChangeTalentsAction::SpecList() std::vector> parsed = sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specNo][80]; std::unordered_map tabCount; tabCount[0] = tabCount[1] = tabCount[2] = 0; - for (auto item : parsed) { + for (auto &item : parsed) { tabCount[item[0]] += item[3]; } out << specFound << ". " << sPlayerbotAIConfig->premadeSpecName[cls][specNo] << " (";