Entities/Unit: Cleanup all the direct accesses to m_unitMovedByMe. Refactor the field to be protected. Add assertions to catch dangling pointers.
Port From (https://github.com/TrinityCore/TrinityCore/commit/edc75831194bc2419e3abada47121fadf4b2aa8d)
This commit is contained in:
@@ -209,8 +209,6 @@ namespace Game.Entities
|
||||
public List<ObjectGuid> m_clientGUIDs = new();
|
||||
public List<ObjectGuid> m_visibleTransports = new();
|
||||
public WorldObject seerView;
|
||||
// only changed for direct client control (possess, vehicle etc.), not stuff you control using pet commands
|
||||
public Unit m_unitMovedByMe;
|
||||
Team m_team;
|
||||
ReputationMgr reputationMgr;
|
||||
QuestObjectiveCriteriaManager m_questObjectiveCriteriaMgr;
|
||||
|
||||
@@ -4013,7 +4013,7 @@ namespace Game.Entities
|
||||
public override bool CanAlwaysSee(WorldObject obj)
|
||||
{
|
||||
// Always can see self
|
||||
if (m_unitMovedByMe == obj)
|
||||
if (GetUnitBeingMoved() == obj)
|
||||
return true;
|
||||
|
||||
ObjectGuid guid = m_activePlayerData.FarsightObject;
|
||||
@@ -5544,7 +5544,7 @@ namespace Game.Entities
|
||||
initialSetup.ServerExpansionLevel = (byte)WorldConfig.GetIntValue(WorldCfg.Expansion);
|
||||
SendPacket(initialSetup);
|
||||
|
||||
SetMover(this);
|
||||
SetMovedUnit(this);
|
||||
}
|
||||
|
||||
public void SendInitialPacketsAfterAddToMap()
|
||||
@@ -7228,18 +7228,7 @@ namespace Game.Entities
|
||||
SetViewpoint(target, allowMove);
|
||||
|
||||
if (allowMove)
|
||||
SetMover(target);
|
||||
}
|
||||
|
||||
public void SetMover(Unit target)
|
||||
{
|
||||
m_unitMovedByMe.m_playerMovingMe = null;
|
||||
m_unitMovedByMe = target;
|
||||
m_unitMovedByMe.m_playerMovingMe = this;
|
||||
|
||||
MoveSetActiveMover packet = new();
|
||||
packet.MoverGUID = target.GetGUID();
|
||||
SendPacket(packet);
|
||||
SetMovedUnit(target);
|
||||
}
|
||||
|
||||
public Item GetWeaponForAttack(WeaponAttackType attackType, bool useable = false)
|
||||
|
||||
Reference in New Issue
Block a user