File diff r23616:e1fb1b190a7f → r23617:216c443321e5
src/industry_cmd.cpp
Show inline comments
 
@@ -153,14 +153,13 @@ Industry::~Industry()
 
		} else if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
 
			DeleteOilRig(tile_cur);
 
		}
 
	}
 

	
 
	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) {
 
			if (IsTileType(tile_cur, MP_CLEAR) && IsClearGround(tile_cur, CLEAR_FIELDS) &&
 
					GetIndustryIndexOfField(tile_cur) == this->index) {
 
				SetIndustryIndexOfField(tile_cur, INVALID_INDUSTRY);
 
@@ -1530,12 +1529,14 @@ static bool CheckIfCanLevelIndustryPlatf
 
	uint h = TileHeight(tile);
 

	
 
	if (TileX(tile) <= _settings_game.construction.industry_platform + 1U || TileY(tile) <= _settings_game.construction.industry_platform + 1U) return false;
 
	/* 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);
 

	
 
	if (TileX(ta.tile) + ta.w >= MapMaxX() || TileY(ta.tile) + ta.h >= MapMaxY()) return false;
 

	
 
	/* _current_company is OWNER_NONE for randomly generated industries and in editor, or the company who funded or prospected the industry.
 
@@ -1590,15 +1591,13 @@ static CommandCost CheckIfFarEnoughFromC
 
	const IndustrySpec *indspec = GetIndustrySpec(type);
 
	const Industry *i = nullptr;
 

	
 
	/* 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);
 
				if (i == i2) continue;
 
				i = i2;
 
				if (DistanceMax(tile, i->location.tile) > (uint)dmax) continue;