Changeset - r14785:131e7c9c7157
[Not reviewed]
master
0 1 0
frosch - 14 years ago 2010-03-10 20:45:23
frosch@openttd.org
(svn r19384) -Fix: Overbuilding plain rail with stations did not update PBS reservation.
1 file changed with 11 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -741,9 +741,10 @@ CommandCost CheckFlatLand(TileArea tile_
 
 * @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 CheckFlatLandRailStat
 
				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(TileInde
 

	
 
	/* 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(TileInde
 

	
 
		numtracks_orig = numtracks;
 

	
 
		SmallVector<Train*, 4> affected_vehicles;
 
		do {
 
			TileIndex tile = tile_org;
 
			int w = plat_len;
0 comments (0 inline, 0 general)