(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)
This commit is contained in:
truelight 2007-07-23 19:30:36 +00:00
parent 33d78635ef
commit b0d618c66b
4 changed files with 18 additions and 9 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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,