aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNipun Garg2019-06-06 03:41:38 +0530
committerEugene Sandulenko2019-09-03 17:16:43 +0200
commitf9beeb66d3674c86c51674577b2b13b13540ba8a (patch)
tree51a59d5e73924d2b6ef63dbb01029e10c7c8bc59
parent538ead52bb0142b18328edcf0a8495ba3406ff94 (diff)
downloadscummvm-rg350-f9beeb66d3674c86c51674577b2b13b13540ba8a.tar.gz
scummvm-rg350-f9beeb66d3674c86c51674577b2b13b13540ba8a.tar.bz2
scummvm-rg350-f9beeb66d3674c86c51674577b2b13b13540ba8a.zip
HDB: Add init() to load the GLOBAL_LUA code
-rw-r--r--engines/hdb/lua-script.cpp25
-rw-r--r--engines/hdb/lua-script.h2
2 files changed, 13 insertions, 14 deletions
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 79d4afb362..184ff474dd 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -40,20 +40,19 @@ LuaScript::~LuaScript() {
}
}
-#if 0
+
bool LuaScript::init() {
- // Create new lua_State and initialize the Std Libs
- _state = luaL_newstate();
- if (!_state || !registerStdLibs()) {
- error("Cannot initialize Lua");
+ // Load Global Lua Code
+ _globalLuaStream = g_hdb->fileMan->findFirstData("GLOBAL_LUA", TYPE_BINARY);
+ _globalLuaLength = g_hdb->fileMan->getLength("GLOBAL_LUA", TYPE_BINARY);
+ if (_globalLuaStream == NULL || _globalLuaLength == 0) {
+ error("LuaScript::initScript: 'global code' failed to load");
return false;
}
- _systemInit = true;
-
return true;
}
-#endif
+
/*
Called from Lua, this will pop into the menu
@@ -622,12 +621,10 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, int32 length) {
// Load GLOBAL_LUA and execute it
- g_hdb->fileMan->findFirstData("GLOBAL_LUA", TYPE_BINARY);
-
- //if (!executeMPC(globalStream, "global code", globalLength)) {
- // error("LuaScript::initScript: 'global code' failed to execute");
- // return false;
- //}
+ if (!executeMPC(_globalLuaStream, "global code", _globalLuaLength)) {
+ error("LuaScript::initScript: 'global code' failed to execute");
+ return false;
+ }
// Load script and execute it
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index eee51cd396..ec7213315e 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -44,6 +44,8 @@ public:
private:
lua_State *_state;
+ Common::SeekableReadStream* _globalLuaStream;
+ int32 _globalLuaLength;
bool _systemInit;
bool registerExtensions();