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

Function TileVirtXYClampedToMap

src/map.cpp:84–87  ·  view source on GitHub ↗

* Get a tile from the virtual XY-coordinate. * Coordinates outside of the map are clamped to the map edge. * @param x The virtual x coordinate of the tile. * @param y The virtual y coordinate of the tile. * @return The TileIndex calculated by the coordinate, clamped to the map bounds. */

Source from the content-addressed store, hash-verified

82 * @return The TileIndex calculated by the coordinate, clamped to the map bounds.
83 */
84TileIndex TileVirtXYClampedToMap(int x, int y)
85{
86 return TileIndex{(static_cast<uint>(Clamp<int>(y / static_cast<int>(TILE_SIZE), 0, Map::MaxY())) << Map::LogX()) + static_cast<uint>(Clamp<int>(x / static_cast<int>(TILE_SIZE), 0, Map::MaxX()))};
87}
88
89#ifdef _DEBUG
90TileIndex TileAdd(TileIndex tile, TileIndexDiff offset)

Callers 2

FindNearestHangarFunction · 0.85
CrashAirplaneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected