diff options
-rw-r--r-- | src/clear_cmd.cpp | 2 | ||||
-rw-r--r-- | src/genworld_gui.cpp | 12 | ||||
-rw-r--r-- | src/smallmap_gui.cpp | 7 | ||||
-rw-r--r-- | src/tile.h | 6 |
4 files changed, 18 insertions, 9 deletions
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index 7b95d085a..ed04ac8e8 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -179,7 +179,7 @@ static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height _error_message = STR_1004_TOO_HIGH; - if (height > 15) return false; + if (height > MAX_TILE_HEIGHT) return false; nh = TerraformGetHeightOfTile(ts, tile); if (nh < 0 || height == nh) return false; diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index bd1f305d2..9763967dc 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -255,7 +255,7 @@ static void GenerateLandscapeWndProc(Window *w, WindowEvent *e) SetWindowWidgetDisabledState(w, GLAND_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR); SetWindowWidgetDisabledState(w, GLAND_START_DATE_UP, _patches_newgame.starting_year >= MAX_YEAR); SetWindowWidgetDisabledState(w, GLAND_SNOW_LEVEL_DOWN, _patches_newgame.snow_line_height <= 2 || _opt_newgame.landscape != LT_ARCTIC); - SetWindowWidgetDisabledState(w, GLAND_SNOW_LEVEL_UP, _patches_newgame.snow_line_height >= 13 || _opt_newgame.landscape != LT_ARCTIC); + SetWindowWidgetDisabledState(w, GLAND_SNOW_LEVEL_UP, _patches_newgame.snow_line_height >= MAX_SNOWLINE_HEIGHT || _opt_newgame.landscape != LT_ARCTIC); SetWindowWidgetLoweredState(w, GLAND_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE); SetWindowWidgetLoweredState(w, GLAND_ARCTIC, _opt_newgame.landscape == LT_ARCTIC); @@ -402,7 +402,7 @@ static void GenerateLandscapeWndProc(Window *w, WindowEvent *e) HandleButtonClick(w, e->we.click.widget); SetWindowDirty(w); - _patches_newgame.snow_line_height = clamp(_patches_newgame.snow_line_height + e->we.click.widget - GLAND_SNOW_LEVEL_TEXT, 2, 13); + _patches_newgame.snow_line_height = clamp(_patches_newgame.snow_line_height + e->we.click.widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT); } _left_button_clicked = false; break; @@ -498,7 +498,7 @@ static void GenerateLandscapeWndProc(Window *w, WindowEvent *e) break; case GLAND_SNOW_LEVEL_TEXT: InvalidateWidget(w, GLAND_SNOW_LEVEL_TEXT); - _patches_newgame.snow_line_height = clamp(value, 2, 13); + _patches_newgame.snow_line_height = clamp(value, 2, MAX_SNOWLINE_HEIGHT); break; } @@ -611,7 +611,7 @@ static void CreateScenarioWndProc(Window *w, WindowEvent *e) SetWindowWidgetDisabledState(w, CSCEN_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR); SetWindowWidgetDisabledState(w, CSCEN_START_DATE_UP, _patches_newgame.starting_year >= MAX_YEAR); SetWindowWidgetDisabledState(w, CSCEN_FLAT_LAND_HEIGHT_DOWN, _patches_newgame.se_flat_world_height <= 0); - SetWindowWidgetDisabledState(w, CSCEN_FLAT_LAND_HEIGHT_UP, _patches_newgame.se_flat_world_height >= 15); + SetWindowWidgetDisabledState(w, CSCEN_FLAT_LAND_HEIGHT_UP, _patches_newgame.se_flat_world_height >= MAX_TILE_HEIGHT); SetWindowWidgetLoweredState(w, CSCEN_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE); SetWindowWidgetLoweredState(w, CSCEN_ARCTIC, _opt_newgame.landscape == LT_ARCTIC); @@ -672,7 +672,7 @@ static void CreateScenarioWndProc(Window *w, WindowEvent *e) HandleButtonClick(w, e->we.click.widget); SetWindowDirty(w); - _patches_newgame.se_flat_world_height = clamp(_patches_newgame.se_flat_world_height + e->we.click.widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, 15); + _patches_newgame.se_flat_world_height = clamp(_patches_newgame.se_flat_world_height + e->we.click.widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT); } _left_button_clicked = false; break; @@ -703,7 +703,7 @@ static void CreateScenarioWndProc(Window *w, WindowEvent *e) break; case CSCEN_FLAT_LAND_HEIGHT_TEXT: InvalidateWidget(w, CSCEN_FLAT_LAND_HEIGHT_TEXT); - _patches_newgame.se_flat_world_height = clamp(value, 0, 15); + _patches_newgame.se_flat_world_height = clamp(value, 0, MAX_TILE_HEIGHT); break; } diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 12ebeeba0..3a80677c0 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -193,8 +193,10 @@ static inline void WRITE_PIXELS_OR(void *d, uint32 val) #define MKCOLOR(x) TO_LE32X(x) -/* Height encodings; 16 levels XXX - needs updating for more/finer heights! */ -static const uint32 _map_height_bits[16] = { +/** + * Height encodings; MAX_TILE_HEIGHT + 1 levels, from 0 to MAX_TILE_HEIGHT + */ +static const uint32 _map_height_bits[] = { MKCOLOR(0x5A5A5A5A), MKCOLOR(0x5A5B5A5B), MKCOLOR(0x5B5B5B5B), @@ -212,6 +214,7 @@ static const uint32 _map_height_bits[16] = { MKCOLOR(0x27272727), MKCOLOR(0x27272727), }; +assert_compile(lengthof(_map_height_bits) == MAX_TILE_HEIGHT + 1); struct AndOr { uint32 mor; diff --git a/src/tile.h b/src/tile.h index d7f747b45..4d6e48ce5 100644 --- a/src/tile.h +++ b/src/tile.h @@ -10,6 +10,12 @@ #include "map.h" #include "slope.h" +/** Maximum allowed tile height */ +#define MAX_TILE_HEIGHT 15 + +/** Maximum allowed snowline height */ +#define MAX_SNOWLINE_HEIGHT (MAX_TILE_HEIGHT - 2) + enum TileType { MP_CLEAR, MP_RAILWAY, |