diff options
Diffstat (limited to 'src/crepe/system/ScriptSystem.cpp')
-rw-r--r-- | src/crepe/system/ScriptSystem.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/crepe/system/ScriptSystem.cpp b/src/crepe/system/ScriptSystem.cpp index ed0c7cc..f1e31f9 100644 --- a/src/crepe/system/ScriptSystem.cpp +++ b/src/crepe/system/ScriptSystem.cpp @@ -32,10 +32,29 @@ void ScriptSystem::update( if (script == nullptr) continue; if (!script->initialized) { - script->init(); - script->initialized = true; + try { + script->init(); + script->initialized = true; + } catch (const exception & e) { + Log::logf( + Log::Level::WARNING, + "Disabled script \"{}\" due to exception in init function: {}", + behavior_script.name, e.what() + ); + behavior_script.active = false; + } } - (*script.*update_function)(delta_time); + try { + (*script.*update_function)(delta_time); + } catch (const exception & e) { + // TODO: discern between fixed/frame update + Log::logf( + Log::Level::WARNING, + "Disabled script \"{}\" due to exception in update function: {}", + behavior_script.name, e.what() + ); + behavior_script.active = false; + } } } |