changeset 18543:1ba866a592fd draft

(svn r23387) -Fix: move ai.script_max_opcode_till_suspend to script.script_max_opcode_till_suspend
author truebrain <truebrain@openttd.org>
date Thu, 01 Dec 2011 12:04:22 +0000
parents 50f097910f96
children e358ddc58613
files src/lang/english.txt src/script/script_instance.cpp src/settings_gui.cpp src/settings_type.h src/table/settings.ini
diffstat 5 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1264,7 +1264,7 @@
 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_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
--- a/src/script/script_instance.cpp
+++ b/src/script/script_instance.cpp
@@ -187,7 +187,7 @@
 			}
 			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 @@
 
 	/* 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::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)
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1479,9 +1479,16 @@
 /** 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 @@
 	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)};
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -257,7 +257,11 @@
 	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 @@
 	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
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -1160,7 +1160,7 @@
 
 [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 @@
 min      = 5000
 max      = 250000
 interval = 2500
-str      = STR_CONFIG_SETTING_AI_MAX_OPCODES
+str      = STR_CONFIG_SETTING_SCRIPT_MAX_OPCODES
 
 ##
 [SDT_VAR]