summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-05-14 04:32:25 +0200
committerglx22 <glx22@users.noreply.github.com>2019-05-15 21:59:57 +0200
commita82e7ec281ca08d91bcff129b390a3f58ac308ba (patch)
tree9b309b561757799eb9fb2c2706f0f5a80581e0de /src/script
parentaac4255d43bf6cdc763cba0c1244a9c2e0fad055 (diff)
downloadopenttd-a82e7ec281ca08d91bcff129b390a3f58ac308ba.tar.xz
Fix #7590: handle script exceptions during scanning
Diffstat (limited to 'src/script')
-rw-r--r--src/script/script_scanner.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp
index 2812ef65e..66dd6dae5 100644
--- a/src/script/script_scanner.cpp
+++ b/src/script/script_scanner.cpp
@@ -17,6 +17,7 @@
#include "../script/squirrel.hpp"
#include "script_scanner.hpp"
#include "script_info.hpp"
+#include "script_fatalerror.hpp"
#include "../network/network_content.h"
#include "../3rdparty/md5/md5.h"
@@ -52,8 +53,12 @@ bool ScriptScanner::AddFile(const char *filename, size_t basepath_length, const
if (!FioCheckFileExists(filename, this->subdir) || !FioCheckFileExists(this->main_script, this->subdir)) return false;
this->ResetEngine();
- this->engine->LoadScript(filename);
-
+ try {
+ this->engine->LoadScript(filename);
+ } catch (Script_FatalError e) {
+ DEBUG(script, 0, "Fatal error '%s' when trying to load the script '%s'.", e.GetErrorMessage(), filename);
+ return false;
+ }
return true;
}