diff options
author | Johannes E. Krause <j.k@eclipso.de> | 2019-01-13 20:58:48 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-01-24 21:17:17 +0100 |
commit | c33596fe4af59213a8a6119fee61a75ed91abdc4 (patch) | |
tree | a88ea65bb25e6a66aff19ac11d4039b7314e7a1b /src/tile_map.h | |
parent | 05da5a177c7e976d5da0da541a842482ab23017d (diff) | |
download | openttd-c33596fe4af59213a8a6119fee61a75ed91abdc4.tar.xz |
Codechange: Unify tile height model in all functions (Patch by adf88, #6583)
Diffstat (limited to 'src/tile_map.h')
-rw-r--r-- | src/tile_map.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/tile_map.h b/src/tile_map.h index 3fad368cd..7a76f2b97 100644 --- a/src/tile_map.h +++ b/src/tile_map.h @@ -34,7 +34,17 @@ static inline uint TileHeight(TileIndex tile) return _m[tile].height; } -uint TileHeightOutsideMap(int x, int y); +/** + * Returns the height of a tile, also for tiles outside the map (virtual "black" tiles). + * + * @param x X coordinate of the tile, may be ouside the map. + * @param y Y coordinate of the tile, may be ouside the map. + * @return The height in the same unit as TileHeight. + */ +static inline uint TileHeightOutsideMap(int x, int y) +{ + return TileHeight(TileXY(Clamp(x, 0, MapMaxX()), Clamp(y, 0, MapMaxY()))); +} /** * Sets the height of a tile. @@ -67,11 +77,10 @@ static inline uint TilePixelHeight(TileIndex tile) } /** - * Returns the tile height for a coordinate outside map. Such a height is - * needed for painting the area outside map using completely black tiles. - * The idea is descending to heightlevel 0 as fast as possible. - * @param x The X-coordinate (same unit as TileX). - * @param y The Y-coordinate (same unit as TileY). + * Returns the height of a tile in pixels, also for tiles outside the map (virtual "black" tiles). + * + * @param x X coordinate of the tile, may be ouside the map. + * @param y Y coordinate of the tile, may be ouside the map. * @return The height in pixels in the same unit as TilePixelHeight. */ static inline uint TilePixelHeightOutsideMap(int x, int y) |