unmovable_cmd.c
changeset 4083 09ca2e8a41ea
parent 4077 d4d440dd8925
child 4230 f4e93251e2f6
equal deleted inserted replaced
4082:6a21544873f0 4083:09ca2e8a41ea
   295 	if (IsCompanyHQ(tile)) ShowPlayerCompany(GetTileOwner(tile));
   295 	if (IsCompanyHQ(tile)) ShowPlayerCompany(GetTileOwner(tile));
   296 }
   296 }
   297 
   297 
   298 
   298 
   299 /* checks, if a radio tower is within a 9x9 tile square around tile */
   299 /* checks, if a radio tower is within a 9x9 tile square around tile */
   300 static bool checkRadioTowerNearby(TileIndex tile)
   300 static bool IsRadioTowerNearby(TileIndex tile)
   301 {
   301 {
   302 	TileIndex tile_s = tile - TileDiffXY(4, 4);
   302 	TileIndex tile_s = tile - TileDiffXY(4, 4);
   303 
   303 
   304 	BEGIN_TILE_LOOP(tile, 9, 9, tile_s)
   304 	BEGIN_TILE_LOOP(tile, 9, 9, tile_s)
   305 		if (IsTransmitterTile(tile)) return false;
   305 		if (IsTransmitterTile(tile)) return true;
   306 	END_TILE_LOOP(tile, 9, 9, tile_s)
   306 	END_TILE_LOOP(tile, 9, 9, tile_s)
   307 	return true;
   307 	return false;
   308 }
   308 }
   309 
   309 
   310 void GenerateUnmovables(void)
   310 void GenerateUnmovables(void)
   311 {
   311 {
   312 	int i,j;
   312 	int i,j;
   321 	i = ScaleByMapSize(1000);
   321 	i = ScaleByMapSize(1000);
   322 	j = ScaleByMapSize(40); // maximum number of radio towers on the map
   322 	j = ScaleByMapSize(40); // maximum number of radio towers on the map
   323 	do {
   323 	do {
   324 		tile = RandomTile();
   324 		tile = RandomTile();
   325 		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h >= TILE_HEIGHT * 4) {
   325 		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h >= TILE_HEIGHT * 4) {
   326 			if (!checkRadioTowerNearby(tile)) continue;
   326 			if (IsRadioTowerNearby(tile)) continue;
   327 			MakeTransmitter(tile);
   327 			MakeTransmitter(tile);
   328 			if (--j == 0) break;
   328 			if (--j == 0) break;
   329 		}
   329 		}
   330 	} while (--i);
   330 	} while (--i);
   331 
   331