diff options
author | Nipun Garg | 2019-06-02 19:03:34 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:16:42 +0200 |
commit | 0ad5f7e1803c8615b2b6ac9425b710fc5b7c8304 (patch) | |
tree | 14487102872bd10a6ca8838e4b2c56fd3321ae7e | |
parent | f88b1d0d6a67c226951f74ad3be6addd9bd7dbdc (diff) | |
download | scummvm-rg350-0ad5f7e1803c8615b2b6ac9425b710fc5b7c8304.tar.gz scummvm-rg350-0ad5f7e1803c8615b2b6ac9425b710fc5b7c8304.tar.bz2 scummvm-rg350-0ad5f7e1803c8615b2b6ac9425b710fc5b7c8304.zip |
HDB: Add _systemInit check to LuaScript
-rw-r--r-- | engines/hdb/lua-script.cpp | 15 | ||||
-rw-r--r-- | engines/hdb/lua-script.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp index a844451998..3793b903a9 100644 --- a/engines/hdb/lua-script.cpp +++ b/engines/hdb/lua-script.cpp @@ -23,12 +23,15 @@ #include "common/lua/lua.h" #include "common/lua/lauxlib.h" #include "common/lua/lualib.h" +#include "common/debug.h" + #include "hdb/lua-script.h" namespace HDB { LuaScript::LuaScript() { _state = NULL; + _systemInit = false; } LuaScript::~LuaScript() { @@ -45,11 +48,17 @@ bool LuaScript::init() { return false; } + _systemInit = true; + return true; } bool LuaScript::executeFile(const Common::String &filename) { + if (!_systemInit) { + return false; + } + Common::File *file = new Common::File; if (!file->open(filename)) { @@ -80,6 +89,11 @@ bool LuaScript::registerStdLibs() { } bool LuaScript::executeChunk(const char *chunk, uint chunkSize, const Common::String &chunkName) const { + + if (!_systemInit) { + return false; + } + // Compile Chunk if (luaL_loadbuffer(_state, chunk, chunkSize, chunkName.c_str())) { error("Couldn't compile \"%s\": %s", chunkName.c_str(), lua_tostring(_state, -1)); @@ -96,6 +110,7 @@ bool LuaScript::executeChunk(const char *chunk, uint chunkSize, const Common::St return false; } + debug("Chunk successfully executed"); return true; } diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h index bf2277364e..8a9441a240 100644 --- a/engines/hdb/lua-script.h +++ b/engines/hdb/lua-script.h @@ -43,6 +43,7 @@ public: private: lua_State *_state; + bool _systemInit; bool registerStdLibs(); bool executeChunk(const char *chunk, uint chunkSize, const Common::String &chunkName) const; |