summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-05-15 21:14:13 +0200
committerglx22 <glx22@users.noreply.github.com>2019-05-15 21:59:57 +0200
commit09004f36974e841705ccb8c8c02a915601350e8c (patch)
tree05f55454435afc39af529c2836fb46f73b9f4c4f /src
parenta82e7ec281ca08d91bcff129b390a3f58ac308ba (diff)
downloadopenttd-09004f36974e841705ccb8c8c02a915601350e8c.tar.xz
Codechange: catch script exceptions by reference
Diffstat (limited to 'src')
-rw-r--r--src/script/script_instance.cpp14
-rw-r--r--src/script/script_scanner.cpp2
-rw-r--r--src/script/squirrel_helper.hpp8
3 files changed, 12 insertions, 12 deletions
diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp
index 9670e37c1..5734c2c83 100644
--- a/src/script/script_instance.cpp
+++ b/src/script/script_instance.cpp
@@ -95,7 +95,7 @@ void ScriptInstance::Initialize(const char *main_script, const char *instance_na
return;
}
ScriptObject::SetAllowDoCommand(true);
- } catch (Script_FatalError e) {
+ } catch (Script_FatalError &e) {
this->is_dead = true;
this->engine->ThrowError(e.GetErrorMessage());
this->engine->ResumeError();
@@ -188,7 +188,7 @@ void ScriptInstance::GameLoop()
}
try {
this->callback(this);
- } catch (Script_Suspend e) {
+ } catch (Script_Suspend &e) {
this->suspend = e.GetSuspendTime();
this->callback = e.GetSuspendCallback();
@@ -218,10 +218,10 @@ void ScriptInstance::GameLoop()
ScriptObject::SetAllowDoCommand(true);
/* Start the script by calling Start() */
if (!this->engine->CallMethod(*this->instance, "Start", _settings_game.script.script_max_opcode_till_suspend) || !this->engine->IsSuspended()) this->Died();
- } catch (Script_Suspend e) {
+ } catch (Script_Suspend &e) {
this->suspend = e.GetSuspendTime();
this->callback = e.GetSuspendCallback();
- } catch (Script_FatalError e) {
+ } catch (Script_FatalError &e) {
this->is_dead = true;
this->engine->ThrowError(e.GetErrorMessage());
this->engine->ResumeError();
@@ -239,10 +239,10 @@ void ScriptInstance::GameLoop()
/* Continue the VM */
try {
if (!this->engine->Resume(_settings_game.script.script_max_opcode_till_suspend)) this->Died();
- } catch (Script_Suspend e) {
+ } catch (Script_Suspend &e) {
this->suspend = e.GetSuspendTime();
this->callback = e.GetSuspendCallback();
- } catch (Script_FatalError e) {
+ } catch (Script_FatalError &e) {
this->is_dead = true;
this->engine->ThrowError(e.GetErrorMessage());
this->engine->ResumeError();
@@ -496,7 +496,7 @@ void ScriptInstance::Save()
this->engine->CrashOccurred();
return;
}
- } catch (Script_FatalError e) {
+ } catch (Script_FatalError &e) {
/* If we don't mark the script as dead here cleaning up the squirrel
* stack could throw Script_FatalError again. */
this->is_dead = true;
diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp
index 66dd6dae5..c4205bbc4 100644
--- a/src/script/script_scanner.cpp
+++ b/src/script/script_scanner.cpp
@@ -55,7 +55,7 @@ bool ScriptScanner::AddFile(const char *filename, size_t basepath_length, const
this->ResetEngine();
try {
this->engine->LoadScript(filename);
- } catch (Script_FatalError e) {
+ } catch (Script_FatalError &e) {
DEBUG(script, 0, "Fatal error '%s' when trying to load the script '%s'.", e.GetErrorMessage(), filename);
return false;
}
diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp
index e266148c5..0f094a80c 100644
--- a/src/script/squirrel_helper.hpp
+++ b/src/script/squirrel_helper.hpp
@@ -766,7 +766,7 @@ namespace SQConvert {
try {
/* Delegate it to a template that can handle this specific function */
return HelperT<Tmethod>::SQCall((Tcls *)real_instance, *(Tmethod *)ptr, vm);
- } catch (SQInteger e) {
+ } catch (SQInteger &e) {
return e;
}
}
@@ -827,7 +827,7 @@ namespace SQConvert {
try {
/* Delegate it to a template that can handle this specific function */
return HelperT<Tmethod>::SQCall((Tcls *)nullptr, *(Tmethod *)ptr, vm);
- } catch (SQInteger e) {
+ } catch (SQInteger &e) {
return e;
}
}
@@ -881,7 +881,7 @@ namespace SQConvert {
sq_setreleasehook(vm, -Tnparam, DefSQDestructorCallback<Tcls>);
instance->AddRef();
return 0;
- } catch (SQInteger e) {
+ } catch (SQInteger &e) {
return e;
}
}
@@ -903,7 +903,7 @@ namespace SQConvert {
sq_setreleasehook(vm, -nparam, DefSQDestructorCallback<Tcls>);
instance->AddRef();
return 0;
- } catch (SQInteger e) {
+ } catch (SQInteger &e) {
return e;
}
}