Core/Movement: Movement Cleanups
Port From (https://github.com/TrinityCore/TrinityCore/commit/6209ceddb9fbbcf1c7e3552c17b23465c29ec118)
This commit is contained in:
@@ -102,21 +102,15 @@ namespace Game.Movement
|
|||||||
DirectClean(reset);
|
DirectClean(reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearExpireList()
|
void Clear(MovementSlot slot)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _expireList.Count; ++i)
|
if (Empty() || slot >= MovementSlot.Max)
|
||||||
DirectDelete(_expireList[i]);
|
return;
|
||||||
|
|
||||||
_expireList.Clear();
|
if (_cleanFlag.HasAnyFlag(MMCleanFlag.Update))
|
||||||
|
DelayedClean(slot);
|
||||||
if (Empty())
|
else
|
||||||
Initialize();
|
DirectClean(slot);
|
||||||
else if (NeedInitTop())
|
|
||||||
InitTop();
|
|
||||||
else if (Convert.ToBoolean(_cleanFlag & MMCleanFlag.Reset))
|
|
||||||
Top().Reset(_owner);
|
|
||||||
|
|
||||||
_cleanFlag &= ~MMCleanFlag.Reset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MovementExpired(bool reset = true)
|
public void MovementExpired(bool reset = true)
|
||||||
@@ -149,6 +143,12 @@ namespace Game.Movement
|
|||||||
return _slot[(int)slot].GetMovementGeneratorType();
|
return _slot[(int)slot].GetMovementGeneratorType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IMovementGenerator GetMotionSlot(MovementSlot slot)
|
||||||
|
{
|
||||||
|
Cypher.Assert((int)slot >= 0);
|
||||||
|
return _slot[(int)slot];
|
||||||
|
}
|
||||||
|
|
||||||
public IMovementGenerator GetMotionSlot(int slot)
|
public IMovementGenerator GetMotionSlot(int slot)
|
||||||
{
|
{
|
||||||
Cypher.Assert(slot >= 0);
|
Cypher.Assert(slot >= 0);
|
||||||
@@ -681,6 +681,24 @@ namespace Game.Movement
|
|||||||
Top().Reset(_owner);
|
Top().Reset(_owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DirectClean(MovementSlot slot)
|
||||||
|
{
|
||||||
|
IMovementGenerator motion = GetMotionSlot(slot);
|
||||||
|
if (motion != null)
|
||||||
|
{
|
||||||
|
_slot[(int)slot] = null;
|
||||||
|
DirectDelete(motion);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!Empty() && Top() == null)
|
||||||
|
--_top;
|
||||||
|
|
||||||
|
if (Empty())
|
||||||
|
Initialize();
|
||||||
|
else if (NeedInitTop())
|
||||||
|
InitTop();
|
||||||
|
}
|
||||||
|
|
||||||
void DelayedClean()
|
void DelayedClean()
|
||||||
{
|
{
|
||||||
while (Size() > 1)
|
while (Size() > 1)
|
||||||
@@ -692,6 +710,19 @@ namespace Game.Movement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DelayedClean(MovementSlot slot)
|
||||||
|
{
|
||||||
|
IMovementGenerator motion = GetMotionSlot(slot);
|
||||||
|
if (motion != null)
|
||||||
|
{
|
||||||
|
_slot[(int)slot] = null;
|
||||||
|
DelayedDelete(motion);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!Empty() && Top() == null)
|
||||||
|
--_top;
|
||||||
|
}
|
||||||
|
|
||||||
void DirectExpire(bool reset)
|
void DirectExpire(bool reset)
|
||||||
{
|
{
|
||||||
if (Size() > 1)
|
if (Size() > 1)
|
||||||
@@ -740,6 +771,23 @@ namespace Game.Movement
|
|||||||
_expireList.Add(curr);
|
_expireList.Add(curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClearExpireList()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _expireList.Count; ++i)
|
||||||
|
DirectDelete(_expireList[i]);
|
||||||
|
|
||||||
|
_expireList.Clear();
|
||||||
|
|
||||||
|
if (Empty())
|
||||||
|
Initialize();
|
||||||
|
else if (NeedInitTop())
|
||||||
|
InitTop();
|
||||||
|
else if (_cleanFlag.HasAnyFlag(MMCleanFlag.Reset))
|
||||||
|
Top().Reset(_owner);
|
||||||
|
|
||||||
|
_cleanFlag &= ~MMCleanFlag.Reset;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Empty() { return (_top < 0); }
|
public bool Empty() { return (_top < 0); }
|
||||||
|
|
||||||
int Size() { return _top + 1; }
|
int Size() { return _top + 1; }
|
||||||
|
|||||||
Reference in New Issue
Block a user