diff options
author | Eugene Sandulenko | 2019-07-16 23:59:42 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:21 +0200 |
commit | 49b0f7c6d21c8c94bdac3963c181ebc7f4e5ccb8 (patch) | |
tree | 34685a357e085ca11a668bbced9db96e4287aeb2 | |
parent | dda8c8137579b007d1aaeebc426bd4f942054b35 (diff) | |
download | scummvm-rg350-49b0f7c6d21c8c94bdac3963c181ebc7f4e5ccb8.tar.gz scummvm-rg350-49b0f7c6d21c8c94bdac3963c181ebc7f4e5ccb8.tar.bz2 scummvm-rg350-49b0f7c6d21c8c94bdac3963c181ebc7f4e5ccb8.zip |
HDB: Normalised usage of _systemInit for Lua
-rw-r--r-- | engines/hdb/lua-script.cpp | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp index 797e030af7..1160d000d7 100644 --- a/engines/hdb/lua-script.cpp +++ b/engines/hdb/lua-script.cpp @@ -86,10 +86,12 @@ bool LuaScript::loadLua(const char *name) { if (luaStream == NULL) { warning("The %s MPC entry can't be found", name); + _systemInit = false; + return false; } - initScript(luaStream, name, luaLength); + _systemInit = initScript(luaStream, name, luaLength); return true; } @@ -1706,7 +1708,7 @@ void debugHook(lua_State *L, lua_Debug *ar) { } bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scriptName, int32 length) { - if (_systemInit) { + if (_state != NULL) { lua_close(_state); } @@ -1718,8 +1720,6 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip } luaL_openlibs(_state); - _systemInit = true; - // Register Extensions for (int i = 0; luaFuncs[i].luaName; i++) { lua_register(_state, luaFuncs[i].luaName, luaFuncs[i].function); @@ -1915,11 +1915,6 @@ void LuaScript::invokeLuaFunction(char *luaFunc, int x, int y, int value1, int v } bool LuaScript::executeMPC(Common::SeekableReadStream *stream, const char *name, const char *scriptName, int32 length) { - - if (!_systemInit) { - return false; - } - char *chunk = new char[length + 1]; stream->read((void *)chunk, length); chunk[length] = '\0'; // be on the safe side @@ -1946,11 +1941,6 @@ bool LuaScript::executeMPC(Common::SeekableReadStream *stream, const char *name, } bool LuaScript::executeFile(const Common::String &filename) { - - if (!_systemInit) { - return false; - } - Common::File *file = new Common::File; if (!file->open(filename)) { @@ -1982,11 +1972,6 @@ bool LuaScript::executeFile(const Common::String &filename) { } bool LuaScript::executeChunk(Common::String &chunk, const Common::String &chunkName) const { - - if (!_systemInit) { - return false; - } - // Compile Chunk if (luaL_loadbuffer(_state, chunk.c_str(), chunk.size(), chunkName.c_str())) { error("Couldn't compile \"%s\": %s", chunkName.c_str(), lua_tostring(_state, -1)); |