diff options
author | frosch <frosch@openttd.org> | 2014-10-25 22:24:05 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2014-10-25 22:24:05 +0000 |
commit | d98d4130bdf6ad6582cf5560052ac304eb7a77ef (patch) | |
tree | cb35690bb9242de7a0ffdfb020d730176dc89dd2 /src | |
parent | dfd57f261617ada4f26f75f3c924ae7a8b426c43 (diff) | |
download | openttd-d98d4130bdf6ad6582cf5560052ac304eb7a77ef.tar.xz |
(svn r27044) -Change (r26905, r26984): Scale heightmap greyscales > 0 evenly to heightlevels > 0, instead of giving heightlevel 1 a bigger loading. Sea level remains at pure black only.
Diffstat (limited to 'src')
-rw-r--r-- | src/heightmap.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/heightmap.cpp b/src/heightmap.cpp index 97e525725..ec3125728 100644 --- a/src/heightmap.cpp +++ b/src/heightmap.cpp @@ -364,16 +364,16 @@ static void GrayscaleToMapHeights(uint img_width, uint img_height, byte *map) assert(img_row < img_height); assert(img_col < img_width); - /* The height in 1/256ths. */ uint heightmap_height = map[img_row * img_width + img_col]; - /* The height in 1/256ths of the maximum height. */ - heightmap_height *= (1 + _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, 256)) heightmap_height = 256; + if (heightmap_height > 0) { + /* 0 is sea level. + * Other grey scales are scaled evenly to the available height levels > 0. + * (The coastline is independent from the number of height levels) */ + heightmap_height = 1 + (heightmap_height - 1) * _settings_game.construction.max_heightlevel / 255; + } - SetTileHeight(tile, heightmap_height / 256); + SetTileHeight(tile, heightmap_height); } /* Only clear the tiles within the map area. */ if (IsInnerTile(tile)) { |