Misc fixes, and added GetDebugInfo() which was missed.

This commit is contained in:
hondacrx
2022-01-05 13:11:32 -05:00
parent b2ddeb3408
commit 0d68984717
28 changed files with 170 additions and 53 deletions
@@ -81,6 +81,8 @@ namespace Game.Movement
bool departureEvent = true;
do
{
Cypher.Assert(_currentNode < _path.Count, $"Point Id: {pointId}\n{owner.GetDebugInfo()}");
DoEventIfAny(owner, _path[_currentNode], departureEvent);
while (!_pointsForPathSwitch.Empty() && _pointsForPathSwitch[0].PathIndex <= _currentNode)
{
@@ -226,6 +228,8 @@ namespace Game.Movement
void DoEventIfAny(Player owner, TaxiPathNodeRecord node, bool departure)
{
Cypher.Assert(node != null, owner.GetDebugInfo());
uint eventid = departure ? node.DepartureEventID : node.ArrivalEventID;
if (eventid != 0)
{
@@ -263,6 +267,20 @@ namespace Game.Movement
Log.outDebug(LogFilter.Server, "FlightPathMovementGenerator::PreloadEndGrid: Unable to determine map to preload flightmaster grid");
}
uint GetPathId(int index)
{
if (index >= _path.Count)
return 0;
return _path[index].PathID;
}
public override string GetDebugInfo()
{
return $"Current Node: {GetCurrentNode()}\n{base.GetDebugInfo()}\nStart Path Id: {GetPathId(0)} Path Size: {_path.Count} HasArrived: {HasArrived()} End Grid X: {_endGridX} " +
$"End Grid Y: {_endGridY} End Map Id: {_endMapId} Preloaded Target Node: {_preloadTargetNode}";
}
public override bool GetResetPosition(Unit u, out float x, out float y, out float z)
{
var node = _path[_currentNode];
@@ -76,8 +76,13 @@ namespace Game.Movement
{
return obj.Mode.GetHashCode() ^ obj.Priority.GetHashCode();
}
}
public virtual string GetDebugInfo()
{
return $"Mode: {Mode} Priority: {Priority} Flags: {Flags} BaseUniteState: {BaseUnitState}";
}
}
public abstract class MovementGeneratorMedium<T> : MovementGenerator where T : Unit
{
public override void Initialize(Unit owner)
@@ -384,7 +384,7 @@ namespace Game.Movement
// this is probably an error state, but we'll leave it
// and hopefully recover on the next Update
// we still need to copy our preffix
Log.outError(LogFilter.Maps, "{0}'s Path Build failed: 0 length path", _sourceUnit.GetGUID().ToString());
Log.outError(LogFilter.Maps, $"Path Build failed\n{_sourceUnit.GetDebugInfo()}");
}
Log.outDebug(LogFilter.Maps, "m_polyLength={0} prefixPolyLength={1} suffixPolyLength={2} \n", _polyLength, prefixPolyLength, suffixPolyLength);
@@ -709,7 +709,7 @@ namespace Game.Movement
npolys = FixupCorridor(polys, npolys, 74, visited, nvisited);
if (Detour.dtStatusFailed(_navMeshQuery.getPolyHeight(polys[0], result, ref result[1])))
Log.outDebug(LogFilter.Maps, $"Cannot find height at position X: {result[2]} Y: {result[0]} Z: {result[1]} for ");// {_sourceUnit.GetDebugInfo()}");
Log.outDebug(LogFilter.Maps, $"Cannot find height at position X: {result[2]} Y: {result[0]} Z: {result[1]} for {_sourceUnit.GetDebugInfo()}");
result[1] += 0.5f;
Detour.dtVcopy(iterPos, result);
@@ -397,6 +397,11 @@ namespace Game.Movement
return true;
}
public override string GetDebugInfo()
{
return $"Current Node: {_currentNode}\n{base.GetDebugInfo()}";
}
bool UpdateTimer(uint diff)
{
_nextMoveTime.Update((int)diff);