Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: prevent useless pathfinder run for blocked vehicles #8568

Merged
merged 1 commit into from Jan 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/roadveh_cmd.cpp
Expand Up @@ -1389,7 +1389,16 @@ bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev)
int y = TileY(v->tile) * TILE_SIZE + rdp[turn_around_start_frame].y;

Direction new_dir = RoadVehGetSlidingDirection(v, x, y);
if (v->IsFrontEngine() && RoadVehFindCloseTo(v, x, y, new_dir) != nullptr) return false;
if (v->IsFrontEngine() && RoadVehFindCloseTo(v, x, y, new_dir) != nullptr) {
/* We are blocked. */
v->cur_speed = 0;
if (!v->path.empty()) {
/* Prevent pathfinding rerun as we already know where we are heading to. */
v->path.tile.push_front(v->tile);
v->path.td.push_front(dir);
}
return false;
}

uint32 r = VehicleEnterTile(v, v->tile, x, y);
if (HasBit(r, VETS_CANNOT_ENTER)) {
Comment on lines 1403 to 1404
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered if the pathfinder prevention checks should be also added to VETS_CANNOT_ENTER, but I wasn't able find a situation where HasBit(r, VETS_CANNOT_ENTER) is true for testing that.

Expand Down