mirror of https://github.com/OpenTTD/OpenTTD
(svn r21080) -Fix: Do not allow to use a custom water level with the original map generator.
parent
ab9279b5a0
commit
725cf7d8bb
|
@ -459,6 +459,13 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
|
||||||
this->SetWidgetDisabledState(GLAND_START_DATE_UP, _settings_newgame.game_creation.starting_year >= MAX_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 <= MIN_SNOWLINE_HEIGHT || _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->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP, _settings_newgame.game_creation.snow_line_height >= MAX_SNOWLINE_HEIGHT || _settings_newgame.game_creation.landscape != LT_ARCTIC);
|
||||||
|
|
||||||
|
/* Do not allow a custom sea level with the original land generator. */
|
||||||
|
if (_settings_newgame.game_creation.land_generator == 0 &&
|
||||||
|
_settings_newgame.difficulty.quantity_sea_lakes == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
|
||||||
|
_settings_newgame.difficulty.quantity_sea_lakes = CUSTOM_SEA_LEVEL_MIN_PERCENTAGE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||||
|
@ -658,9 +665,15 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
|
||||||
ShowDropDownMenu(this, _elevations, _settings_newgame.difficulty.terrain_type, GLAND_TERRAIN_PULLDOWN, 0, 0);
|
ShowDropDownMenu(this, _elevations, _settings_newgame.difficulty.terrain_type, GLAND_TERRAIN_PULLDOWN, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GLAND_WATER_PULLDOWN: // Water quantity
|
case GLAND_WATER_PULLDOWN: { // Water quantity
|
||||||
ShowDropDownMenu(this, _sea_lakes, _settings_newgame.difficulty.quantity_sea_lakes, GLAND_WATER_PULLDOWN, 0, 0);
|
uint32 hidden_mask = 0;
|
||||||
|
/* Disable custom water level when the original map generator is active. */
|
||||||
|
if (_settings_newgame.game_creation.land_generator == 0) {
|
||||||
|
SetBit(hidden_mask, CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY);
|
||||||
|
}
|
||||||
|
ShowDropDownMenu(this, _sea_lakes, _settings_newgame.difficulty.quantity_sea_lakes, GLAND_WATER_PULLDOWN, 0, hidden_mask);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case GLAND_SMOOTHNESS_PULLDOWN: // Map smoothness
|
case GLAND_SMOOTHNESS_PULLDOWN: // Map smoothness
|
||||||
ShowDropDownMenu(this, _smoothness, _settings_newgame.game_creation.tgen_smoothness, GLAND_SMOOTHNESS_PULLDOWN, 0, 0);
|
ShowDropDownMenu(this, _smoothness, _settings_newgame.game_creation.tgen_smoothness, GLAND_SMOOTHNESS_PULLDOWN, 0, 0);
|
||||||
|
|
|
@ -963,6 +963,7 @@ void GenerateLandscape(byte mode)
|
||||||
default: {
|
default: {
|
||||||
uint32 r = Random();
|
uint32 r = Random();
|
||||||
|
|
||||||
|
assert(_settings_game.difficulty.quantity_sea_lakes != CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY);
|
||||||
uint i = ScaleByMapSize(GB(r, 0, 7) + (3 - _settings_game.difficulty.quantity_sea_lakes) * 256 + 100);
|
uint i = ScaleByMapSize(GB(r, 0, 7) + (3 - _settings_game.difficulty.quantity_sea_lakes) * 256 + 100);
|
||||||
for (; i != 0; --i) {
|
for (; i != 0; --i) {
|
||||||
GenerateTerrain(_settings_game.difficulty.terrain_type, 0);
|
GenerateTerrain(_settings_game.difficulty.terrain_type, 0);
|
||||||
|
|
|
@ -902,6 +902,21 @@ static bool InvalidateIndustryViewWindow(int32 p1)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Checks if any settings are set to incorrect values, and sets them to correct values in that case. */
|
||||||
|
static void ValidateSettings()
|
||||||
|
{
|
||||||
|
/* Force the difficulty levels to correct values if they are invalid. */
|
||||||
|
if (_settings_newgame.difficulty.diff_level != 3) {
|
||||||
|
SetDifficultyLevel(_settings_newgame.difficulty.diff_level, &_settings_newgame.difficulty);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do not allow a custom sea level with the original land generator. */
|
||||||
|
if (_settings_newgame.game_creation.land_generator == 0 &&
|
||||||
|
_settings_newgame.difficulty.quantity_sea_lakes == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
|
||||||
|
_settings_newgame.difficulty.quantity_sea_lakes = CUSTOM_SEA_LEVEL_MIN_PERCENTAGE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A: competitors
|
* A: competitors
|
||||||
* B: competitor start time. Deprecated since savegame version 110.
|
* B: competitor start time. Deprecated since savegame version 110.
|
||||||
|
@ -941,17 +956,6 @@ void SetDifficultyLevel(int mode, DifficultySettings *gm_opt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks the difficulty levels read from the configuration and
|
|
||||||
* forces them to be correct when invalid.
|
|
||||||
*/
|
|
||||||
static void CheckDifficultyLevels()
|
|
||||||
{
|
|
||||||
if (_settings_newgame.difficulty.diff_level != 3) {
|
|
||||||
SetDifficultyLevel(_settings_newgame.difficulty.diff_level, &_settings_newgame.difficulty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool DifficultyReset(int32 level)
|
static bool DifficultyReset(int32 level)
|
||||||
{
|
{
|
||||||
SetDifficultyLevel(level, (_game_mode == GM_MENU) ? &_settings_newgame.difficulty : &_settings_game.difficulty);
|
SetDifficultyLevel(level, (_game_mode == GM_MENU) ? &_settings_newgame.difficulty : &_settings_game.difficulty);
|
||||||
|
@ -1477,7 +1481,7 @@ void LoadFromConfig()
|
||||||
IniLoadSettings(ini, _gameopt_settings, "gameopt", &_settings_newgame);
|
IniLoadSettings(ini, _gameopt_settings, "gameopt", &_settings_newgame);
|
||||||
HandleOldDiffCustom(false);
|
HandleOldDiffCustom(false);
|
||||||
|
|
||||||
CheckDifficultyLevels();
|
ValidateSettings();
|
||||||
delete ini;
|
delete ini;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue