refactor(Core/Movement): follower management of references (#25060)

Co-authored-by: Shauren <shauren.trinity@gmail.com>
This commit is contained in:
sogladev 2026-03-12 10:59:16 +01:00 committed by GitHub
parent a8a96eb8f8
commit 40f55bb0f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 28 additions and 135 deletions

View file

@ -16,6 +16,7 @@
*/
#include "Unit.h"
#include "AbstractFollower.h"
#include "AreaDefines.h"
#include "ArenaSpectator.h"
#include "Battlefield.h"
@ -44,7 +45,6 @@
#include "MoveSpline.h"
#include "MoveSplineInit.h"
#include "MovementGenerator.h"
#include "AbstractFollower.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "OutdoorPvP.h"
@ -5530,12 +5530,8 @@ void Unit::RemoveAreaAurasDueToLeaveWorld()
void Unit::RemoveAllFollowers()
{
while (auto* ref = m_FollowingRefMgr.getFirst())
{
auto* source = ref->GetSource();
ref->delink();
source->SetTarget(nullptr);
}
while (!m_followingMe.empty())
(*m_followingMe.begin())->SetTarget(nullptr);
}
void Unit::RemoveAllAuras()

View file

@ -20,8 +20,6 @@
#include "EnumFlag.h"
#include "EventProcessor.h"
#include "FollowerRefMgr.h"
#include "FollowerReference.h"
#include "HostileRefMgr.h"
#include "ItemTemplate.h"
#include "MotionMaster.h"
@ -74,6 +72,7 @@ class MotionTransport;
class Vehicle;
class TransportBase;
class SpellCastTargets;
class AbstractFollower;
typedef std::list<Unit*> UnitList;
typedef std::list< std::pair<Aura*, uint8> > DispelChargesList;
@ -1881,9 +1880,9 @@ public:
[[nodiscard]] bool IsInDisallowedMountForm() const;
// Followers
void AddFollower(FollowerReference* ref) { m_FollowingRefMgr.insertFirst(ref); }
void FollowerAdded(AbstractFollower* f) { m_followingMe.insert(f); }
void FollowerRemoved(AbstractFollower* f) { m_followingMe.erase(f); }
[[nodiscard]] virtual float GetFollowAngle() const { return static_cast<float>(M_PI / 2); }
void RemoveFollower(FollowerReference* /*ref*/ ) { /* nothing to do yet */ }
void RemoveAllFollowers();
// Pets, guardians, minions...
@ -2229,7 +2228,7 @@ private:
// Manage all Units that are threatened by us
HostileRefMgr m_HostileRefMgr;
FollowerRefMgr m_FollowingRefMgr;
std::unordered_set<AbstractFollower*> m_followingMe;
Unit* m_comboTarget;
int8 m_comboPoints;