Core/Movement: Fix stunned falling units freezing the client

Port From (https://github.com/TrinityCore/TrinityCore/commit/b40cadd5a12445c1265db8d81b2a0c5e73fe6757)
This commit is contained in:
hondacrx
2022-01-05 23:23:07 -05:00
parent b527bd99d6
commit 20a31a52c2
+16 -8
View File
@@ -102,11 +102,15 @@ namespace Game.Movement
public MotionMaster(Unit unit) public MotionMaster(Unit unit)
{ {
_owner = unit; _owner = unit;
_flags = MotionMasterFlags.InitializationPending;
} }
public void Initialize() public void Initialize()
{ {
if (HasFlag(MotionMasterFlags.Delayed)) if (HasFlag(MotionMasterFlags.InitializationPending))
return;
if (HasFlag(MotionMasterFlags.Update))
{ {
_delayedActions.Enqueue(new DelayedAction(() => Initialize(), MotionMasterDelayedActionType.Initialize)); _delayedActions.Enqueue(new DelayedAction(() => Initialize(), MotionMasterDelayedActionType.Initialize));
return; return;
@@ -125,9 +129,13 @@ namespace Game.Movement
if (!HasFlag(MotionMasterFlags.InitializationPending)) if (!HasFlag(MotionMasterFlags.InitializationPending))
return; return;
AddFlag(MotionMasterFlags.Initializing);
RemoveFlag(MotionMasterFlags.InitializationPending);
DirectInitialize();
ResolveDelayedActions(); ResolveDelayedActions();
RemoveFlag(MotionMasterFlags.InitializationPending); RemoveFlag(MotionMasterFlags.Initializing);
} }
public bool Empty() public bool Empty()
@@ -297,7 +305,7 @@ namespace Game.Movement
if (!_owner) if (!_owner)
return; return;
if (HasFlag(MotionMasterFlags.InitializationPending)) if (HasFlag(MotionMasterFlags.InitializationPending | MotionMasterFlags.Initializing))
return; return;
Cypher.Assert(!Empty(), $"MotionMaster:Update: update called without Initializing! ({_owner.GetGUID()})"); Cypher.Assert(!Empty(), $"MotionMaster:Update: update called without Initializing! ({_owner.GetGUID()})");
@@ -559,9 +567,9 @@ namespace Game.Movement
public void MoveConfused() public void MoveConfused()
{ {
if (_owner.IsTypeId(TypeId.Player)) if (_owner.IsTypeId(TypeId.Player))
Add(new ConfusedGenerator<Player>()); Add(new ConfusedMovementGenerator<Player>());
else else
Add(new ConfusedGenerator<Creature>()); Add(new ConfusedMovementGenerator<Creature>());
} }
public void MoveFleeing(Unit enemy, uint time) public void MoveFleeing(Unit enemy, uint time)
@@ -574,10 +582,10 @@ namespace Game.Movement
if (time != 0) if (time != 0)
Add(new TimedFleeingGenerator(enemy.GetGUID(), time)); Add(new TimedFleeingGenerator(enemy.GetGUID(), time));
else else
Add(new FleeingGenerator<Creature>(enemy.GetGUID())); Add(new FleeingMovementGenerator<Creature>(enemy.GetGUID()));
} }
else else
Add(new FleeingGenerator<Player>(enemy.GetGUID())); Add(new FleeingMovementGenerator<Player>(enemy.GetGUID()));
} }
public void MovePoint(uint id, Position pos, bool generatePath = true, float? finalOrient = null) public void MovePoint(uint id, Position pos, bool generatePath = true, float? finalOrient = null)
@@ -883,7 +891,7 @@ namespace Game.Movement
return; return;
// rooted units don't move (also setting falling+root flag causes client freezes) // rooted units don't move (also setting falling+root flag causes client freezes)
if (_owner.HasUnitState(UnitState.Root)) if (_owner.HasUnitState(UnitState.Root | UnitState.Stunned))
return; return;
_owner.SetFall(true); _owner.SetFall(true);