Reset added rndbots on server restart to automatically apply configuration changes (#913)

* Refactor RandomPlayerbotMgr and delete add value on restart server

* Remove reset tips in conf file
This commit is contained in:
Yunfan Li
2025-01-26 19:06:29 +08:00
committed by GitHub
parent 05db6f67b4
commit e571694a88
6 changed files with 28 additions and 13 deletions

View File

@@ -49,6 +49,7 @@ std::list<uint32> PlayerbotFactory::classQuestIds;
std::list<uint32> PlayerbotFactory::specialQuestIds;
std::vector<uint32> PlayerbotFactory::enchantSpellIdCache;
std::vector<uint32> PlayerbotFactory::enchantGemIdCache;
std::unordered_map<uint32, std::vector<uint32>> PlayerbotFactory::trainerIdCache;
PlayerbotFactory::PlayerbotFactory(Player* bot, uint32 level, uint32 itemQuality, uint32 gearScoreLimit)
: level(level), itemQuality(itemQuality), gearScoreLimit(gearScoreLimit), bot(bot)
@@ -2327,7 +2328,7 @@ void PlayerbotFactory::SetRandomSkill(uint16 id)
void PlayerbotFactory::InitAvailableSpells()
{
if (trainerIdCache.empty())
if (trainerIdCache[bot->getClass()].empty())
{
CreatureTemplateContainer const* creatureTemplateContainer = sObjectMgr->GetCreatureTemplates();
for (CreatureTemplateContainer::const_iterator i = creatureTemplateContainer->begin();
@@ -2341,10 +2342,10 @@ void PlayerbotFactory::InitAvailableSpells()
continue;
uint32 trainerId = co.Entry;
trainerIdCache.push_back(trainerId);
trainerIdCache[bot->getClass()].push_back(trainerId);
}
}
for (uint32 trainerId : trainerIdCache)
for (uint32 trainerId : trainerIdCache[bot->getClass()])
{
TrainerSpellData const* trainer_spells = sObjectMgr->GetNpcTrainerSpells(trainerId);
if (!trainer_spells)