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.
This commit is contained in:
@@ -119,7 +119,7 @@ private:
|
|||||||
tile = TILE_ADD(tile, diff);
|
tile = TILE_ADD(tile, diff);
|
||||||
}
|
}
|
||||||
} else if (tile != m_res_fail_tile || td != m_res_fail_td) {
|
} 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);
|
return (tile != m_res_dest || td != m_res_dest_td) && (tile != m_res_fail_tile || td != m_res_fail_td);
|
||||||
}
|
}
|
||||||
|
14
src/pbs.cpp
14
src/pbs.cpp
@@ -154,6 +154,20 @@ bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations)
|
|||||||
return false;
|
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
|
* Lift the reservation of a specific track on a tile
|
||||||
* @param tile the 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 TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations = true);
|
||||||
bool TryReserveRailTrackdir(TileIndex tile, Trackdir td, bool trigger_stations = true);
|
bool TryReserveRailTrackdir(TileIndex tile, Trackdir td, bool trigger_stations = true);
|
||||||
void UnreserveRailTrack(TileIndex tile, Track t);
|
void UnreserveRailTrack(TileIndex tile, Track t);
|
||||||
|
void UnreserveRailTrackdir(TileIndex tile, Trackdir td);
|
||||||
|
|
||||||
/** This struct contains information about the end of a reserved path. */
|
/** This struct contains information about the end of a reserved path. */
|
||||||
struct PBSTileInfo {
|
struct PBSTileInfo {
|
||||||
|
@@ -2415,7 +2415,7 @@ static PBSTileInfo ExtendTrainReservation(const Train *v, const PBSTileInfo &ori
|
|||||||
tile = ft.m_new_tile;
|
tile = ft.m_new_tile;
|
||||||
cur_td = FindFirstTrackdir(ft.m_new_td_bits);
|
cur_td = FindFirstTrackdir(ft.m_new_td_bits);
|
||||||
|
|
||||||
UnreserveRailTrack(tile, TrackdirToTrack(cur_td));
|
UnreserveRailTrackdir(tile, cur_td);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Path invalid. */
|
/* Path invalid. */
|
||||||
|
Reference in New Issue
Block a user