From 7ec3d9a0c66f82822fad924de7ab72a02e0521eb Mon Sep 17 00:00:00 2001 From: rubidium Date: Thu, 21 Jan 2010 23:19:50 +0000 Subject: (svn r18883) -Codechange: warn in the difficulty and AI configuration window when setting the number of AIs to non-zero when you don't have AIs --- src/lang/english.txt | 1 + src/settings.cpp | 6 ++++++ src/settings_gui.cpp | 6 ++++++ 3 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/lang/english.txt b/src/lang/english.txt index d172924f8..adb4f3008 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1065,6 +1065,7 @@ STR_CITY_APPROVAL_PERMISSIVE :Permissive STR_CITY_APPROVAL_TOLERANT :Tolerant STR_CITY_APPROVAL_HOSTILE :Hostile +STR_WARNING_NO_SUITABLE_AI :{WHITE}No suitable AIs available...{}You can download several AIs via the 'Online Content' system STR_WARNING_DIFFICULTY_TO_CUSTOM :{WHITE}This action changed the difficulty level to custom # Advanced settings window diff --git a/src/settings.cpp b/src/settings.cpp index 8a091816f..a136c3d75 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -58,6 +58,7 @@ #include "settings_func.h" #include "ini_type.h" #include "ai/ai_config.hpp" +#include "ai/ai.hpp" #include "newgrf.h" #include "ship.h" #include "company_base.h" @@ -851,6 +852,11 @@ static bool DifficultyChange(int32) _settings_game.difficulty.diff_level = 3; } + if (((_game_mode == GM_MENU) ? _settings_newgame.difficulty : _settings_game.difficulty).max_no_competitors != 0 && + AI::GetInfoList()->size() == 0 && (!_networking || _network_server)) { + ShowErrorMessage(STR_WARNING_NO_SUITABLE_AI, INVALID_STRING_ID, 0, 0, true); + } + /* If we are a network-client, update the difficult setting (if it is open). * Use this instead of just dirtying the window because we need to load in * the new difficulty settings */ diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 0d5955871..d9220798b 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -31,6 +31,7 @@ #include "company_func.h" #include "viewport_func.h" #include "core/geometry_func.hpp" +#include "ai/ai.hpp" #include #include "table/sprites.h" @@ -653,6 +654,11 @@ public: SetDifficultyLevel(3, &this->opt_mod_temp.difficulty); // set difficulty level to custom this->LowerWidget(GDW_LVL_CUSTOM); this->InvalidateData(); + + if (widget / 3 == 0 && this->opt_mod_temp.difficulty.max_no_competitors != 0 && + AI::GetInfoList()->size() == 0) { + ShowErrorMessage(STR_WARNING_NO_SUITABLE_AI, INVALID_STRING_ID, 0, 0, true); + } return; } -- cgit v1.2.3-70-g09d2