1
0
Fork 0

Add: Hide stopped road vehicles in extended depots that block the path of another vehicle.

pull/8480/head
J0anJosep 2021-11-13 19:15:47 +01:00
parent d9b182df78
commit 861de832f6
1 changed files with 30 additions and 0 deletions

View File

@ -683,6 +683,27 @@ static Vehicle *EnumCheckRoadVehClose(Vehicle *v, void *data)
return nullptr; return nullptr;
} }
/**
* Hide a stopped and visible road vehicle in an extended depot.
* @param v The road vehicle
* @pre v->IsStoppedInDepot() && IsExtendedRoadDepotTile(v->tile)
*/
static void LiftRoadVehicleInDepot(RoadVehicle *v)
{
assert(v->IsStoppedInDepot());
assert(IsExtendedRoadDepotTile(v->tile));
for (RoadVehicle *rv = v; rv != nullptr; rv = rv->Next()) {
rv->vehstatus |= VS_HIDDEN;
rv->tile = v->tile;
rv->direction = v->direction;
rv->x_pos = v->x_pos;
rv->y_pos = v->y_pos;
rv->UpdatePosition();
rv->Vehicle::UpdateViewport(true);
}
UpdateExtendedDepotReservation(v, false);
}
static RoadVehicle *RoadVehFindCloseTo(RoadVehicle *v, int x, int y, Direction dir, bool update_blocked_ctr = true) static RoadVehicle *RoadVehFindCloseTo(RoadVehicle *v, int x, int y, Direction dir, bool update_blocked_ctr = true)
{ {
RoadVehFindData rvf; RoadVehFindData rvf;
@ -716,6 +737,15 @@ static RoadVehicle *RoadVehFindCloseTo(RoadVehicle *v, int x, int y, Direction d
rvf.best = rvf.best->First(); rvf.best = rvf.best->First();
/* If the best vehicle is a road vehicle stopped in an extended depot,
* it is in the way of the moving vehicle. Hide the stopped vehicle
* inside the depot. */
if (rvf.best->IsStoppedInDepot()) {
assert(IsExtendedRoadDepotTile(rvf.best->tile));
LiftRoadVehicleInDepot(RoadVehicle::From(rvf.best));
return nullptr;
}
return RoadVehicle::From(rvf.best); return RoadVehicle::From(rvf.best);
} }