mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Creatures: Fixed memory leaks in creature formations
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user