summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-09-21 18:29:18 +0000
committerrubidium <rubidium@openttd.org>2014-09-21 18:29:18 +0000
commit26239c3d89327d2b94210097f90ae3c6dba3dbc7 (patch)
treec0f29619698a839f674fb4653902540a79895526 /src
parent03b731f9290d08674e254bdb17f83b721a3f96c4 (diff)
downloadopenttd-26239c3d89327d2b94210097f90ae3c6dba3dbc7.tar.xz
(svn r26905) -Change: account for the maximum map height when converting heightmaps
Diffstat (limited to 'src')
-rw-r--r--src/heightmap.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/heightmap.cpp b/src/heightmap.cpp
index 93cfa0a62..acbb202e2 100644
--- a/src/heightmap.cpp
+++ b/src/heightmap.cpp
@@ -364,8 +364,16 @@ static void GrayscaleToMapHeights(uint img_width, uint img_height, byte *map)
assert(img_row < img_height);
assert(img_col < img_width);
- /* Colour scales from 0 to 255, OpenTTD height scales from 0 to 15 */
- SetTileHeight(tile, map[img_row * img_width + img_col] / 16);
+ /* The height in 1/255ths. */
+ uint heightmap_height = map[img_row * img_width + img_col];
+
+ /* The height in 1/255ths of the maximum height. */
+ heightmap_height *= _settings_game.construction.max_heightlevel;
+
+ /* Scaling should not alter the coastline, thus values in the interval ]0..1] result in a heightlevel of 1 */
+ if (IsInsideMM(heightmap_height, 1, UINT8_MAX)) heightmap_height = UINT8_MAX;
+
+ SetTileHeight(tile, heightmap_height / UINT8_MAX);
}
/* Only clear the tiles within the map area. */
if (IsInnerTile(tile)) {