MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / IsTileFlat

Function IsTileFlat

src/tile_map.cpp:95–109  ·  view source on GitHub ↗

* Check if a given tile is flat * @param tile Tile to check * @param h If not \c nullptr, pointer to storage of z height (only if tile is flat) * @return Whether the tile is flat */

Source from the content-addressed store, hash-verified

93 * @return Whether the tile is flat
94 */
95bool IsTileFlat(TileIndex tile, int *h)
96{
97 uint x1 = TileX(tile);
98 uint y1 = TileY(tile);
99 uint x2 = std::min(x1 + 1, Map::MaxX());
100 uint y2 = std::min(y1 + 1, Map::MaxY());
101
102 uint z = TileHeight(tile);
103 if (TileHeight(TileXY(x2, y1)) != z) return false;
104 if (TileHeight(TileXY(x1, y2)) != z) return false;
105 if (TileHeight(TileXY(x2, y2)) != z) return false;
106
107 if (h != nullptr) *h = z;
108 return true;
109}
110
111/**
112 * Get bottom height of the tile

Callers 15

CmdBuildShipDepotFunction · 0.85
DoBuildLockFunction · 0.85
IsWateredTileFunction · 0.85
GetTileTrackStatus_WaterFunction · 0.85
FindSpringFunction · 0.85
IsValidRiverTerminusTileFunction · 0.85
TryMakeRiverTerminusFunction · 0.85
RiverMakeWiderFunction · 0.85
CountConnectedSeaTilesFunction · 0.85
FlowRiverFunction · 0.85
CmdBuildBuoyFunction · 0.85

Calls 4

TileXFunction · 0.85
TileYFunction · 0.85
TileHeightFunction · 0.85
TileXYFunction · 0.85

Tested by

no test coverage detected