# HG changeset patch # User adf88@interia.pl # Date 1503167716 -7200 # Sat Aug 19 20:35:16 2017 +0200 # Branch trunk # Node ID 1549869412e37381c1d259752997479faee6482d # Parent 584e1cc2ffb25cb095e7ffa701d23530d5d10ea5 When placing an airport, check for flat land and clear tiles that belong to the airport tile table only rather then iterating whole airport rectangle. diff -r 584e1cc2ffb2 -r 1549869412e3 src/station_cmd.cpp --- a/src/station_cmd.cpp Sun Aug 13 18:38:42 2017 +0000 +++ b/src/station_cmd.cpp Sat Aug 19 20:35:16 2017 +0200 @@ -771,22 +771,22 @@ } /** - * Tries to clear the given area. - * @param tile_area Area to check. + * Checks if an airport can be built at the given location and clear the area. + * @param tile_iter Airport tile iterator. * @param flags Operation to perform. * @return The cost in case of success, or an error code if it failed. */ -CommandCost CheckFlatLand(TileArea tile_area, DoCommandFlag flags) +static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCommandFlag flags) { CommandCost cost(EXPENSES_CONSTRUCTION); int allowed_z = -1; - TILE_AREA_LOOP(tile_cur, tile_area) { - CommandCost ret = CheckBuildableTile(tile_cur, 0, allowed_z, true); + for (; tile_iter != INVALID_TILE; ++tile_iter) { + CommandCost ret = CheckBuildableTile(tile_iter, 0, allowed_z, true); if (ret.Failed()) return ret; cost.AddCost(ret); - ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR); + ret = DoCommand(tile_iter, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (ret.Failed()) return ret; cost.AddCost(ret); } @@ -2216,11 +2216,11 @@ return_cmd_error(STR_ERROR_STATION_TOO_SPREAD_OUT); } - CommandCost cost = CheckFlatLand(airport_area, flags); + AirportTileTableIterator iter(as->table[layout], tile); + CommandCost cost = CheckFlatLandAirport(iter, flags); if (cost.Failed()) return cost; /* The noise level is the noise from the airport and reduce it to account for the distance to the town center. */ - AirportTileTableIterator iter(as->table[layout], tile); Town *nearest = AirportGetNearestTown(as, iter); uint newnoise_level = GetAirportNoiseLevelForTown(as, iter, nearest->xy);