1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-18 09:52:44 +01:00

Codechange: Replace CircularTileSearch with SpiralTileSequence.

This commit is contained in:
frosch
2025-04-19 15:58:48 +02:00
committed by frosch
parent 0dada5a750
commit b956af631e
10 changed files with 223 additions and 412 deletions

View File

@@ -744,16 +744,6 @@ static void AnimateTile_Object(TileIndex tile)
AnimateNewObjectTile(tile);
}
/**
* Helper function for \c CircularTileSearch.
* @param tile The tile to check.
* @return True iff the tile has a radio tower.
*/
static bool HasTransmitter(TileIndex tile, void *)
{
return IsObjectTypeTile(tile, OBJECT_TRANSMITTER);
}
/**
* Try to build a lighthouse.
* @return True iff building a lighthouse succeeded.
@@ -805,9 +795,9 @@ static bool TryBuildTransmitter()
TileIndex tile = RandomTile();
int h;
if (IsTileType(tile, MP_CLEAR) && IsTileFlat(tile, &h) && h >= 4 && !IsBridgeAbove(tile)) {
TileIndex t = tile;
if (CircularTileSearch(&t, 9, HasTransmitter, nullptr)) return false;
for (auto t : SpiralTileSequence(tile, 9)) {
if (IsObjectTypeTile(t, OBJECT_TRANSMITTER)) return false;
}
BuildObject(OBJECT_TRANSMITTER, tile);
return true;
}