diff options
author | Eugene Sandulenko | 2019-07-08 21:15:16 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:15 +0200 |
commit | 2315a05ad39e013b009e98baafcbd9b7edb717a1 (patch) | |
tree | ea7798e60fad0c87b41224d139d17528cfa74ef4 | |
parent | 85a8209d97992572d98a2f4bb20a9b9faa706b0c (diff) | |
download | scummvm-rg350-2315a05ad39e013b009e98baafcbd9b7edb717a1.tar.gz scummvm-rg350-2315a05ad39e013b009e98baafcbd9b7edb717a1.tar.bz2 scummvm-rg350-2315a05ad39e013b009e98baafcbd9b7edb717a1.zip |
HDB: Fix calling Lua save/load
-rw-r--r-- | engines/hdb/lua-script.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp index 58f79293cc..8ce614cabb 100644 --- a/engines/hdb/lua-script.cpp +++ b/engines/hdb/lua-script.cpp @@ -162,10 +162,8 @@ void LuaScript::save(Common::OutSaveFile *out, const char *fName) { lua_getglobal(_state, "SaveState"); lua_pushstring(_state, fName); - if (lua_pcall(_state, 0, 0, -2)) { - error("An error occured while saving \"%s\": %s.", fName, lua_tostring(_state, -1)); - lua_pop(_state, -1); - } + + lua_call(_state, 1, 0); } void LuaScript::loadSaveFile(Common::InSaveFile *in, const char *fName) { @@ -181,13 +179,14 @@ void LuaScript::loadSaveFile(Common::InSaveFile *in, const char *fName) { in->read(_globals[i]->string, 32); } + // 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, "LoadState"); lua_pushstring(_state, fName); - if (lua_pcall(_state, 0, 0, -2)) { - error("An error occured while loading \"%s\": %s.", fName, lua_tostring(_state, -1)); - lua_pop(_state, -1); - } + lua_call(_state, 1, 0); } void LuaScript::setLuaGlobalValue(const char *name, int value) { |