Skip to content

Commit

Permalink
Fix pathfinding and increase player path limit
Browse files Browse the repository at this point in the history
The previous implementation didn't behave quite like A-* is supposed to.

After trying to figure out what's causing it and giving up,
I've reimplemented it in a straightforward manner.
Now it seems to work a lot better.

Also increases maximum player path length to 100 steps.
We still only store the first 25 steps in the save file for vanilla
compatibility.
  • Loading branch information
glebm authored and AJenbo committed Jan 26, 2025
1 parent 471a448 commit 3e6b501
Show file tree
Hide file tree
Showing 12 changed files with 265 additions and 316 deletions.
4 changes: 2 additions & 2 deletions Source/controls/plrctrls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ int GetDistance(Point destination, int maxDistance)
return 0;
}

int8_t walkpath[MaxPathLength];
int8_t walkpath[MaxPathLengthPlayer];
Player &myPlayer = *MyPlayer;
int steps = FindPath(CanStep, [&myPlayer](Point position) { return PosOkPlayer(myPlayer, position); }, myPlayer.position.future, destination, walkpath);
int steps = FindPath(CanStep, [&myPlayer](Point position) { return PosOkPlayer(myPlayer, position); }, myPlayer.position.future, destination, walkpath, std::min<size_t>(maxDistance, MaxPathLengthPlayer));
if (steps > maxDistance)
return 0;

Expand Down
Loading

0 comments on commit 3e6b501

Please sign in to comment.