aboutsummaryrefslogtreecommitdiff
path: root/engines/hdb/lua-script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/hdb/lua-script.cpp')
-rw-r--r--engines/hdb/lua-script.cpp19
1 files changed, 17 insertions, 2 deletions
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++;
+ }
+}
+}