Fix unreserving through a green PBS signal not setting the state to red.

This also had the side effect of failed reservation attempts through
a reserve-through signal leaving the signal erroneously set to green.
pull/6/merge
Jonathan G Rennison 8 years ago
parent 83369d5e71
commit 1bb3024534

@ -119,7 +119,7 @@ private:
tile = TILE_ADD(tile, diff);
}
} else if (tile != m_res_fail_tile || td != m_res_fail_td) {
UnreserveRailTrack(tile, TrackdirToTrack(td));
UnreserveRailTrackdir(tile, td);
}
return (tile != m_res_dest || td != m_res_dest_td) && (tile != m_res_fail_tile || td != m_res_fail_td);
}

@ -154,6 +154,20 @@ bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations)
return false;
}
/**
* Lift the reservation of a specific trackdir on a tile
* This also sets PBS signals to red if unreserving through the facing track direction
* @param tile the tile
* @param t the track
*/
void UnreserveRailTrackdir(TileIndex tile, Trackdir td)
{
if (HasPbsSignalOnTrackdir(tile, td)) {
SetSignalStateByTrackdir(tile, td, SIGNAL_STATE_RED);
}
UnreserveRailTrack(tile, TrackdirToTrack(td));
}
/**
* Lift the reservation of a specific track on a tile
* @param tile the tile

@ -24,6 +24,7 @@ void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool
bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations = true);
bool TryReserveRailTrackdir(TileIndex tile, Trackdir td, bool trigger_stations = true);
void UnreserveRailTrack(TileIndex tile, Track t);
void UnreserveRailTrackdir(TileIndex tile, Trackdir td);
/** This struct contains information about the end of a reserved path. */
struct PBSTileInfo {

@ -2415,7 +2415,7 @@ static PBSTileInfo ExtendTrainReservation(const Train *v, const PBSTileInfo &ori
tile = ft.m_new_tile;
cur_td = FindFirstTrackdir(ft.m_new_td_bits);
UnreserveRailTrack(tile, TrackdirToTrack(cur_td));
UnreserveRailTrackdir(tile, cur_td);
}
/* Path invalid. */

Loading…
Cancel
Save