From d88476e6773d16a86bc43b9789cf0b51d753ad97 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sun, 12 Dec 2010 00:18:49 +0000 Subject: MOHAWK: parse LB script named targeting modes svn-id: r54874 --- engines/mohawk/livingbooks.cpp | 52 +++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'engines/mohawk/livingbooks.cpp') diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index 2aceb4c2c5..491fab2858 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -1669,21 +1669,51 @@ void LBItem::readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEnd if (size < 2) error("Script entry of type 0x%04x was too small (%d)", type, size); - entry->argc = stream->readUint16(); - entry->argvParam = new uint16[entry->argc]; - entry->argvTarget = new uint16[entry->argc]; - debug(4, "With %d targets:", entry->argc); - if (size < (2 + entry->argc * 4)) - error("Script entry of type 0x%04x was too small (%d)", type, size); - for (uint i = 0; i < entry->argc; i++) { - entry->argvParam[i] = stream->readUint16(); - entry->argvTarget[i] = stream->readUint16(); - debug(4, "Target %d, param 0x%04x", entry->argvTarget[i], entry->argvParam[i]); + entry->argc = stream->readUint16(); + size -= 2; + + if ((entry->opcode & 0xff00) == 0x0100) { + uint16 targetingType = entry->argc; + if (targetingType == 0x3f3f || targetingType == 0xffff) { + entry->argc = 0; + + uint16 count = stream->readUint16(); + size -= 2; + + // FIXME: targeting by name + for (uint i = 0; i < count; i++) { + Common::String target = readString(stream); + warning("ignoring target '%s' in script entry", target.c_str()); + size -= target.size() + 1; + } + + // FIXME: unknown + if (targetingType == 0xffff) { + byte unknown = stream->readByte(); + warning("ignoring unknown script entry byte %02x", unknown); + size--; + } + } } - size -= (2 + entry->argc * 4); + if (entry->argc) { + entry->argvParam = new uint16[entry->argc]; + entry->argvTarget = new uint16[entry->argc]; + debug(4, "With %d targets:", entry->argc); + + if (size < (entry->argc * 4)) + error("Script entry of type 0x%04x was too small (%d)", type, size); + + for (uint i = 0; i < entry->argc; i++) { + entry->argvParam[i] = stream->readUint16(); + entry->argvTarget[i] = stream->readUint16(); + debug(4, "Target %d, param 0x%04x", entry->argvTarget[i], entry->argvParam[i]); + } + + size -= (entry->argc * 4); + } } if (type == kLBNotifyScript && entry->opcode == kLBNotifyChangeMode && _vm->getGameType() != GType_LIVINGBOOKSV1) { -- cgit v1.2.3