Fixed crashes and errors when loading into world.

This commit is contained in:
hondacrx
2022-06-21 14:56:22 -04:00
parent be8e18450e
commit 63cbd18350
12 changed files with 79 additions and 31 deletions
+2 -2
View File
@@ -47,7 +47,7 @@ namespace Game.AI
SmartEscortState _escortState;
uint _escortNPCFlags;
uint _escortInvokerCheckTimer;
WaypointPath _path;
WaypointPath _path = new();
uint _currentWaypointNode;
bool _waypointReached;
uint _waypointPauseTimer;
@@ -132,7 +132,6 @@ namespace Game.AI
return false;
}
_path = new WaypointPath();
_path.id = path.id;
_path.nodes.AddRange(path.nodes);
foreach (WaypointNode waypoint in _path.nodes)
@@ -802,6 +801,7 @@ namespace Game.AI
{
me.SetWalk(!run);
_run = run;
foreach (var node in _path.nodes)
node.moveType = run ? WaypointMoveType.Run : WaypointMoveType.Walk;
}
@@ -912,7 +912,7 @@ namespace Game.AI
return true;
}
bool IsEventValid(SmartScriptHolder e)
{
if (e.Event.type >= SmartEvents.End)
@@ -2435,7 +2435,7 @@ namespace Game.AI
}
}
public class SmartScriptHolder : IComparer<SmartScriptHolder>
public class SmartScriptHolder : IComparable<SmartScriptHolder>
{
public const uint DefaultPriority = uint.MaxValue;
@@ -2478,17 +2478,17 @@ namespace Game.AI
return $"Entry {EntryOrGuid} SourceType {GetScriptType()} Event {EventId} Action {GetActionType()}";
}
public int Compare(SmartScriptHolder left, SmartScriptHolder right)
public int CompareTo(SmartScriptHolder other)
{
int result = left.Priority.CompareTo(right.Priority);
int result = Priority.CompareTo(other.Priority);
if (result == 0)
result = left.EntryOrGuid.CompareTo(right.EntryOrGuid);
result = EntryOrGuid.CompareTo(other.EntryOrGuid);
if (result == 0)
result = left.SourceType.CompareTo(right.SourceType);
result = SourceType.CompareTo(other.SourceType);
if (result == 0)
result = left.EventId.CompareTo(right.EventId);
result = EventId.CompareTo(other.EventId);
if (result == 0)
result = left.Link.CompareTo(right.Link);
result = Link.CompareTo(other.Link);
return result;
}