From 3f9165a71451d608dbb2013695de6ac0380f9d11 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 1 Sep 2024 14:09:35 +0800 Subject: [PATCH] Fix addclass --- src/PlayerbotAIConfig.cpp | 4 ++++ src/RandomPlayerbotMgr.cpp | 2 -- src/RandomPlayerbotMgr.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index d6844aaf..a87135f1 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -13,6 +13,7 @@ #include "Playerbots.h" #include "RandomItemMgr.h" #include "RandomPlayerbotFactory.h" +#include "RandomPlayerbotMgr.h" #include "Talentspec.h" template @@ -482,6 +483,9 @@ bool PlayerbotAIConfig::Initialize() selfBotLevel = sConfigMgr->GetOption("AiPlayerbot.SelfBotLevel", 1); RandomPlayerbotFactory::CreateRandomBots(); + if (sPlayerbotAIConfig->addClassCommand) + sRandomPlayerbotMgr->PrepareAddclassCache(); + if (World::IsStopped()) { return true; diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 10f2bfe5..21bd012a 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -162,8 +162,6 @@ RandomPlayerbotMgr::RandomPlayerbotMgr() : PlayerbotHolder(), processTicks(0) { sPlayerbotCommandServer->Start(); PrepareTeleportCache(); - if (sPlayerbotAIConfig->addClassCommand) - PrepareAddclassCache(); } BattlegroundData.clear(); diff --git a/src/RandomPlayerbotMgr.h b/src/RandomPlayerbotMgr.h index 2105477c..5c35aefa 100644 --- a/src/RandomPlayerbotMgr.h +++ b/src/RandomPlayerbotMgr.h @@ -169,6 +169,7 @@ public: void setActivityPercentage(float percentage) { activityMod = percentage / 100.0f; } static uint8 GetTeamClassIdx(bool isAlliance, uint8 claz) { return isAlliance * 20 + claz; } + void PrepareAddclassCache(); std::map> addclassCache; protected: void OnBotLoginInternal(Player* const bot) override; @@ -193,7 +194,6 @@ private: void RandomTeleport(Player* bot, std::vector& locs, bool hearth = false); uint32 GetZoneLevel(uint16 mapId, float teleX, float teleY, float teleZ); void PrepareTeleportCache(); - void PrepareAddclassCache(); typedef void (RandomPlayerbotMgr::*ConsoleCommandHandler)(Player*); std::vector players;