Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
NPF bails out when source tile is also a destination tile #7114
If the tile a vehicle is leaving is also a valid destination tile, NPF just returns INVALID_TRACKDIR and does no pathfinding at all.
As NPF(Ship-Train-RoadVehicle)ChooseTrack call the pathfinder with the NPF_FLAG_IGNORE_START_TILE set, use it for not accepting the starting tile as a valid destination tile.
Please, do a thorough review of this PR and make sure it doesn't create any new bug.
I tried to trigger the asserts. Tried by ordering a ship to go to depot right after leaving it, it walks now, no longer doing 180º reverse.
Tried no tracks in front of the ship, of a train, and road vehicle, and the asserts don't trigger. It's always chosing a track different than invalid.
I also checked with river generation. Doesn't make any difference. The code there always require that the river has moved one step minimum from a tile to another.