From 9dde1287aa5bbcb0dfdcba17f0e8ba2d7db67881 Mon Sep 17 00:00:00 2001 From: truebrain Date: Thu, 1 Dec 2011 12:04:22 +0000 Subject: (svn r23387) -Fix: move ai.script_max_opcode_till_suspend to script.script_max_opcode_till_suspend --- src/lang/english.txt | 3 ++- src/script/script_instance.cpp | 6 +++--- src/settings_gui.cpp | 8 +++++++- src/settings_type.h | 7 ++++++- src/table/settings.ini | 4 ++-- 5 files changed, 20 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/lang/english.txt b/src/lang/english.txt index 28699feeb..4a8a137b1 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1264,7 +1264,7 @@ STR_CONFIG_SETTING_AI_BUILDS_AIRCRAFT :{LTBLUE}Disable STR_CONFIG_SETTING_AI_BUILDS_SHIPS :{LTBLUE}Disable ships for computer: {ORANGE}{STRING1} STR_CONFIG_SETTING_AI_IN_MULTIPLAYER :{LTBLUE}Allow AIs in multiplayer: {ORANGE}{STRING1} -STR_CONFIG_SETTING_AI_MAX_OPCODES :{LTBLUE}#opcodes before AI is suspended: {ORANGE}{STRING1} +STR_CONFIG_SETTING_SCRIPT_MAX_OPCODES :{LTBLUE}#opcodes before scripts are suspended: {ORANGE}{STRING1} STR_CONFIG_SETTING_SERVINT_ISPERCENT :{LTBLUE}Service intervals are in percents: {ORANGE}{STRING1} STR_CONFIG_SETTING_SERVINT_TRAINS :{LTBLUE}Default service interval for trains: {ORANGE}{STRING1} day{P 0:1 "" s}/% @@ -1357,6 +1357,7 @@ STR_CONFIG_SETTING_VEHICLES_ROUTING :{ORANGE}Routing STR_CONFIG_SETTING_VEHICLES_TRAINS :{ORANGE}Trains STR_CONFIG_SETTING_ECONOMY_TOWNS :{ORANGE}Towns STR_CONFIG_SETTING_ECONOMY_INDUSTRIES :{ORANGE}Industries +STR_CONFIG_SETTING_ECONOMY_SCRIPTS :{ORANGE}Scripts STR_CONFIG_SETTING_PATHFINDER_OPF :Original STR_CONFIG_SETTING_PATHFINDER_NPF :NPF diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index 8e812b82e..4fabdf2fb 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -187,7 +187,7 @@ void ScriptInstance::GameLoop() } ScriptObject::SetAllowDoCommand(true); /* Start the script by calling Start() */ - if (!this->engine->CallMethod(*this->instance, "Start", _settings_game.ai.ai_max_opcode_till_suspend) || !this->engine->IsSuspended()) this->Died(); + if (!this->engine->CallMethod(*this->instance, "Start", _settings_game.script.script_max_opcode_till_suspend) || !this->engine->IsSuspended()) this->Died(); } catch (Script_Suspend e) { this->suspend = e.GetSuspendTime(); this->callback = e.GetSuspendCallback(); @@ -208,7 +208,7 @@ void ScriptInstance::GameLoop() /* Continue the VM */ try { - if (!this->engine->Resume(_settings_game.ai.ai_max_opcode_till_suspend)) this->Died(); + if (!this->engine->Resume(_settings_game.script.script_max_opcode_till_suspend)) this->Died(); } catch (Script_Suspend e) { this->suspend = e.GetSuspendTime(); this->callback = e.GetSuspendCallback(); @@ -497,7 +497,7 @@ void ScriptInstance::Save() void ScriptInstance::Suspend() { HSQUIRRELVM vm = this->engine->GetVM(); - Squirrel::DecreaseOps(vm, _settings_game.ai.ai_max_opcode_till_suspend); + Squirrel::DecreaseOps(vm, _settings_game.script.script_max_opcode_till_suspend); } /* static */ bool ScriptInstance::LoadObjects(HSQUIRRELVM vm) diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 47225e2a2..c11e22093 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1479,9 +1479,16 @@ static SettingEntry _settings_economy_industries[] = { /** Industries sub-page */ static SettingsPage _settings_economy_industries_page = {_settings_economy_industries, lengthof(_settings_economy_industries)}; +static SettingEntry _settings_economy_scripts[] = { + SettingEntry("script.script_max_opcode_till_suspend"), +}; +/** Scripts sub-page */ +static SettingsPage _settings_economy_scripts_page = {_settings_economy_scripts, lengthof(_settings_economy_scripts)}; + static SettingEntry _settings_economy[] = { SettingEntry(&_settings_economy_towns_page, STR_CONFIG_SETTING_ECONOMY_TOWNS), SettingEntry(&_settings_economy_industries_page, STR_CONFIG_SETTING_ECONOMY_INDUSTRIES), + SettingEntry(&_settings_economy_scripts_page, STR_CONFIG_SETTING_ECONOMY_SCRIPTS), SettingEntry("economy.inflation"), SettingEntry("economy.smooth_economy"), SettingEntry("economy.feeder_payment_share"), @@ -1495,7 +1502,6 @@ static SettingEntry _settings_ai_npc[] = { SettingEntry("ai.ai_disable_veh_roadveh"), SettingEntry("ai.ai_disable_veh_aircraft"), SettingEntry("ai.ai_disable_veh_ship"), - SettingEntry("ai.ai_max_opcode_till_suspend"), }; /** Computer players sub-page */ static SettingsPage _settings_ai_npc_page = {_settings_ai_npc, lengthof(_settings_ai_npc)}; diff --git a/src/settings_type.h b/src/settings_type.h index d23011eb7..b1d622844 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -257,7 +257,11 @@ struct AISettings { bool ai_disable_veh_roadveh; ///< disable types for AI bool ai_disable_veh_aircraft; ///< disable types for AI bool ai_disable_veh_ship; ///< disable types for AI - uint32 ai_max_opcode_till_suspend; ///< max opcode calls till AI will suspend +}; + +/** Settings related to scripts. */ +struct ScriptSettings { + uint32 script_max_opcode_till_suspend; ///< max opcode calls till scripts will suspend }; /** Settings related to the old pathfinder. */ @@ -447,6 +451,7 @@ struct GameSettings { GameCreationSettings game_creation; ///< settings used during the creation of a game (map) ConstructionSettings construction; ///< construction of things in-game AISettings ai; ///< what may the AI do? + ScriptSettings script; ///< settings for scripts class AIConfig *ai_config[MAX_COMPANIES]; ///< settings per company PathfinderSettings pf; ///< settings for all pathfinders OrderSettings order; ///< settings related to orders diff --git a/src/table/settings.ini b/src/table/settings.ini index 0e37e7c5b..48dc333bb 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -1160,7 +1160,7 @@ str = STR_CONFIG_SETTING_AI_BUILDS_SHIPS [SDT_VAR] base = GameSettings -var = ai.ai_max_opcode_till_suspend +var = script.script_max_opcode_till_suspend type = SLE_UINT32 from = 107 guiflags = SGF_NEWGAME_ONLY @@ -1168,7 +1168,7 @@ def = 10000 min = 5000 max = 250000 interval = 2500 -str = STR_CONFIG_SETTING_AI_MAX_OPCODES +str = STR_CONFIG_SETTING_SCRIPT_MAX_OPCODES ## [SDT_VAR] -- cgit v1.2.3-54-g00ecf