Codechange: Replace duplicated code with TileArea::Expand() (#7467)
This commit is contained in:
@@ -156,8 +156,7 @@ Industry::~Industry()
|
||||
}
|
||||
|
||||
if (GetIndustrySpec(this->type)->behaviour & INDUSTRYBEH_PLANT_FIELDS) {
|
||||
TileArea ta(this->location.tile - TileDiffXY(min(TileX(this->location.tile), 21), min(TileY(this->location.tile), 21)), 42, 42);
|
||||
ta.ClampToMap();
|
||||
TileArea ta = TileArea(this->location.tile, 0, 0).Expand(21);
|
||||
|
||||
/* Remove the farmland and convert it to regular tiles over time. */
|
||||
TILE_AREA_LOOP(tile_cur, ta) {
|
||||
@@ -1533,6 +1532,8 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags,
|
||||
/* Check that all tiles in area and surrounding are clear
|
||||
* this determines that there are no obstructing items */
|
||||
|
||||
/* TileArea::Expand is not used here as we need to abort
|
||||
* instead of clamping if the bounds cannot expanded. */
|
||||
TileArea ta(tile + TileDiffXY(-_settings_game.construction.industry_platform, -_settings_game.construction.industry_platform),
|
||||
max_x + 2 + 2 * _settings_game.construction.industry_platform, max_y + 2 + 2 * _settings_game.construction.industry_platform);
|
||||
|
||||
@@ -1593,9 +1594,7 @@ static CommandCost CheckIfFarEnoughFromConflictingIndustry(TileIndex tile, int t
|
||||
/* On a large map with many industries, it may be faster to check an area. */
|
||||
static const int dmax = 14;
|
||||
if (Industry::GetNumItems() > (size_t) (dmax * dmax * 2)) {
|
||||
const int tx = TileX(tile);
|
||||
const int ty = TileY(tile);
|
||||
TileArea tile_area = TileArea(TileXY(max(0, tx - dmax), max(0, ty - dmax)), TileXY(min(MapMaxX(), tx + dmax), min(MapMaxY(), ty + dmax)));
|
||||
TileArea tile_area = TileArea(tile, 1, 1).Expand(dmax);
|
||||
TILE_AREA_LOOP(atile, tile_area) {
|
||||
if (GetTileType(atile) == MP_INDUSTRY) {
|
||||
const Industry *i2 = Industry::GetByTile(atile);
|
||||
|
Reference in New Issue
Block a user