fix(Core/Vehicles): defer accessory init to avoid double install (#25486)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Andrew 2026-04-16 17:15:30 -03:00 committed by GitHub
parent a0e831c954
commit fc74e0e1fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 8 deletions

View file

@ -713,6 +713,13 @@ void Creature::Update(uint32 diff)
m_vehicleKit->Reset();
}
if (_triggerVehicleKitInit)
{
_triggerVehicleKitInit = false;
if (m_vehicleKit)
m_vehicleKit->Reset();
}
switch (m_deathState)
{
case DeathState::JustRespawned:
@ -1113,9 +1120,10 @@ bool Creature::AIM_Initialize(CreatureAI* ai)
IsAIEnabled = true;
i_AI->InitializeAI();
// Xinef: Initialize vehicle if it is not summoned!
if (GetVehicleKit() && m_spawnId)
GetVehicleKit()->Reset();
// Defer vehicle kit init to the next Creature::Update tick so accessories
// install after visibility sync.
if (GetVehicleKit())
_triggerVehicleKitInit = true;
return true;
}

View file

@ -536,6 +536,9 @@ private:
// Formation variable
CreatureGroup* m_formation;
bool TriggerJustRespawned;
// Deferred vehicle init: set in AIM_Initialize, consumed on the next
// Creature::Update tick so accessories install after visibility sync.
bool _triggerVehicleKitInit = false;
// Shared timer between mobs who assist another.
// Damaging one extends leash range on all of them.

View file

@ -346,11 +346,6 @@ bool Map::AddToMap(T* obj, bool checkTransport)
//also, trigger needs to cast spell, if not update, cannot see visual
obj->UpdateObjectVisibility(true);
// Xinef: little hack for vehicles, accessories have to be added after visibility update so they wont fall off the vehicle, moved from Creature::AIM_Initialize
// Initialize vehicle, this is done only for summoned npcs, DB creatures are handled by grid loaders
if (obj->IsCreature())
if (Vehicle* vehicle = obj->ToCreature()->GetVehicleKit())
vehicle->Reset();
return true;
}