mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
(svn r26932) -Codechange: replace some constants with less weird looking constants and simplify clamping by actually using Clamp
This commit is contained in:
parent
d5bb1d023f
commit
135b3f635d
11
src/tgp.cpp
11
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 ed; // coast distance from edge
|
||||||
int depth;
|
int depth;
|
||||||
|
|
||||||
height_t h_prev = 16;
|
height_t h_prev = I2H(1);
|
||||||
height_t h;
|
height_t h;
|
||||||
|
|
||||||
assert(IsValidXY(org_x, org_y));
|
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) */
|
/* 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++) {
|
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? */
|
/* Coast found? */
|
||||||
if (_height_map.height(x, y) > 15) break;
|
if (_height_map.height(x, y) >= I2H(1)) break;
|
||||||
|
|
||||||
/* Coast found in the neighborhood? */
|
/* Coast found in the neighborhood? */
|
||||||
if (IsValidXY(x + dir_y, y + dir_x) && _height_map.height(x + dir_y, y + dir_x) > 0) break;
|
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);
|
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 */
|
/* Transfer height map into OTTD map */
|
||||||
for (y = 0; y < _height_map.size_y; y++) {
|
for (y = 0; y < _height_map.size_y; y++) {
|
||||||
for (x = 0; x < _height_map.size_x; x++) {
|
for (x = 0; x < _height_map.size_x; x++) {
|
||||||
int height = H2I(_height_map.height(x, y));
|
TgenSetTileHeight(TileXY(x, y), Clamp(H2I(_height_map.height(x, y)), 0, max_height));
|
||||||
if (height < 0) height = 0;
|
|
||||||
if (height > 15) height = 15;
|
|
||||||
TgenSetTileHeight(TileXY(x, y), height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user