[Scummvm-cvs-logs] SF.net SVN: scummvm:[54871] scummvm/trunk/engines/mohawk
fuzzie at users.sourceforge.net
fuzzie at users.sourceforge.net
Sun Dec 12 00:48:30 CET 2010
Revision: 54871
http://scummvm.svn.sourceforge.net/scummvm/?rev=54871&view=rev
Author: fuzzie
Date: 2010-12-11 23:48:29 +0000 (Sat, 11 Dec 2010)
Log Message:
-----------
MOHAWK: Improve LB script parsing
Modified Paths:
--------------
scummvm/trunk/engines/mohawk/livingbooks.cpp
scummvm/trunk/engines/mohawk/livingbooks.h
Modified: scummvm/trunk/engines/mohawk/livingbooks.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.cpp 2010-12-11 19:53:44 UTC (rev 54870)
+++ scummvm/trunk/engines/mohawk/livingbooks.cpp 2010-12-11 23:48:29 UTC (rev 54871)
@@ -1661,6 +1661,10 @@
entry->type, entry->event, entry->opcode, entry->param);
size -= 6;
+ // TODO: read as bytes, if this is correct (but beware endianism)
+ byte expectedConditions = (entry->event & 0xff00) >> 8;
+ entry->event = entry->event & 0xff;
+
if (type == kLBMsgListScript) {
if (size < 2)
error("Script entry of type 0x%04x was too small (%d)", type, size);
@@ -1694,26 +1698,33 @@
entry->newUnknown, entry->newMode, entry->newPage, entry->newSubpage);
size -= 8;
}
- // FIXME: what is 0x1d?
- if (entry->event == kLBEventNotified || entry->opcode == 0x1d) {
+ if (entry->event == kLBEventNotified) {
if (size < 4)
- error("not enough bytes (%d) in event %d, opcode 0x%04x", size, entry->event, entry->opcode);
+ error("not enough bytes (%d) in kLBEventNotified, opcode 0x%04x", size, entry->opcode);
entry->matchFrom = stream->readUint16();
entry->matchNotify = stream->readUint16();
debug(4, "kLBEventNotified: unknowns %04x, %04x",
entry->matchFrom, entry->matchNotify);
size -= 4;
}
+ if (entry->opcode == kLBOpSendExpression) {
+ if (size < 4)
+ error("not enough bytes (%d) in kLBOpSendExpression, event 0x%04x", size, entry->event);
+ entry->offset = stream->readUint32();
+ debug(4, "kLBOpSendExpression: offset %08x", entry->offset);
+ size -= 4;
+ }
if (entry->opcode == 0xffff) {
if (size < 4)
- error("didn't get enough bytes (%d) to read command in script entry", size);
+ error("didn't get enough bytes (%d) to read message in script entry", size);
size -= 4;
uint16 msgId = stream->readUint16();
+ uint16 msgLen = stream->readUint16();
if (msgId != kLBCommand)
error("expected a command in script entry, got 0x%04x", msgId);
- uint16 msgLen = stream->readUint16();
- if (msgLen != size)
+
+ if (msgLen != size && expectedConditions == 0)
error("script entry msgLen %d is not equal to size %d", msgLen, size);
Common::String command = readString(stream);
@@ -1725,7 +1736,9 @@
entry->command = command;
debug(4, "script entry command '%s'", command.c_str());
- } else if (size) {
+ }
+
+ if (size) {
byte commandLen = stream->readByte();
if (commandLen)
error("got confused while reading bytes at end of script entry (got %d)", commandLen);
@@ -1742,9 +1755,6 @@
debug(4, "script entry condition '%s'", condition.c_str());
}
- // TODO: read as bytes, if this is correct (but beware endianism)
- byte expectedConditions = (entry->event & 0xff00) >> 8;
- entry->event = entry->event & 0xff;
if (entry->conditions.size() != expectedConditions)
error("got %d conditions, but expected %d", entry->conditions.size(), expectedConditions);
Modified: scummvm/trunk/engines/mohawk/livingbooks.h
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.h 2010-12-11 19:53:44 UTC (rev 54870)
+++ scummvm/trunk/engines/mohawk/livingbooks.h 2010-12-11 23:48:29 UTC (rev 54871)
@@ -222,6 +222,9 @@
uint16 matchFrom;
uint16 matchNotify;
+ // kLBOpSendExpression
+ uint32 offset;
+
Common::String command;
Common::Array<Common::String> conditions;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list