mirror of https://github.com/OpenTTD/OpenTTD
Add: Set reservation and penalties to improve pathfinding in extended depots.
parent
e26d14c5ef
commit
328f0ab20e
|
@ -607,6 +607,15 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
|
|||
uint platform_length = GetPlatformLength(n.GetLastTile(), ReverseDiagDir(TrackdirToExitdir(n.GetLastTrackdir())));
|
||||
/* Reduce the extra cost caused by passing-platform penalty (each platform receives it in the segment cost). */
|
||||
extra_cost -= Yapf().PfGetSettings().rail_station_penalty * platform_length;
|
||||
if (tf->m_is_extended_depot) {
|
||||
DepotReservation depot_reservation = GetDepotReservation(n.GetLastTile());
|
||||
if (depot_reservation == DEPOT_RESERVATION_FULL_STOPPED_VEH) {
|
||||
extra_cost += YAPF_INFINITE_PENALTY;
|
||||
} else {
|
||||
extra_cost += (HasDepotReservation(n.GetLastTile()) ? 2 : 1) * platform_length * Yapf().PfGetSettings().rail_station_penalty;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add penalty for the inappropriate platform length. */
|
||||
extra_cost += PlatformLengthPenalty(platform_length);
|
||||
}
|
||||
|
|
|
@ -2390,6 +2390,7 @@ bool HandleTrainEnterDepot(Train *v)
|
|||
for (Train *u = t; u != nullptr; u = u->Next()) u->track |= TRACK_BIT_DEPOT;
|
||||
t->force_proceed = TFP_NONE;
|
||||
ClrBit(t->flags, VRF_TOGGLE_REVERSE);
|
||||
UpdateExtendedDepotReservation(t, true);
|
||||
v->UpdateViewport(true, true);
|
||||
SetWindowClassesDirty(WC_TRAINS_LIST);
|
||||
SetWindowDirty(WC_VEHICLE_VIEW, v->index);
|
||||
|
@ -2481,6 +2482,7 @@ static bool CheckTrainStayInDepot(Train *v)
|
|||
v->UpdateAcceleration();
|
||||
ProcessOrders(v);
|
||||
if (CheckReverseTrain(v)) ReverseTrainDirection(v);
|
||||
UpdateExtendedDepotReservation(v, false);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, depot_id);
|
||||
|
||||
/* Check whether it is safe to exit the depot. */
|
||||
|
@ -3315,6 +3317,7 @@ uint Train::Crash(bool flooded)
|
|||
for (Train *v = this; v != nullptr; v = v->Next()) {
|
||||
v->track &= ~TRACK_BIT_DEPOT;
|
||||
}
|
||||
UpdateExtendedDepotReservation(this, false);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(this->tile));
|
||||
}
|
||||
/* Remove reserved tracks of platform ahead. */
|
||||
|
|
|
@ -185,6 +185,7 @@ void TrainPlacement::LiftTrain(Train *train, DoCommandFlag flags)
|
|||
if ((flags & DC_EXEC) == 0) return;
|
||||
|
||||
SetPlatformReservation(train->tile, false);
|
||||
UpdateExtendedDepotReservation(train, false);
|
||||
|
||||
UpdateSignalsOnSegment(train->tile, INVALID_DIAGDIR, train->owner);
|
||||
}
|
||||
|
@ -307,6 +308,7 @@ void TrainPlacement::PlaceTrain(Train *train, DoCommandFlag flags)
|
|||
}
|
||||
|
||||
SetPlatformReservation(train->tile, true);
|
||||
UpdateExtendedDepotReservation(train, true);
|
||||
|
||||
UpdateSignalsOnSegment(train->tile, INVALID_DIAGDIR, train->owner);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue