|
|
|
@ -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;
|
|
|
|
|