summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-12-21 16:13:30 +0000
committerrubidium <rubidium@openttd.org>2009-12-21 16:13:30 +0000
commitabb601f682775de2f0670482f0b4b773300c9949 (patch)
treeecebbb1001c8171c92e35634800c8fc47464549b
parentb3ecc90992d2d74b6be77ba084e21671b7ba9163 (diff)
downloadopenttd-abb601f682775de2f0670482f0b4b773300c9949.tar.xz
(svn r18585) -Codechange: replace some magic numbers by constants
-rw-r--r--src/date_type.h3
-rw-r--r--src/genworld_gui.cpp6
-rw-r--r--src/table/settings.h8
-rw-r--r--src/tile_type.h2
4 files changed, 12 insertions, 7 deletions
diff --git a/src/date_type.h b/src/date_type.h
index 5afc925e4..e0481ff49 100644
--- a/src/date_type.h
+++ b/src/date_type.h
@@ -68,6 +68,9 @@ enum {
/** The absolute minimum & maximum years in OTTD */
#define MIN_YEAR 0
+/** The default starting year */
+#define DEF_START_YEAR 1950
+
/**
* MAX_YEAR, nicely rounded value of the number of years that can
* be encoded in a single 32 bits date, about 2^31 / 366 years.
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 1a2f12a4d..adb59522f 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -499,7 +499,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
this->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
this->SetWidgetDisabledState(GLAND_START_DATE_UP, _settings_newgame.game_creation.starting_year >= MAX_YEAR);
- this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _settings_newgame.game_creation.snow_line_height <= 2 || _settings_newgame.game_creation.landscape != LT_ARCTIC);
+ this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _settings_newgame.game_creation.snow_line_height <= MIN_SNOWLINE_HEIGHT || _settings_newgame.game_creation.landscape != LT_ARCTIC);
this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP, _settings_newgame.game_creation.snow_line_height >= MAX_SNOWLINE_HEIGHT || _settings_newgame.game_creation.landscape != LT_ARCTIC);
this->SetWidgetLoweredState(GLAND_TEMPERATE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
@@ -589,7 +589,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
this->HandleButtonClick(widget);
this->SetDirty();
- _settings_newgame.game_creation.snow_line_height = Clamp(_settings_newgame.game_creation.snow_line_height + widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT);
+ _settings_newgame.game_creation.snow_line_height = Clamp(_settings_newgame.game_creation.snow_line_height + widget - GLAND_SNOW_LEVEL_TEXT, MIN_SNOWLINE_HEIGHT, MAX_SNOWLINE_HEIGHT);
}
_left_button_clicked = false;
break;
@@ -743,7 +743,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
case GLAND_SNOW_LEVEL_TEXT:
this->SetWidgetDirty(GLAND_SNOW_LEVEL_TEXT);
- _settings_newgame.game_creation.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT);
+ _settings_newgame.game_creation.snow_line_height = Clamp(value, MIN_SNOWLINE_HEIGHT, MAX_SNOWLINE_HEIGHT);
break;
case GLAND_TOWN_PULLDOWN:
diff --git a/src/table/settings.h b/src/table/settings.h
index 96dd8c8d7..11a097d38 100644
--- a/src/table/settings.h
+++ b/src/table/settings.h
@@ -314,7 +314,7 @@ static const SettingDesc _gameopt_settings[] = {
/* There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow these bigger values (21-255). Invalid values will fallback to english on use and (undefined string) in GUI. */
SDT_OMANY(GameSettings, game_creation.town_name, SLE_UINT8, 0, 0, 0, 255, _town_names, STR_NULL, NULL, NULL),
SDT_OMANY(GameSettings, game_creation.landscape, SLE_UINT8, 0, 0, 0, 3, _climates, STR_NULL, NULL, ConvertLandscape),
- SDT_VAR(GameSettings, game_creation.snow_line, SLE_UINT8, 0, 0, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
+ SDT_VAR(GameSettings, game_creation.snow_line, SLE_UINT8, 0, 0, DEF_SNOWLINE_HEIGHT * TILE_HEIGHT, MIN_SNOWLINE_HEIGHT * TILE_HEIGHT, DEF_SNOWLINE_HEIGHT * TILE_HEIGHT, 0, STR_NULL, NULL),
SDT_CONDNULL( 1, 0, 22),
SDTC_CONDOMANY( gui.autosave, SLE_UINT8, 23, SL_MAX_VERSION, S, 0, 1, 4, _autosave_interval, STR_NULL, NULL),
SDT_OMANY(GameSettings, vehicle.road_side, SLE_UINT8, 0, 0, 1, 1, _roadsides, STR_NULL, NULL, NULL),
@@ -357,7 +357,7 @@ const SettingDesc _settings[] = {
/* There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow these bigger values (21-255). Invalid values will fallback to english on use and (undefined string) in GUI. */
SDT_CONDOMANY(GameSettings, game_creation.town_name, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 0, 255, _town_names, STR_NULL, NULL, NULL),
SDT_CONDOMANY(GameSettings, game_creation.landscape, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 0, 3, _climates, STR_NULL, NULL, ConvertLandscape),
- SDT_CONDVAR(GameSettings, game_creation.snow_line, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
+ SDT_CONDVAR(GameSettings, game_creation.snow_line, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, DEF_SNOWLINE_HEIGHT * TILE_HEIGHT, MIN_SNOWLINE_HEIGHT * TILE_HEIGHT, DEF_SNOWLINE_HEIGHT * TILE_HEIGHT, 0, STR_NULL, NULL),
SDT_CONDOMANY(GameSettings, vehicle.road_side, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 1, 1, _roadsides, STR_NULL, CheckRoadSide, NULL),
SDT_BOOL(GameSettings, construction.build_on_slopes, 0,NN, true, STR_CONFIG_SETTING_BUILDONSLOPES, NULL),
@@ -426,9 +426,9 @@ const SettingDesc _settings[] = {
SDT_BOOL(GameSettings, economy.bribe, 0, 0, true, STR_CONFIG_SETTING_BRIBE, NULL),
SDT_CONDBOOL(GameSettings, economy.exclusive_rights, 79, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_SETTING_ALLOW_EXCLUSIVE, NULL),
SDT_CONDBOOL(GameSettings, economy.give_money, 79, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_SETTING_ALLOW_GIVE_MONEY, NULL),
- SDT_VAR(GameSettings, game_creation.snow_line_height, SLE_UINT8, 0, 0, 7, 2, 13, 0, STR_CONFIG_SETTING_SNOWLINE_HEIGHT, NULL),
+ SDT_VAR(GameSettings, game_creation.snow_line_height, SLE_UINT8, 0, 0, DEF_SNOWLINE_HEIGHT, MIN_SNOWLINE_HEIGHT, DEF_SNOWLINE_HEIGHT, 0, STR_CONFIG_SETTING_SNOWLINE_HEIGHT, NULL),
SDTC_VAR( gui.coloured_news_year, SLE_INT32, 0,NC, 2000,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_SETTING_COLOURED_NEWS_YEAR, NULL),
- SDT_VAR(GameSettings, game_creation.starting_year, SLE_INT32, 0,NC, 1950,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_SETTING_STARTING_YEAR, NULL),
+ SDT_VAR(GameSettings, game_creation.starting_year, SLE_INT32, 0,NC,DEF_START_YEAR,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_SETTING_STARTING_YEAR, NULL),
SDT_CONDNULL( 4, 0, 104),
SDT_BOOL(GameSettings, economy.smooth_economy, 0, 0, true, STR_CONFIG_SETTING_SMOOTH_ECONOMY, NULL),
SDT_BOOL(GameSettings, economy.allow_shares, 0, 0, false, STR_CONFIG_SETTING_ALLOW_SHARES, NULL),
diff --git a/src/tile_type.h b/src/tile_type.h
index 4083dfd67..bd1d62dab 100644
--- a/src/tile_type.h
+++ b/src/tile_type.h
@@ -21,6 +21,8 @@ enum {
TILE_HEIGHT = 8, ///< The standard height-difference between tiles on two levels is 8 (z-diff 8)
MAX_TILE_HEIGHT = 15, ///< Maximum allowed tile height
+ MIN_SNOWLINE_HEIGHT = 2, ///< Minimum snowline height
+ DEF_SNOWLINE_HEIGHT = 7, ///< Default snowline height
MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2), ///< Maximum allowed snowline height
};