diff options
author | rubidium <rubidium@openttd.org> | 2014-09-27 20:39:32 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2014-09-27 20:39:32 +0000 |
commit | 135b3f635dbc8d5e9bd52fb35751adf9f0017649 (patch) | |
tree | 200c50db0717d1b0048f3e5c59adcfd01dfc9616 | |
parent | d5bb1d023fb6872a6dabcb398071e090c631993a (diff) | |
download | openttd-135b3f635dbc8d5e9bd52fb35751adf9f0017649.tar.xz |
(svn r26932) -Codechange: replace some constants with less weird looking constants and simplify clamping by actually using Clamp
-rw-r--r-- | src/tgp.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/tgp.cpp b/src/tgp.cpp index 77cf282da..87b3eb9e0 100644 --- a/src/tgp.cpp +++ b/src/tgp.cpp @@ -773,7 +773,7 @@ static void HeightMapSmoothCoastInDirection(int org_x, int org_y, int dir_x, int int ed; // coast distance from edge int depth; - height_t h_prev = 16; + height_t h_prev = I2H(1); height_t h; assert(IsValidXY(org_x, org_y)); @@ -781,7 +781,7 @@ static void HeightMapSmoothCoastInDirection(int org_x, int org_y, int dir_x, int /* Search for the coast (first non-water tile) */ for (x = org_x, y = org_y, ed = 0; IsValidXY(x, y) && ed < max_coast_dist_from_edge; x += dir_x, y += dir_y, ed++) { /* Coast found? */ - if (_height_map.height(x, y) > 15) break; + if (_height_map.height(x, y) >= I2H(1)) break; /* Coast found in the neighborhood? */ if (IsValidXY(x + dir_y, y + dir_x) && _height_map.height(x + dir_y, y + dir_x) > 0) break; @@ -986,13 +986,12 @@ void GenerateTerrainPerlin() for (x = 0; x < _height_map.size_x; x++) MakeVoid(x); } + int max_height = _settings_game.construction.max_heightlevel; + /* Transfer height map into OTTD map */ for (y = 0; y < _height_map.size_y; y++) { for (x = 0; x < _height_map.size_x; x++) { - int height = H2I(_height_map.height(x, y)); - if (height < 0) height = 0; - if (height > 15) height = 15; - TgenSetTileHeight(TileXY(x, y), height); + TgenSetTileHeight(TileXY(x, y), Clamp(H2I(_height_map.height(x, y)), 0, max_height)); } } |