Skip to content

Commit

Permalink
Blindly throw a conditional check in here, just in case the unhandled…
Browse files Browse the repository at this point in the history
… exception is the only bad thing going on here.
  • Loading branch information
airbreather committed Jan 8, 2025
1 parent 76440df commit f8e6d6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/Autopelago/Game.RouteCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ private bool UpdateTargetLocation()
_pathToTarget.Clear();
bool first = true;
GetPath(CurrentLocation, TargetLocation);
_pathToTarget.EnsureCapacity(_prevPath.Count - 1);

// consider: why is this sometimes empty immediately after calling GetPath???
if (_prevPath.Count > 0)
{
_pathToTarget.EnsureCapacity(_prevPath.Count - 1);
}

foreach (LocationKey l in _prevPath)
{
if (first)
Expand Down
4 changes: 2 additions & 2 deletions src/Autopelago/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,12 @@ public void Advance()
// combat this, every time the player decides to move, they can advance up to three
// whole spaces towards their target. this keeps the overall progression speed the
// same in dense areas.
for (int i = 0; i < MaxMovementsPerAction && CurrentLocation != TargetLocation; i++)
for (int i = 0; i < MaxMovementsPerAction && CurrentLocation != TargetLocation && _pathToTarget.TryDequeue(out LocationKey dequeued); i++)
{
_movementLog.Add(new()
{
PreviousLocation = CurrentLocation,
CurrentLocation = _pathToTarget.Dequeue(),
CurrentLocation = dequeued,
});

CurrentLocation = _movementLog[^1].CurrentLocation;
Expand Down

0 comments on commit f8e6d6e

Please sign in to comment.