* 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 */
| 93 | * @return Whether the tile is flat |
| 94 | */ |
| 95 | bool 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 |
no test coverage detected