1
0
Fork 0

Compare commits

...

2 Commits

Author SHA1 Message Date
mrmbernardi b61c3622e7
Merge fe3d5a7718 into aaf5d39b15 2025-07-11 04:45:47 +00:00
Michael Bernardi fe3d5a7718 Fix #10467: [YAPF] Trains do not use all available tracks 2023-07-27 21:25:29 +02:00
1 changed files with 8 additions and 2 deletions

View File

@ -161,12 +161,18 @@ public:
if (n.num_signals_passed >= this->sig_look_ahead_costs.size() / 2) return 0;
if (!IsPbsSignal(n.last_signal_type)) return 0;
const Train *v = Yapf().GetVehicle();
assert(v != nullptr);
assert(v->type == VEH_TRAIN);
/* the longer a train waits, the more it will consider longer routes around blocking trains */
int impatience = std::max(0, v->wait_counter - DAY_TICKS / 2);
if (IsRailStationTile(tile) && IsAnyStationTileReserved(tile, trackdir, skipped)) {
return Yapf().PfGetSettings().rail_pbs_station_penalty * (skipped + 1);
return Yapf().PfGetSettings().rail_pbs_station_penalty * (skipped + 1) + impatience;
} else if (TrackOverlapsTracks(GetReservedTrackbits(tile), TrackdirToTrack(trackdir))) {
int cost = Yapf().PfGetSettings().rail_pbs_cross_penalty;
if (!IsDiagonalTrackdir(trackdir)) cost = (cost * YAPF_TILE_CORNER_LENGTH) / YAPF_TILE_LENGTH;
return cost * (skipped + 1);
return cost * (skipped + 1) + impatience;
}
return 0;
}