aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2019-06-06 09:48:54 +0200
committerEugene Sandulenko2019-09-03 17:16:43 +0200
commit418ad2c94e0e86c04ea8f19760cd3344db99647b (patch)
tree846966313cd0716291f9659814182a91c433b42a
parent58a645dadb84f80ffe66a9d81da1302f5eb975cd (diff)
downloadscummvm-rg350-418ad2c94e0e86c04ea8f19760cd3344db99647b.tar.gz
scummvm-rg350-418ad2c94e0e86c04ea8f19760cd3344db99647b.tar.bz2
scummvm-rg350-418ad2c94e0e86c04ea8f19760cd3344db99647b.zip
HDB: Add error handling during level_init execution
-rw-r--r--engines/hdb/lua-script.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 1580552151..56e0ead5e8 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -684,8 +684,19 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, int32 length) {
return false;
}
+
+ // Error handling function to be executed after the function is put on the stack
+ lua_rawgeti(_state, LUA_REGISTRYINDEX, _pcallErrorhandlerRegistryIndex);
+ lua_insert(_state, -2);
+
lua_getglobal(_state, "level_init");
- lua_pcall(_state, 0, 0, 0);
+
+ if (lua_pcall(_state, 0, 0, -2)) {
+ error("An error occured while executing \"%s\": %s.", "level_init", lua_tostring(_state, -1));
+ lua_pop(_state, -1);
+
+ return false;
+ }
return true;
}