Avoid RVs overtaking into the path of another overtaking RV

This commit is contained in:
Jonathan G Rennison
2020-10-25 16:59:54 +00:00
parent c67b8f7d0e
commit 569d715cfc

View File

@@ -970,7 +970,10 @@ static void RoadVehCheckOvertake(RoadVehicle *v, RoadVehicle *u)
} }
if (CheckRoadBlockedForOvertaking(&od)) return; if (CheckRoadBlockedForOvertaking(&od)) return;
} }
tile_count = v->gcache.cached_total_length / TILE_SIZE; DiagDirection dir = DirToDiagDir(v->direction);
int tile_offset = ((DiagDirToAxis(DirToDiagDir(v->direction)) == AXIS_X) ? v->x_pos : v->y_pos) & 0xF;
int tile_ahead_margin = ((dir == DIAGDIR_SE || dir == DIAGDIR_SW) ? TILE_SIZE - 1 - tile_offset : tile_offset);;
tile_count = (v->gcache.cached_total_length + tile_ahead_margin) / TILE_SIZE;
check_tile = v->tile - check_tile_diff; check_tile = v->tile - check_tile_diff;
for (; tile_count != 0; tile_count--, check_tile -= check_tile_diff) { for (; tile_count != 0; tile_count--, check_tile -= check_tile_diff) {
od.tile = check_tile; od.tile = check_tile;