Mercurial > hg > openttd
changeset 19856:74b60883eeca draft
(svn r24789) -Add: Separate setting to control the default settings of newly added scripts and random AIs.
author | frosch <frosch@openttd.org> |
---|---|
date | Wed, 05 Dec 2012 19:36:04 +0000 |
parents | bc1a33f760f3 |
children | 7cc9b6e3bac1 |
files | src/ai/ai_config.cpp src/lang/english.txt src/saveload/afterload.cpp src/saveload/saveload.cpp src/script/script_info.cpp src/settings_gui.cpp src/settings_type.h src/table/gameopt_settings.ini src/table/settings.ini |
diffstat | 9 files changed, 33 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ai/ai_config.cpp +++ b/src/ai/ai_config.cpp @@ -82,7 +82,7 @@ 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;
--- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1409,6 +1409,12 @@ 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}
--- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -2755,6 +2755,11 @@ } } + 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();
--- 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
--- a/src/script/script_info.cpp +++ b/src/script/script_info.cpp @@ -293,7 +293,7 @@ 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;
--- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1845,6 +1845,7 @@ 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"),
--- a/src/settings_type.h +++ b/src/settings_type.h @@ -288,6 +288,7 @@ /** 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 };
--- a/src/table/gameopt_settings.ini +++ b/src/table/gameopt_settings.ini @@ -23,6 +23,7 @@ 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,
--- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -1298,6 +1298,21 @@ 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