aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2024-07-08 11:23:41 +0200
committerShauren <shauren.trinity@gmail.com>2024-07-08 12:45:19 +0200
commitb08d85349c54e524e7d52c2acc9e9c367b61afaf (patch)
tree53a363fbdc72bc54b7b5f830146617b75ff74f44
parentaca264e11b4600512a6eac53fb2295a9a7a8bb70 (diff)
Core/Creatures: Fixed memory leaks in creature formations
(cherry picked from commit 2e3920081f4f349a226ab5238cd983403e167656)
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp6
-rw-r--r--src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp4
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 94cdf8c3118..8fb57bafe9e 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -12637,11 +12637,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 009af793d19..afb6083047e 100644
--- a/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_elwynn_forest.cpp
@@ -114,8 +114,8 @@ struct npc_cameron : public ScriptedAI
// first we break formation because children will need to move on their own now
for (auto 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)