diff options
author | Travis Howell | 2007-06-20 01:01:29 +0000 |
---|---|---|
committer | Travis Howell | 2007-06-20 01:01:29 +0000 |
commit | 61c91cafb9376b10d643269d55e409da6a87f667 (patch) | |
tree | c0fc06039884867cc12e58cc490529c5e064e242 | |
parent | b51f2f3212ae8a5abbdce4d947ec2d1cad1a0b6f (diff) | |
download | scummvm-rg350-61c91cafb9376b10d643269d55e409da6a87f667.tar.gz scummvm-rg350-61c91cafb9376b10d643269d55e409da6a87f667.tar.bz2 scummvm-rg350-61c91cafb9376b10d643269d55e409da6a87f667.zip |
Cleanup.
svn-id: r27552
-rw-r--r-- | engines/agos/agos.cpp | 2 | ||||
-rw-r--r-- | engines/agos/agos.h | 4 | ||||
-rw-r--r-- | engines/agos/res.cpp | 219 | ||||
-rw-r--r-- | engines/agos/string.cpp | 2 | ||||
-rw-r--r-- | engines/agos/vga_ff.cpp | 2 |
5 files changed, 123 insertions, 106 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index cef31c7de1..1d44fc45b7 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -759,7 +759,7 @@ void AGOSEngine_Simon2::setupGame() { _itemMemSize = 20000; _tableMemSize = 100000; // Check whether to use MT-32 MIDI tracks in Simon the Sorcerer 2 - if ((getGameType() == GType_SIMON2) && _nativeMT32) + if (getGameType() == GType_SIMON2 && _nativeMT32) _musicIndexBase = (1128 + 612) / 4; else _musicIndexBase = 1128 / 4; diff --git a/engines/agos/agos.h b/engines/agos/agos.h index 79a8bc0567..c8adddf3e2 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -574,7 +574,7 @@ protected: void setupStringTable(byte *mem, int num); void setupLocalStringTable(byte *mem, int num); void readGamePcText(Common::SeekableReadStream *in); - void readItemChildren(Common::SeekableReadStream *in, Item *item, uint tmp); + virtual void readItemChildren(Common::SeekableReadStream *in, Item *item, uint tmp); void readItemFromGamePc(Common::SeekableReadStream *in, Item *item); void loadGamePcFile(); void readGamePcFile(Common::SeekableReadStream *in); @@ -1369,6 +1369,8 @@ protected: const OpcodeEntryElvira2 *_opcodesElvira2; + virtual void readItemChildren(Common::SeekableReadStream *in, Item *item, uint tmp); + virtual bool loadGame(const char *filename, bool restartMode = false); virtual bool saveGame(uint slot, const char *caption); diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp index f5936b7d85..977e8b1578 100644 --- a/engines/agos/res.cpp +++ b/engines/agos/res.cpp @@ -351,104 +351,130 @@ void AGOSEngine::readItemFromGamePc(Common::SeekableReadStream *in, Item *item) void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, uint type) { if (type == 1) { - if (getGameType() == GType_ELVIRA1) { - SubRoom *subRoom = (SubRoom *)allocateChildBlock(item, 1, sizeof(SubRoom)); - subRoom->roomShort = in->readUint32BE(); - subRoom->roomLong = in->readUint32BE(); - subRoom->flags = in->readUint16BE(); - } else { - uint fr1 = in->readUint16BE(); - uint fr2 = in->readUint16BE(); - uint i, size; - uint j, k; - SubRoom *subRoom; - - size = SubRoom_SIZE; - for (i = 0, j = fr2; i != 6; i++, j >>= 2) - if (j & 3) - size += sizeof(subRoom->roomExit[0]); - - subRoom = (SubRoom *)allocateChildBlock(item, 1, size); - subRoom->subroutine_id = fr1; - subRoom->roomExitStates = fr2; - - for (i = k = 0, j = fr2; i != 6; i++, j >>= 2) - if (j & 3) - subRoom->roomExit[k++] = (uint16)fileReadItemID(in); - } + SubRoom *subRoom = (SubRoom *)allocateChildBlock(item, 1, sizeof(SubRoom)); + subRoom->roomShort = in->readUint32BE(); + subRoom->roomLong = in->readUint32BE(); + subRoom->flags = in->readUint16BE(); } else if (type == 2) { - if (getGameType() == GType_ELVIRA1) { - SubObject *subObject = (SubObject *)allocateChildBlock(item, 2, sizeof(SubObject)); - in->readUint32BE(); - in->readUint32BE(); - in->readUint32BE(); - subObject->objectName = in->readUint32BE(); - subObject->objectSize = in->readUint16BE(); - subObject->objectWeight = in->readUint16BE(); - subObject->objectFlags = in->readUint16BE(); - } else { - uint32 fr = in->readUint32BE(); - uint i, k, size; - SubObject *subObject; + SubObject *subObject = (SubObject *)allocateChildBlock(item, 2, sizeof(SubObject)); + in->readUint32BE(); + in->readUint32BE(); + in->readUint32BE(); + subObject->objectName = in->readUint32BE(); + subObject->objectSize = in->readUint16BE(); + subObject->objectWeight = in->readUint16BE(); + subObject->objectFlags = in->readUint16BE(); + } else if (type == 4) { + SubGenExit *genExit = (SubGenExit *)allocateChildBlock(item, 4, sizeof(SubGenExit)); + genExit->dest[0] = (uint16)fileReadItemID(in); + genExit->dest[1] = (uint16)fileReadItemID(in); + genExit->dest[2] = (uint16)fileReadItemID(in); + genExit->dest[3] = (uint16)fileReadItemID(in); + genExit->dest[4] = (uint16)fileReadItemID(in); + genExit->dest[5] = (uint16)fileReadItemID(in); + fileReadItemID(in); + fileReadItemID(in); + fileReadItemID(in); + fileReadItemID(in); + fileReadItemID(in); + fileReadItemID(in); + } else if (type == 7) { + SubContainer *container = (SubContainer *)allocateChildBlock(item, 7, sizeof(SubContainer)); + container->volume = in->readUint16BE(); + container->flags = in->readUint16BE(); + } else if (type == 8) { + SubChain *chain = (SubChain *)allocateChildBlock(item, 8, sizeof(SubChain)); + chain->chChained = (uint16)fileReadItemID(in); + } else if (type == 9) { + setUserFlag(item, 0, in->readUint16BE()); + setUserFlag(item, 1, in->readUint16BE()); + setUserFlag(item, 2, in->readUint16BE()); + setUserFlag(item, 3, in->readUint16BE()); + setUserFlag(item, 4, in->readUint16BE()); + setUserFlag(item, 5, in->readUint16BE()); + setUserFlag(item, 6, in->readUint16BE()); + setUserFlag(item, 7, in->readUint16BE()); + SubUserFlag *subUserFlag = (SubUserFlag *) findChildOfType(item, 9); + subUserFlag->userItems[0] = (uint16)fileReadItemID(in); + fileReadItemID(in); + fileReadItemID(in); + fileReadItemID(in); + } else if (type == 255) { + SubInherit *inherit = (SubInherit *)allocateChildBlock(item, 255, sizeof(SubInherit)); + inherit->inMaster = (uint16)fileReadItemID(in); + } else { + error("readItemChildren: invalid type %d", type); + } +} - size = SubObject_SIZE; - for (i = 0; i != 16; i++) - if (fr & (1 << i)) - size += sizeof(subObject->objectFlagValue[0]); +void AGOSEngine_Elvira2::readItemChildren(Common::SeekableReadStream *in, Item *item, uint type) { + if (type == 1) { + uint fr1 = in->readUint16BE(); + uint fr2 = in->readUint16BE(); + uint i, size; + uint j, k; + SubRoom *subRoom; + + size = SubRoom_SIZE; + for (i = 0, j = fr2; i != 6; i++, j >>= 2) + if (j & 3) + size += sizeof(subRoom->roomExit[0]); + + subRoom = (SubRoom *)allocateChildBlock(item, 1, size); + subRoom->subroutine_id = fr1; + subRoom->roomExitStates = fr2; + + for (i = k = 0, j = fr2; i != 6; i++, j >>= 2) + if (j & 3) + subRoom->roomExit[k++] = (uint16)fileReadItemID(in); + } else if (type == 2) { + uint32 fr = in->readUint32BE(); + uint i, k, size; + SubObject *subObject; - subObject = (SubObject *)allocateChildBlock(item, 2, size); - subObject->objectFlags = fr; + size = SubObject_SIZE; + for (i = 0; i != 16; i++) + if (fr & (1 << i)) + size += sizeof(subObject->objectFlagValue[0]); - k = 0; - if (fr & 1) { - subObject->objectFlagValue[k++] = (uint16)in->readUint32BE(); - } - for (i = 1; i != 16; i++) - if (fr & (1 << i)) - subObject->objectFlagValue[k++] = in->readUint16BE(); + subObject = (SubObject *)allocateChildBlock(item, 2, size); + subObject->objectFlags = fr; - if (getGameType() != GType_ELVIRA2) - subObject->objectName = (uint16)in->readUint32BE(); + k = 0; + if (fr & 1) { + subObject->objectFlagValue[k++] = (uint16)in->readUint32BE(); } + for (i = 1; i != 16; i++) + if (fr & (1 << i)) + subObject->objectFlagValue[k++] = in->readUint16BE(); + + if (getGameType() != GType_ELVIRA2) + subObject->objectName = (uint16)in->readUint32BE(); } else if (type == 4) { - if (getGameType() == GType_ELVIRA2) { - uint i, j, k, size; - uint id, x, y, z; - SubSuperRoom *subSuperRoom; - - id = in->readUint16BE(); - x = in->readUint16BE(); - y = in->readUint16BE(); - z = in->readUint16BE(); - - j = x * y * z; - size = SubSuperRoom_SIZE; - for (i = 0; i != j; i++) - size += sizeof(subSuperRoom->roomExitStates[0]); - - subSuperRoom = (SubSuperRoom *)allocateChildBlock(item, 4, size); - subSuperRoom->subroutine_id = id; - subSuperRoom->roomX = x; - subSuperRoom->roomY = y; - subSuperRoom->roomZ = z; - - for (i = k = 0; i != j; i++) - subSuperRoom->roomExitStates[k++] = in->readUint16BE(); - } else if (getGameType() == GType_ELVIRA1) { - SubGenExit *genExit = (SubGenExit *)allocateChildBlock(item, 4, sizeof(SubGenExit)); - genExit->dest[0] = (uint16)fileReadItemID(in); - genExit->dest[1] = (uint16)fileReadItemID(in); - genExit->dest[2] = (uint16)fileReadItemID(in); - genExit->dest[3] = (uint16)fileReadItemID(in); - genExit->dest[4] = (uint16)fileReadItemID(in); - genExit->dest[5] = (uint16)fileReadItemID(in); - fileReadItemID(in); - fileReadItemID(in); - fileReadItemID(in); - fileReadItemID(in); - fileReadItemID(in); - fileReadItemID(in); - } + assert(getGameType() == GType_ELVIRA2); + + uint i, j, k, size; + uint id, x, y, z; + SubSuperRoom *subSuperRoom; + + id = in->readUint16BE(); + x = in->readUint16BE(); + y = in->readUint16BE(); + z = in->readUint16BE(); + + j = x * y * z; + size = SubSuperRoom_SIZE; + for (i = 0; i != j; i++) + size += sizeof(subSuperRoom->roomExitStates[0]); + + subSuperRoom = (SubSuperRoom *)allocateChildBlock(item, 4, size); + subSuperRoom->subroutine_id = id; + subSuperRoom->roomX = x; + subSuperRoom->roomY = y; + subSuperRoom->roomZ = z; + + for (i = k = 0; i != j; i++) + subSuperRoom->roomExitStates[k++] = in->readUint16BE(); } else if (type == 7) { SubContainer *container = (SubContainer *)allocateChildBlock(item, 7, sizeof(SubContainer)); container->volume = in->readUint16BE(); @@ -461,17 +487,6 @@ void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, ui setUserFlag(item, 1, in->readUint16BE()); setUserFlag(item, 2, in->readUint16BE()); setUserFlag(item, 3, in->readUint16BE()); - if (getGameType() == GType_ELVIRA1) { - setUserFlag(item, 4, in->readUint16BE()); - setUserFlag(item, 5, in->readUint16BE()); - setUserFlag(item, 6, in->readUint16BE()); - setUserFlag(item, 7, in->readUint16BE()); - SubUserFlag *subUserFlag = (SubUserFlag *) findChildOfType(item, 9); - subUserFlag->userItems[0] = (uint16)fileReadItemID(in); - fileReadItemID(in); - fileReadItemID(in); - fileReadItemID(in); - } } else if (type == 255) { SubInherit *inherit = (SubInherit *)allocateChildBlock(item, 255, sizeof(SubInherit)); inherit->inMaster = (uint16)fileReadItemID(in); diff --git a/engines/agos/string.cpp b/engines/agos/string.cpp index d9249d3305..9a84876a6e 100644 --- a/engines/agos/string.cpp +++ b/engines/agos/string.cpp @@ -304,7 +304,7 @@ void AGOSEngine::printScreenText(uint vgaSpriteId, uint color, const char *strin lettersPerRowJustified = stringLength / (stringLength / lettersPerRow + 1) + 1; talkDelay = (stringLength + 3) / 3; - if ((getGameType() == GType_SIMON1) && (getFeatures() & GF_TALKIE)) { + if (getGameType() == GType_SIMON1 && (getFeatures() & GF_TALKIE)) { if (_variableArray[141] == 0) _variableArray[141] = 9; _variableArray[85] = _variableArray[141] * talkDelay; diff --git a/engines/agos/vga_ff.cpp b/engines/agos/vga_ff.cpp index e1ee56002e..29b05e1e3c 100644 --- a/engines/agos/vga_ff.cpp +++ b/engines/agos/vga_ff.cpp @@ -217,7 +217,7 @@ void AGOSEngine::checkScrollX(int16 x, int16 xpos) { if (_scrollXMax == 0 || x == 0) return; - if ((getGameType() == GType_FF) && (getBitFlag(80) || getBitFlag(82))) + if (getGameType() == GType_FF && (getBitFlag(80) || getBitFlag(82))) return; int16 tmp; |