Skip to content
Permalink
Browse files

Codechange: catch script exceptions by reference

  • Loading branch information...
glx22 committed May 15, 2019
1 parent a82e7ec commit 09004f36974e841705ccb8c8c02a915601350e8c
Showing with 12 additions and 12 deletions.
  1. +7 −7 src/script/script_instance.cpp
  2. +1 −1 src/script/script_scanner.cpp
  3. +4 −4 src/script/squirrel_helper.hpp
@@ -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;
@@ -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;
}
@@ -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;
}
}

0 comments on commit 09004f3

Please sign in to comment.
You can’t perform that action at this time.