summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-02-21 02:34:53 +0000
committeryexo <yexo@openttd.org>2009-02-21 02:34:53 +0000
commit598d20eedcfb9ac05877b48171604e115d38a46c (patch)
treef078747297abae0d4c76406a0b8e0d6b37a2a9c5 /src
parent057ceec51c0080826d9c3f2e1cf914d307f734a8 (diff)
downloadopenttd-598d20eedcfb9ac05877b48171604e115d38a46c.tar.xz
(svn r15538) -Fix (r15334): The difficulty level wasn't set to custom when changing the amount of towns/industries from the newgame gui.
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_gui.cpp11
-rw-r--r--src/genworld_gui.cpp16
-rw-r--r--src/settings.cpp5
3 files changed, 13 insertions, 19 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 3b09f0220..5aae9938c 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -16,6 +16,7 @@
#include "../string_func.h"
#include "../textbuf_gui.h"
#include "../settings_type.h"
+#include "../settings_func.h"
#include "../network/network_content.h"
#include "ai.hpp"
@@ -485,15 +486,13 @@ struct AIConfigWindow : public Window {
case AIC_WIDGET_BACKGROUND: {
/* Check if the user clicked on one of the arrows to configure the number of AIs */
if (IsInsideBS(pt.x, 10, 20) && IsInsideBS(pt.y, 18, 10)) {
+ int new_value;
if (pt.x <= 20) {
- _settings_newgame.difficulty.max_no_competitors = max(0, _settings_newgame.difficulty.max_no_competitors - 1);
+ new_value = max(0, _settings_newgame.difficulty.max_no_competitors - 1);
} else {
- _settings_newgame.difficulty.max_no_competitors = min(MAX_COMPANIES - 1, _settings_newgame.difficulty.max_no_competitors + 1);
- }
- if (_settings_newgame.difficulty.diff_level != 3) {
- _settings_newgame.difficulty.diff_level = 3;
- ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
+ new_value = min(MAX_COMPANIES - 1, _settings_newgame.difficulty.max_no_competitors + 1);
}
+ IConsoleSetSetting("difficulty.max_no_competitors", new_value);
this->SetDirty();
}
break;
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 10d1b97df..525e625e9 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -571,15 +571,11 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
case GLAND_SMOOTHNESS_PULLDOWN: _settings_newgame.game_creation.tgen_smoothness = index; break;
case GLAND_TOWN_PULLDOWN:
- _settings_newgame.difficulty.number_towns = index;
- if (_settings_newgame.difficulty.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
- IConsoleSetSetting("difficulty.number_towns", _settings_newgame.difficulty.number_towns);
+ IConsoleSetSetting("difficulty.number_towns", index);
break;
case GLAND_INDUSTRY_PULLDOWN:
- _settings_newgame.difficulty.number_industries = index;
- if (_settings_newgame.difficulty.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
- IConsoleSetSetting("difficulty.number_industries", _settings_newgame.difficulty.number_industries);
+ IConsoleSetSetting("difficulty.number_industries", index);
break;
case GLAND_LANDSCAPE_PULLDOWN:
@@ -592,15 +588,11 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
break;
case GLAND_TERRAIN_PULLDOWN:
- _settings_newgame.difficulty.terrain_type = index;
- if (_settings_newgame.difficulty.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
- IConsoleSetSetting("difficulty.terrain_type", _settings_newgame.difficulty.terrain_type);
+ IConsoleSetSetting("difficulty.terrain_type", index);
break;
case GLAND_WATER_PULLDOWN:
- _settings_newgame.difficulty.quantity_sea_lakes = index;
- if (_settings_newgame.difficulty.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
- IConsoleSetSetting("difficulty.quantity_sea_lakes", _settings_newgame.difficulty.quantity_sea_lakes);
+ IConsoleSetSetting("difficulty.quantity_sea_lakes", index);
break;
}
this->SetDirty();
diff --git a/src/settings.cpp b/src/settings.cpp
index 0dc48cfc8..ecfc3403c 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1009,7 +1009,10 @@ static bool DifficultyReset(int32 level)
static bool DifficultyChange(int32)
{
if (_game_mode == GM_MENU) {
- _settings_newgame.difficulty.diff_level = 3;
+ if (_settings_newgame.difficulty.diff_level != 3) {
+ ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
+ _settings_newgame.difficulty.diff_level = 3;
+ }
} else {
_settings_game.difficulty.diff_level = 3;
}