Mercurial > hg > openttd
changeset 7313:06f0315f7746 draft
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
-Codechange: replace magic 13 with MAX_SNOWLINE_HEIGHT (bilbo)
-Codechange: assure _map_height_bits is always of correct size (Rubidium)
author | truelight <truelight@openttd.org> |
---|---|
date | Mon, 23 Jul 2007 19:30:36 +0000 |
parents | d985b39f0757 |
children | 1b710e837d59 |
files | src/clear_cmd.cpp src/genworld_gui.cpp src/smallmap_gui.cpp src/tile.h |
diffstat | 4 files changed, 18 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -179,7 +179,7 @@ _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;
--- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -255,7 +255,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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; }
--- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -193,8 +193,10 @@ #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 @@ MKCOLOR(0x27272727), MKCOLOR(0x27272727), }; +assert_compile(lengthof(_map_height_bits) == MAX_TILE_HEIGHT + 1); struct AndOr { uint32 mor;