Core/Creatures: Fixed memory leaks in creature formations

This commit is contained in:
Shauren
2024-07-08 11:23:41 +02:00
parent cdf0d62e48
commit 2e3920081f
2 changed files with 5 additions and 5 deletions

View File

@@ -12291,11 +12291,11 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a
return;
}
if (vehicle->GetBase()->GetTypeId() == TYPEID_UNIT)
if (Creature* vehicleBaseCreature = vehicle->GetBase()->ToCreature())
{
// If a player entered a vehicle that is part of a formation, remove it from said formation
if (CreatureGroup* creatureGroup = vehicle->GetBase()->ToCreature()->GetFormation())
creatureGroup->RemoveMember(vehicle->GetBase()->ToCreature());
if (CreatureGroup* creatureGroup = vehicleBaseCreature->GetFormation())
sFormationMgr->RemoveCreatureFromGroup(creatureGroup, vehicleBaseCreature);
}
}

View File

@@ -121,8 +121,8 @@ struct npc_cameron : public ScriptedAI
// first we break formation because children will need to move on their own now
for (ObjectGuid guid : _childrenGUIDs)
if (Creature* child = ObjectAccessor::GetCreature(*me, guid))
if (child->GetFormation())
child->GetFormation()->RemoveMember(child);
if (CreatureGroup* creatureGroup = child->GetFormation())
sFormationMgr->RemoveCreatureFromGroup(creatureGroup, child);
// Move each child to an random position
for (uint32 i = 0; i < _childrenGUIDs.size(); ++i)