summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-03-10 20:45:23 +0000
committerfrosch <frosch@openttd.org>2010-03-10 20:45:23 +0000
commitf7eb527a372e69332970a5fe9d3229c185aeddea (patch)
tree5361b513724c96d8df0abd69430dc1eb0f00b3d5
parentc0a9215bad60a6e58274b9891bf981faea697bc1 (diff)
downloadopenttd-f7eb527a372e69332970a5fe9d3229c185aeddea.tar.xz
(svn r19384) -Fix: Overbuilding plain rail with stations did not update PBS reservation.
-rw-r--r--src/station_cmd.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 16fcbce37..a6452151c 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -741,9 +741,10 @@ CommandCost CheckFlatLand(TileArea tile_area, DoCommandFlag flags)
* @param invalid_dirs Prohibited directions (set of #DiagDirection).
* @param station StationID to be queried and returned if available.
* @param rt The rail type to check for (overbuilding rail stations over rail).
+ * @param affected_vehicles List of trains with PBS reservations on the tiles
* @return The cost in case of success, or an error code if it failed.
*/
-static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, uint invalid_dirs, StationID *station, RailType rt = INVALID_RAILTYPE)
+static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, uint invalid_dirs, StationID *station, RailType rt, SmallVector<Train *, 4> &affected_vehicles)
{
CommandCost cost(EXPENSES_CONSTRUCTION);
int allowed_z = -1;
@@ -784,6 +785,13 @@ static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag fl
Track expected_track = HasBit(invalid_dirs, DIAGDIR_NE) ? TRACK_X : TRACK_Y;
if (tracks == TRACK_BIT_NONE && track == expected_track) {
+ /* Check for trains having a reservation for this tile. */
+ if (HasBit(GetRailReservationTrackBits(tile_cur), track)) {
+ Train *v = GetTrainForReservation(tile_cur, track);
+ if (v != NULL) {
+ *affected_vehicles.Append() = v;
+ }
+ }
CommandCost ret = DoCommand(tile_cur, 0, track, flags, CMD_REMOVE_SINGLE_RAIL);
if (ret.Failed()) return ret;
cost.AddCost(ret);
@@ -1130,8 +1138,9 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
/* Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station) */
StationID est = INVALID_STATION;
+ SmallVector<Train *, 4> affected_vehicles;
/* Clear the land below the station. */
- CommandCost cost = CheckFlatLandRailStation(TileArea(tile_org, w_org, h_org), flags, 5 << axis, _settings_game.station.nonuniform_stations ? &est : NULL, rt);
+ CommandCost cost = CheckFlatLandRailStation(TileArea(tile_org, w_org, h_org), flags, 5 << axis, _settings_game.station.nonuniform_stations ? &est : NULL, rt, affected_vehicles);
if (cost.Failed()) return cost;
/* Add construction expenses. */
cost.AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len);
@@ -1222,7 +1231,6 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
numtracks_orig = numtracks;
- SmallVector<Train*, 4> affected_vehicles;
do {
TileIndex tile = tile_org;
int w = plat_len;