Changeset - r16742:db1dd4012898
[Not reviewed]
master
0 1 0
rubidium - 13 years ago 2010-12-12 18:18:50
rubidium@openttd.org
(svn r21485) -Codechange: use CircularTileSearch to find whether there's a transmitter nearby
1 file changed with 10 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/object_cmd.cpp
Show inline comments
 
@@ -563,18 +563,15 @@ static void AnimateTile_Object(TileIndex
 
	AnimateNewObjectTile(tile);
 
}
 

	
 
/* checks, if a radio tower is within a 9x9 tile square around tile */
 
static bool IsRadioTowerNearby(TileIndex tile)
 
/**
 
 * Helper function for \c CircularTileSearch.
 
 * @param tile The tile to check.
 
 * @param user Ignored.
 
 * @return True iff the tile has a radio tower.
 
 */
 
static bool HasTransmitter(TileIndex tile, void *user)
 
{
 
	TileIndex tile_s = tile - TileDiffXY(min(TileX(tile), 4U), min(TileY(tile), 4U));
 
	uint w = min(TileX(tile), 4U) + 1 + min(MapMaxX() - TileX(tile), 4U);
 
	uint h = min(TileY(tile), 4U) + 1 + min(MapMaxY() - TileY(tile), 4U);
 

	
 
	TILE_LOOP(tile, w, h, tile_s) {
 
		if (IsTransmitterTile(tile)) return true;
 
	}
 

	
 
	return false;
 
	return IsTransmitterTile(tile);
 
}
 

	
 
void GenerateObjects()
 
@@ -608,7 +605,8 @@ void GenerateObjects()
 

	
 
		uint h;
 
		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h >= TILE_HEIGHT * 4 && !IsBridgeAbove(tile)) {
 
			if (IsRadioTowerNearby(tile)) continue;
 
			TileIndex t = tile;
 
			if (CircularTileSearch(&t, 9, HasTransmitter, NULL)) continue;
 

	
 
			BuildObject(OBJECT_TRANSMITTER, tile);
 
			IncreaseGeneratingWorldProgress(GWP_OBJECT);
0 comments (0 inline, 0 general)