mirror of https://github.com/OpenTTD/OpenTTD
(svn r24789) -Add: Separate setting to control the default settings of newly added scripts and random AIs.
parent
e43bf5dabd
commit
812ae4140a
|
@ -82,7 +82,7 @@ int AIConfig::GetSetting(const char *name) const
|
||||||
SettingValueList::const_iterator it = this->settings.find(name);
|
SettingValueList::const_iterator it = this->settings.find(name);
|
||||||
if (it == this->settings.end()) {
|
if (it == this->settings.end()) {
|
||||||
assert(strcmp("start_date", name) == 0);
|
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_EASY: return AI::START_NEXT_EASY;
|
||||||
case SP_MEDIUM: return AI::START_NEXT_MEDIUM;
|
case SP_MEDIUM: return AI::START_NEXT_MEDIUM;
|
||||||
case SP_HARD: return AI::START_NEXT_HARD;
|
case SP_HARD: return AI::START_NEXT_HARD;
|
||||||
|
|
|
@ -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 :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_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 :Allow AIs in multiplayer: {STRING2}
|
||||||
STR_CONFIG_SETTING_AI_IN_MULTIPLAYER_HELPTEXT :Allow AI computer players to participate in multiplayer games
|
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}
|
STR_CONFIG_SETTING_SCRIPT_MAX_OPCODES :#opcodes before scripts are suspended: {STRING2}
|
||||||
|
|
|
@ -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 */
|
/* Road stops is 'only' updating some caches */
|
||||||
AfterLoadRoadStops();
|
AfterLoadRoadStops();
|
||||||
AfterLoadLabelMaps();
|
AfterLoadLabelMaps();
|
||||||
|
|
|
@ -241,8 +241,9 @@
|
||||||
* 175 24136
|
* 175 24136
|
||||||
* 176 24446
|
* 176 24446
|
||||||
* 177 24619
|
* 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
|
SavegameType _savegame_type; ///< type of savegame we are loading
|
||||||
|
|
||||||
|
|
|
@ -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++) {
|
for (ScriptConfigItemList::const_iterator it = this->config_list.begin(); it != this->config_list.end(); it++) {
|
||||||
if (strcmp((*it).name, name) != 0) continue;
|
if (strcmp((*it).name, name) != 0) continue;
|
||||||
/* The default value depends on the difficulty level */
|
/* 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_EASY: return (*it).easy_value;
|
||||||
case SP_MEDIUM: return (*it).medium_value;
|
case SP_MEDIUM: return (*it).medium_value;
|
||||||
case SP_HARD: return (*it).hard_value;
|
case SP_HARD: return (*it).hard_value;
|
||||||
|
|
|
@ -1845,6 +1845,7 @@ static SettingEntry _settings_economy[] = {
|
||||||
static SettingsPage _settings_economy_page = {_settings_economy, lengthof(_settings_economy)};
|
static SettingsPage _settings_economy_page = {_settings_economy, lengthof(_settings_economy)};
|
||||||
|
|
||||||
static SettingEntry _settings_ai_npc[] = {
|
static SettingEntry _settings_ai_npc[] = {
|
||||||
|
SettingEntry("script.settings_profile"),
|
||||||
SettingEntry("ai.ai_in_multiplayer"),
|
SettingEntry("ai.ai_in_multiplayer"),
|
||||||
SettingEntry("ai.ai_disable_veh_train"),
|
SettingEntry("ai.ai_disable_veh_train"),
|
||||||
SettingEntry("ai.ai_disable_veh_roadveh"),
|
SettingEntry("ai.ai_disable_veh_roadveh"),
|
||||||
|
|
|
@ -288,6 +288,7 @@ struct AISettings {
|
||||||
|
|
||||||
/** Settings related to scripts. */
|
/** Settings related to scripts. */
|
||||||
struct ScriptSettings {
|
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
|
uint32 script_max_opcode_till_suspend; ///< max opcode calls till scripts will suspend
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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";
|
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 */
|
#endif /* ENABLE_NETWORK */
|
||||||
static const char *_osk_activation = "disabled|double|single|immediately";
|
static const char *_osk_activation = "disabled|double|single|immediately";
|
||||||
|
static const char *_settings_profiles = "easy|medium|hard";
|
||||||
|
|
||||||
static const SettingDesc _gameopt_settings[] = {
|
static const SettingDesc _gameopt_settings[] = {
|
||||||
/* In version 4 a new difficulty setting has been added to the difficulty settings,
|
/* In version 4 a new difficulty setting has been added to the difficulty settings,
|
||||||
|
|
|
@ -1298,6 +1298,21 @@ cat = SC_EXPERT
|
||||||
length = 1
|
length = 1
|
||||||
to = 106
|
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]
|
[SDT_BOOL]
|
||||||
base = GameSettings
|
base = GameSettings
|
||||||
var = ai.ai_in_multiplayer
|
var = ai.ai_in_multiplayer
|
||||||
|
|
Loading…
Reference in New Issue