summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-12-05 19:36:04 +0000
committerfrosch <frosch@openttd.org>2012-12-05 19:36:04 +0000
commit812ae4140a8566c2b4b43c6aa5bab5eecf82f18a (patch)
treeb79a9960ef438be736d9768a71336f8dd60f9416
parente43bf5dabdb4a62b4e6b6812db422b962b4eaaf1 (diff)
downloadopenttd-812ae4140a8566c2b4b43c6aa5bab5eecf82f18a.tar.xz
(svn r24789) -Add: Separate setting to control the default settings of newly added scripts and random AIs.
-rw-r--r--src/ai/ai_config.cpp2
-rw-r--r--src/lang/english.txt6
-rw-r--r--src/saveload/afterload.cpp5
-rw-r--r--src/saveload/saveload.cpp3
-rw-r--r--src/script/script_info.cpp2
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/settings_type.h1
-rw-r--r--src/table/gameopt_settings.ini1
-rw-r--r--src/table/settings.ini15
9 files changed, 33 insertions, 3 deletions
diff --git a/src/ai/ai_config.cpp b/src/ai/ai_config.cpp
index 7241eab0a..3b3c09a42 100644
--- a/src/ai/ai_config.cpp
+++ b/src/ai/ai_config.cpp
@@ -82,7 +82,7 @@ int AIConfig::GetSetting(const char *name) const
SettingValueList::const_iterator it = this->settings.find(name);
if (it == this->settings.end()) {
assert(strcmp("start_date", name) == 0);
- switch (GetGameSettings().difficulty.diff_level) {
+ switch (GetGameSettings().script.settings_profile) {
case SP_EASY: return AI::START_NEXT_EASY;
case SP_MEDIUM: return AI::START_NEXT_MEDIUM;
case SP_HARD: return AI::START_NEXT_HARD;
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 33564eebb..4a36b3b8c 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1409,6 +1409,12 @@ STR_CONFIG_SETTING_AI_BUILDS_AIRCRAFT_HELPTEXT :Enabling this s
STR_CONFIG_SETTING_AI_BUILDS_SHIPS :Disable ships for computer: {STRING2}
STR_CONFIG_SETTING_AI_BUILDS_SHIPS_HELPTEXT :Enabling this setting makes building ships impossible for a computer player
+STR_CONFIG_SETTING_AI_PROFILE :Default settings profile: {STRING2}
+STR_CONFIG_SETTING_AI_PROFILE_HELPTEXT :Choose which settings profile to use for random AIs or for initial values when adding a new AI or Game Script
+STR_CONFIG_SETTING_AI_PROFILE_EASY :Easy
+STR_CONFIG_SETTING_AI_PROFILE_MEDIUM :Medium
+STR_CONFIG_SETTING_AI_PROFILE_HARD :Hard
+
STR_CONFIG_SETTING_AI_IN_MULTIPLAYER :Allow AIs in multiplayer: {STRING2}
STR_CONFIG_SETTING_AI_IN_MULTIPLAYER_HELPTEXT :Allow AI computer players to participate in multiplayer games
STR_CONFIG_SETTING_SCRIPT_MAX_OPCODES :#opcodes before scripts are suspended: {STRING2}
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 5d02ed1d1..5937318aa 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -2755,6 +2755,11 @@ bool AfterLoadGame()
}
}
+ if (IsSavegameVersionBefore(178)) {
+ /* Initialise script settings profile */
+ _settings_game.script.settings_profile = IsInsideMM(_settings_game.difficulty.diff_level, SP_BEGIN, SP_END) ? _settings_game.difficulty.diff_level : (uint)SP_MEDIUM;
+ }
+
/* Road stops is 'only' updating some caches */
AfterLoadRoadStops();
AfterLoadLabelMaps();
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 1e64c83f5..7d74798bd 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -241,8 +241,9 @@
* 175 24136
* 176 24446
* 177 24619
+ * 178 TODO
*/
-extern const uint16 SAVEGAME_VERSION = 177; ///< Current savegame version of OpenTTD.
+extern const uint16 SAVEGAME_VERSION = 178; ///< Current savegame version of OpenTTD.
SavegameType _savegame_type; ///< type of savegame we are loading
diff --git a/src/script/script_info.cpp b/src/script/script_info.cpp
index 94c977225..a1db9e13e 100644
--- a/src/script/script_info.cpp
+++ b/src/script/script_info.cpp
@@ -293,7 +293,7 @@ int ScriptInfo::GetSettingDefaultValue(const char *name) const
for (ScriptConfigItemList::const_iterator it = this->config_list.begin(); it != this->config_list.end(); it++) {
if (strcmp((*it).name, name) != 0) continue;
/* The default value depends on the difficulty level */
- switch (GetGameSettings().difficulty.diff_level) {
+ switch (GetGameSettings().script.settings_profile) {
case SP_EASY: return (*it).easy_value;
case SP_MEDIUM: return (*it).medium_value;
case SP_HARD: return (*it).hard_value;
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index ee21d8d28..938106b68 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1845,6 +1845,7 @@ static SettingEntry _settings_economy[] = {
static SettingsPage _settings_economy_page = {_settings_economy, lengthof(_settings_economy)};
static SettingEntry _settings_ai_npc[] = {
+ SettingEntry("script.settings_profile"),
SettingEntry("ai.ai_in_multiplayer"),
SettingEntry("ai.ai_disable_veh_train"),
SettingEntry("ai.ai_disable_veh_roadveh"),
diff --git a/src/settings_type.h b/src/settings_type.h
index 00bb56654..934e44733 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -288,6 +288,7 @@ struct AISettings {
/** Settings related to scripts. */
struct ScriptSettings {
+ uint8 settings_profile; ///< difficulty profile to set initial settings of scripts, esp. random AIs
uint32 script_max_opcode_till_suspend; ///< max opcode calls till scripts will suspend
};
diff --git a/src/table/gameopt_settings.ini b/src/table/gameopt_settings.ini
index 71bc68502..10373c965 100644
--- a/src/table/gameopt_settings.ini
+++ b/src/table/gameopt_settings.ini
@@ -23,6 +23,7 @@ static const char *_savegame_date = "long|short|iso";
static const char *_server_langs = "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN|AFRIKAANS|CROATIAN|CATALAN|ESTONIAN|GALICIAN|GREEK|LATVIAN";
#endif /* ENABLE_NETWORK */
static const char *_osk_activation = "disabled|double|single|immediately";
+static const char *_settings_profiles = "easy|medium|hard";
static const SettingDesc _gameopt_settings[] = {
/* In version 4 a new difficulty setting has been added to the difficulty settings,
diff --git a/src/table/settings.ini b/src/table/settings.ini
index a9caf1caa..fa1ab0754 100644
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -1298,6 +1298,21 @@ cat = SC_EXPERT
length = 1
to = 106
+[SDT_OMANY]
+base = GameSettings
+var = script.settings_profile
+type = SLE_UINT8
+from = 178
+guiflags = SGF_MULTISTRING
+def = SP_EASY
+min = SP_EASY
+max = SP_HARD
+full = _settings_profiles
+str = STR_CONFIG_SETTING_AI_PROFILE
+strhelp = STR_CONFIG_SETTING_AI_PROFILE_HELPTEXT
+strval = STR_CONFIG_SETTING_AI_PROFILE_EASY
+cat = SC_BASIC
+
[SDT_BOOL]
base = GameSettings
var = ai.ai_in_multiplayer