aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNipun Garg2019-06-05 03:06:21 +0530
committerEugene Sandulenko2019-09-03 17:16:42 +0200
commit4b8f7f339e3be160b8acb77b4efd71d21877c79f (patch)
tree7345fadf308e0977a8590df690beb73ba6b1fbf1 /engines
parent094bf4c06b4f9184b593e0f8f59c61fd1c577d8c (diff)
downloadscummvm-rg350-4b8f7f339e3be160b8acb77b4efd71d21877c79f.tar.gz
scummvm-rg350-4b8f7f339e3be160b8acb77b4efd71d21877c79f.tar.bz2
scummvm-rg350-4b8f7f339e3be160b8acb77b4efd71d21877c79f.zip
HDB: Add stripComments() to strip C-style comments
There are a few C-style comments present in the Lua files
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/hdb.cpp8
-rw-r--r--engines/hdb/lua-script.cpp19
-rw-r--r--engines/hdb/lua-script.h1
3 files changed, 22 insertions, 6 deletions
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index b96d8187e5..a33cb82a90 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -138,14 +138,14 @@ Common::Error HDBGame::run() {
Tile *tile = new Tile;
Graphics::Surface surf2 = tile->load(tileStream);
- Common::SeekableReadStream *luaStream = fileMan->findFirstData("MAP00_DEMO_LUA", TYPE_BINARY);
- int32 luaLength = fileMan->getLength("MAP00_DEMO_LUA", TYPE_BINARY);
+ Common::SeekableReadStream *luaStream = fileMan->findFirstData("CINE_INTRO_DEMO_LUA", TYPE_BINARY);
+ int32 luaLength = fileMan->getLength("CINE_INTRO_DEMO_LUA", TYPE_BINARY);
if (luaStream == NULL) {
- debug("The MAP00_DEMO_LUA MPC entry can't be found.");
+ debug("The CINE_INTRO_DEMO_LUA MPC entry can't be found.");
return Common::kReadingFailed;
}
- lua->initScript(luaStream, "MAP00_DEMO_LUA", luaLength);
+ lua->initScript(luaStream, "CINE_INTRO_DEMO_LUA", luaLength);
//lua->executeMPC(luaStream, "CINE_INTRO_DEMO_LUA", luaLength);
while (!shouldQuit()) {
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 3dfb53a436..55ad724c48 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -147,9 +147,12 @@ bool LuaScript::executeMPC(Common::SeekableReadStream *stream, const char *name,
return false;
}
- const char *chunk = new char[length];
+ char *chunk = new char[length];
stream->read((void *)chunk, length);
+ // Remove C-Style comments from script
+ stripComments(chunk);
+
if (!executeChunk(chunk, length, name)) {
delete[] chunk;
@@ -215,4 +218,16 @@ bool LuaScript::executeChunk(const char *chunk, uint chunkSize, const Common::St
return true;
}
-} \ No newline at end of file
+void LuaScript::stripComments(char *chunk) {
+ uint32 offset = 0;
+
+ while (chunk[offset]) {
+ if (chunk[offset] == '/' && chunk[offset + 1] == '/') {
+ while (chunk[offset] != 0x0d) {
+ chunk[offset++] = ' ';
+ }
+ }
+ offset++;
+ }
+}
+}
diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h
index 42e905d139..78b5dc08dd 100644
--- a/engines/hdb/lua-script.h
+++ b/engines/hdb/lua-script.h
@@ -48,6 +48,7 @@ private:
bool registerExtensions();
bool executeChunk(const char *chunk, uint chunkSize, const Common::String &chunkName) const;
+ void stripComments(char *chunk);
};
}