diff options
| author | Shauren <shauren.trinity@gmail.com> | 2024-07-08 11:23:41 +0200 |
|---|---|---|
| committer | Ovahlord <dreadkiller@gmx.de> | 2024-07-08 13:13:06 +0200 |
| commit | 7198c5223ef9a2deb8265e1ca9a3f60926310e78 (patch) | |
| tree | 59b6e3803e5aad375d7a155962895fa3db9ee0c6 /src | |
| parent | 2fc0272533314ff7944aca7e6cf3ff7857e563c5 (diff) | |
Core/Creatures: Fixed memory leaks in creature formations
(cherry picked from commit 2e3920081f4f349a226ab5238cd983403e167656)
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 6 | ||||
| -rw-r--r-- | src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 3c127223c86..f6df54fca2d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12255,11 +12255,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); } } diff --git a/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp b/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp index 975e87c5da8..9b38dbfa104 100644 --- a/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp +++ b/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp @@ -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) |
