Pet Battles: Fix wild battle pet marking not working
Two bugs prevented TryMarkAsWildBattlePet() from ever marking critters: 1. Init order: BattlePetMgr::Initialize() ran AFTER sMapMgr->Initialize(), so the species-by-creature map was empty during creature spawning. Moved battle pet initialization before map system startup. 2. Respawn flag wipe: TryMarkAsWildBattlePet() ran BEFORE setDeathState(JUST_RESPAWNED), which calls ReplaceAllNpcFlags from template, wiping the dynamically added UNIT_NPC_FLAG_WILD_BATTLE_PET. Moved TryMarkAsWildBattlePet() to after setDeathState.
This commit is contained in:
@@ -2384,9 +2384,11 @@ void Creature::Respawn(bool force)
|
||||
UpdateEntry(m_originalEntry);
|
||||
|
||||
SelectLevel();
|
||||
TryMarkAsWildBattlePet();
|
||||
|
||||
// setDeathState(JUST_RESPAWNED) calls ReplaceAllNpcFlags from template,
|
||||
// so TryMarkAsWildBattlePet must run AFTER to add the dynamic flag
|
||||
setDeathState(JUST_RESPAWNED);
|
||||
TryMarkAsWildBattlePet();
|
||||
|
||||
CreatureModel display(GetNativeDisplayId(), GetNativeDisplayScale(), 1.0f);
|
||||
if (sObjectMgr->GetCreatureModelRandomGender(&display, GetCreatureTemplate()))
|
||||
|
||||
@@ -2031,6 +2031,14 @@ bool World::SetInitialWorldSettings()
|
||||
mail_timer_expires = ((DAY * IN_MILLISECONDS) / (m_timers[WUPDATE_AUCTIONS].GetInterval()));
|
||||
TC_LOG_INFO("server.loading", "Mail timer set to: {}, mail return is called every {} minutes", uint64(mail_timer), uint64(mail_timer_expires));
|
||||
|
||||
// Battle pet data must be loaded before map initialization ? creature spawning
|
||||
// calls TryMarkAsWildBattlePet() which needs the species-by-creature map populated
|
||||
TC_LOG_INFO("server.loading", "Loading battle pets info...");
|
||||
BattlePets::BattlePetMgr::Initialize();
|
||||
|
||||
TC_LOG_INFO("server.loading", "Initializing pet battle system...");
|
||||
sPetBattleMgr->Initialize();
|
||||
|
||||
///- Initialize MapManager
|
||||
TC_LOG_INFO("server.loading", "Starting Map System");
|
||||
sMapMgr->Initialize();
|
||||
@@ -2096,12 +2104,6 @@ bool World::SetInitialWorldSettings()
|
||||
TC_LOG_INFO("server.loading", "Loading character templates...");
|
||||
sCharacterTemplateDataStore->LoadCharacterTemplates();
|
||||
|
||||
TC_LOG_INFO("server.loading", "Loading battle pets info...");
|
||||
BattlePets::BattlePetMgr::Initialize();
|
||||
|
||||
TC_LOG_INFO("server.loading", "Initializing pet battle system...");
|
||||
sPetBattleMgr->Initialize();
|
||||
|
||||
TC_LOG_INFO("server.loading", "Loading scenarios");
|
||||
sScenarioMgr->LoadDB2Data();
|
||||
sScenarioMgr->LoadDBData();
|
||||
|
||||
Reference in New Issue
Block a user