mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
3 Commits
959a330d9f
...
501e8aa73b
Author | SHA1 | Date |
---|---|---|
|
501e8aa73b | |
|
c69fc76395 | |
|
fe3d5a7718 |
|
@ -161,12 +161,18 @@ public:
|
||||||
if (n.num_signals_passed >= this->sig_look_ahead_costs.size() / 2) return 0;
|
if (n.num_signals_passed >= this->sig_look_ahead_costs.size() / 2) return 0;
|
||||||
if (!IsPbsSignal(n.last_signal_type)) 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)) {
|
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))) {
|
} else if (TrackOverlapsTracks(GetReservedTrackbits(tile), TrackdirToTrack(trackdir))) {
|
||||||
int cost = Yapf().PfGetSettings().rail_pbs_cross_penalty;
|
int cost = Yapf().PfGetSettings().rail_pbs_cross_penalty;
|
||||||
if (!IsDiagonalTrackdir(trackdir)) cost = (cost * YAPF_TILE_CORNER_LENGTH) / YAPF_TILE_LENGTH;
|
if (!IsDiagonalTrackdir(trackdir)) cost = (cost * YAPF_TILE_CORNER_LENGTH) / YAPF_TILE_LENGTH;
|
||||||
return cost * (skipped + 1);
|
return cost * (skipped + 1) + impatience;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Bridge offset
|
* Bridge offset
|
||||||
*/
|
*/
|
||||||
SpriteID bridge_offset;
|
uint8_t bridge_offset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.
|
* Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.
|
||||||
|
|
Loading…
Reference in New Issue