aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2019-07-09 23:34:01 +0200
committerEugene Sandulenko2019-09-03 17:17:16 +0200
commit38bdb36b239fbeb7e6e38adeacd83c8cfb7caa9b (patch)
tree240ebc387e629418ace51a1f6ee4d65158e89e5a /engines
parentd0b5e0fbc75cdb929dd3c666d4a64c8a83f3ecc6 (diff)
downloadscummvm-rg350-38bdb36b239fbeb7e6e38adeacd83c8cfb7caa9b.tar.gz
scummvm-rg350-38bdb36b239fbeb7e6e38adeacd83c8cfb7caa9b.tar.bz2
scummvm-rg350-38bdb36b239fbeb7e6e38adeacd83c8cfb7caa9b.zip
HDB: Finish implementation of Lua dofile()
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/lua-script.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 7a33355710..b563de3d0e 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -1256,8 +1256,21 @@ static int dofile(lua_State *L) {
if (!in)
error("Lua dofile: cannot open file '%s'", fName);
+ int length = in->size();
+ char *chunk = new char[length + 1];
+ in->read((void *)chunk, length);
+
+ chunk[length] = '\0'; // be on the safe side
+
+ Common::String chunkString(chunk);
+ delete[] chunk;
+
delete in;
+ if (!g_hdb->_lua->executeChunk(chunkString, fName)) {
+ return 0;
+ }
+
return 0;
}