diff options
author | Matthew Hoops | 2010-11-20 23:53:14 +0000 |
---|---|---|
committer | Matthew Hoops | 2010-11-20 23:53:14 +0000 |
commit | 0f2bcd2f9fcc6d5c8ba67b75f625290db126d231 (patch) | |
tree | be048742e6c46d4706ea895393f998c89bc7fdaa /engines | |
parent | d886c037dd43aa76550c8dcea7b59f8f53f1c6fa (diff) | |
download | scummvm-rg350-0f2bcd2f9fcc6d5c8ba67b75f625290db126d231.tar.gz scummvm-rg350-0f2bcd2f9fcc6d5c8ba67b75f625290db126d231.tar.bz2 scummvm-rg350-0f2bcd2f9fcc6d5c8ba67b75f625290db126d231.zip |
MOHAWK: Cleanup resource handling
- Renamed getRawData() to getResource()
- Add a getResource() and hasResource() function for named resources
- Other minor formatting changes
svn-id: r54396
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mohawk/console.cpp | 8 | ||||
-rw-r--r-- | engines/mohawk/graphics.cpp | 18 | ||||
-rw-r--r-- | engines/mohawk/livingbooks.cpp | 4 | ||||
-rw-r--r-- | engines/mohawk/mohawk.cpp | 25 | ||||
-rw-r--r-- | engines/mohawk/mohawk.h | 4 | ||||
-rw-r--r-- | engines/mohawk/myst.cpp | 8 | ||||
-rw-r--r-- | engines/mohawk/resource.cpp | 128 | ||||
-rw-r--r-- | engines/mohawk/resource.h | 42 | ||||
-rw-r--r-- | engines/mohawk/riven.cpp | 12 | ||||
-rw-r--r-- | engines/mohawk/riven_saveload.cpp | 8 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.cpp | 4 | ||||
-rw-r--r-- | engines/mohawk/sound.cpp | 18 | ||||
-rw-r--r-- | engines/mohawk/video.cpp | 4 |
13 files changed, 194 insertions, 89 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp index bb64401f37..0316c40c3c 100644 --- a/engines/mohawk/console.cpp +++ b/engines/mohawk/console.cpp @@ -502,7 +502,7 @@ bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) { _vm->changeToStack(newStack); // Load in Variable Names - Common::SeekableReadStream *nameStream = _vm->getRawData(ID_NAME, VariableNames); + Common::SeekableReadStream *nameStream = _vm->getResource(ID_NAME, VariableNames); Common::StringArray varNames; uint16 namesCount = nameStream->readUint16BE(); @@ -523,7 +523,7 @@ bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) { delete nameStream; // Load in External Command Names - nameStream = _vm->getRawData(ID_NAME, ExternalCommandNames); + nameStream = _vm->getResource(ID_NAME, ExternalCommandNames); Common::StringArray xNames; namesCount = nameStream->readUint16BE(); @@ -553,7 +553,7 @@ bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) { // deriven. debugN("\n\nDumping scripts for %s\'s card %d!\n", argv[1], (uint16)atoi(argv[3])); debugN("==================================\n\n"); - Common::SeekableReadStream *cardStream = _vm->getRawData(MKID_BE('CARD'), (uint16)atoi(argv[3])); + Common::SeekableReadStream *cardStream = _vm->getResource(MKID_BE('CARD'), (uint16)atoi(argv[3])); cardStream->seek(4); RivenScriptList scriptList = _vm->_scriptMan->readScripts(cardStream, false); for (uint32 i = 0; i < scriptList.size(); i++) { @@ -566,7 +566,7 @@ bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) { debugN("\n\nDumping scripts for %s\'s card %d hotspots!\n", argv[1], (uint16)atoi(argv[3])); debugN("===========================================\n\n"); - Common::SeekableReadStream *hsptStream = _vm->getRawData(MKID_BE('HSPT'), (uint16)atoi(argv[3])); + Common::SeekableReadStream *hsptStream = _vm->getResource(MKID_BE('HSPT'), (uint16)atoi(argv[3])); uint16 hotspotCount = hsptStream->readUint16BE(); diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index 5215e2b78c..2b2bbd8f2c 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -203,7 +203,7 @@ Graphics::Surface *MystGraphics::decodeImage(uint16 id) { if (_vm->getFeatures() & GF_ME && _vm->hasResource(ID_PICT, id)) { // The PICT resource exists. However, it could still contain a MystBitmap // instead of a PICT image... - dataStream = _vm->getRawData(ID_PICT, id); + dataStream = _vm->getResource(ID_PICT, id); // Here we detect whether it's really a PICT or a WDIB. Since a MystBitmap // would be compressed, there's no way to detect for the BM without a hack. @@ -212,7 +212,7 @@ Graphics::Surface *MystGraphics::decodeImage(uint16 id) { isPict = (dataStream->readUint32BE() == 0x001102FF); dataStream->seek(0); } else // No PICT, so the WDIB must exist. Let's go grab it. - dataStream = _vm->getRawData(ID_WDIB, id); + dataStream = _vm->getResource(ID_WDIB, id); if (isPict) surface = _pictDecoder->decodeImage(dataStream); @@ -283,8 +283,8 @@ void MystGraphics::hideCursor(void) { void MystGraphics::changeCursor(uint16 cursor) { // Both Myst and Myst ME use the "MystBitmap" format for cursor images. - ImageData *data = _bmpDecoder->decodeImage(_vm->getRawData(ID_WDIB, cursor)); - Common::SeekableReadStream *clrcStream = _vm->getRawData(ID_CLRC, cursor); + ImageData *data = _bmpDecoder->decodeImage(_vm->getResource(ID_WDIB, cursor)); + Common::SeekableReadStream *clrcStream = _vm->getResource(ID_CLRC, cursor); uint16 hotspotX = clrcStream->readUint16LE(); uint16 hotspotY = clrcStream->readUint16LE(); delete clrcStream; @@ -343,7 +343,7 @@ RivenGraphics::~RivenGraphics() { } Graphics::Surface *RivenGraphics::decodeImage(uint16 id) { - ImageData *imageData = _bitmapDecoder->decodeImage(_vm->getRawData(ID_TBMP, id)); + ImageData *imageData = _bitmapDecoder->decodeImage(_vm->getResource(ID_TBMP, id)); Graphics::Surface *surface = imageData->getSurface(); delete imageData; return surface; @@ -363,7 +363,7 @@ void RivenGraphics::copyImageToScreen(uint16 image, uint32 left, uint32 top, uin } void RivenGraphics::drawPLST(uint16 x) { - Common::SeekableReadStream* plst = _vm->getRawData(ID_PLST, _vm->getCurCard()); + Common::SeekableReadStream* plst = _vm->getResource(ID_PLST, _vm->getCurCard()); uint16 index, id, left, top, right, bottom; uint16 recordCount = plst->readUint16BE(); @@ -412,7 +412,7 @@ void RivenGraphics::updateScreen() { } void RivenGraphics::scheduleWaterEffect(uint16 sfxeID) { - Common::SeekableReadStream *sfxeStream = _vm->getRawData(ID_SFXE, sfxeID); + Common::SeekableReadStream *sfxeStream = _vm->getResource(ID_SFXE, sfxeID); if (sfxeStream->readUint16BE() != 'SL') error ("Unknown sfxe tag"); @@ -790,7 +790,7 @@ Graphics::Surface *LBGraphics::decodeImage(uint16 id) { if (_vm->getGameType() == GType_LIVINGBOOKSV1) imageData = _bmpDecoder->decodeImage(_vm->wrapStreamEndian(ID_BMAP, id)); else - imageData = _bmpDecoder->decodeImage(_vm->getRawData(ID_TBMP, id)); + imageData = _bmpDecoder->decodeImage(_vm->getResource(ID_TBMP, id)); imageData->_palette = _palette; Graphics::Surface *surface = imageData->getSurface(); @@ -828,7 +828,7 @@ void LBGraphics::setPalette(uint16 id) { delete ctblStream; } else { - Common::SeekableReadStream *tpalStream = _vm->getRawData(ID_TPAL, id); + Common::SeekableReadStream *tpalStream = _vm->getResource(ID_TPAL, id); uint16 colorStart = tpalStream->readUint16BE(); uint16 colorCount = tpalStream->readUint16BE(); diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index 515ee7c8ba..d95decfc2a 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -169,7 +169,7 @@ void MohawkEngine_LivingBooks::loadIntro() { // Only 1 VSRN resource per stack, Id 1000 uint16 MohawkEngine_LivingBooks::getResourceVersion() { - Common::SeekableReadStream *versionStream = getRawData(ID_VRSN, 1000); + Common::SeekableReadStream *versionStream = getResource(ID_VRSN, 1000); if (versionStream->size() != 2) warning("Version Record size mismatch"); @@ -264,7 +264,7 @@ void MohawkEngine_LivingBooks::loadANI(uint16 resourceId) { } Common::SeekableSubReadStreamEndian *MohawkEngine_LivingBooks::wrapStreamEndian(uint32 tag, uint16 id) { - Common::SeekableReadStream *dataStream = getRawData(tag, id); + Common::SeekableReadStream *dataStream = getResource(tag, id); return new Common::SeekableSubReadStreamEndian(dataStream, 0, dataStream->size(), isBigEndian(), DisposeAfterUse::YES); } diff --git a/engines/mohawk/mohawk.cpp b/engines/mohawk/mohawk.cpp index 6b4d8bb2d2..54e753dfe5 100644 --- a/engines/mohawk/mohawk.cpp +++ b/engines/mohawk/mohawk.cpp @@ -84,12 +84,21 @@ void MohawkEngine::pauseGame() { runDialog(*_pauseDialog); } -Common::SeekableReadStream *MohawkEngine::getRawData(uint32 tag, uint16 id) { +Common::SeekableReadStream *MohawkEngine::getResource(uint32 tag, uint16 id) { for (uint32 i = 0; i < _mhk.size(); i++) if (_mhk[i]->hasResource(tag, id)) - return _mhk[i]->getRawData(tag, id); + return _mhk[i]->getResource(tag, id); - error ("Could not find a \'%s\' resource with ID %04x", tag2str(tag), id); + error("Could not find a '%s' resource with ID %04x", tag2str(tag), id); + return NULL; +} + +Common::SeekableReadStream *MohawkEngine::getResource(uint32 tag, const Common::String &resName) { + for (uint32 i = 0; i < _mhk.size(); i++) + if (_mhk[i]->hasResource(tag, resName)) + return _mhk[i]->getResource(tag, resName); + + error("Could not find a '%s' resource matching name '%s'", tag2str(tag), resName.c_str()); return NULL; } @@ -101,12 +110,20 @@ bool MohawkEngine::hasResource(uint32 tag, uint16 id) { return false; } +bool MohawkEngine::hasResource(uint32 tag, const Common::String &resName) { + for (uint32 i = 0; i < _mhk.size(); i++) + if (_mhk[i]->hasResource(tag, resName)) + return true; + + return false; +} + uint32 MohawkEngine::getResourceOffset(uint32 tag, uint16 id) { for (uint32 i = 0; i < _mhk.size(); i++) if (_mhk[i]->hasResource(tag, id)) return _mhk[i]->getOffset(tag, id); - error ("Could not find a \'%s\' resource with ID %04x", tag2str(tag), id); + error("Could not find a '%s' resource with ID %04x", tag2str(tag), id); return 0; } diff --git a/engines/mohawk/mohawk.h b/engines/mohawk/mohawk.h index 7bd76193fc..d53c080f40 100644 --- a/engines/mohawk/mohawk.h +++ b/engines/mohawk/mohawk.h @@ -99,8 +99,10 @@ public: Sound *_sound; VideoManager *_video; - virtual Common::SeekableReadStream *getRawData(uint32 tag, uint16 id); + virtual Common::SeekableReadStream *getResource(uint32 tag, uint16 id); + Common::SeekableReadStream *getResource(uint32 tag, const Common::String &resName); bool hasResource(uint32 tag, uint16 id); + bool hasResource(uint32 tag, const Common::String &resName); uint32 getResourceOffset(uint32 tag, uint16 id); void pauseGame(); diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index dd5d045fc6..7778aff954 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -121,7 +121,7 @@ Common::SeekableReadStream *MohawkEngine_Myst::getRawData(uint32 tag, uint16 id) for (uint32 i = 0; i < _mhk.size(); i++) if (_mhk[i]->hasResource(tag, id)) { - ret = _mhk[i]->getRawData(tag, id); + ret = _mhk[i]->getResource(tag, id); _cache.add(tag, id, ret); return ret; } @@ -137,19 +137,19 @@ void MohawkEngine_Myst::cachePreload(uint32 tag, uint16 id) { for (uint32 i = 0; i < _mhk.size(); i++) { // Check for MJMP in Myst ME if ((getFeatures() & GF_ME) && tag == ID_MSND && _mhk[i]->hasResource(ID_MJMP, id)) { - Common::SeekableReadStream *tempData = _mhk[i]->getRawData(ID_MJMP, id); + Common::SeekableReadStream *tempData = _mhk[i]->getResource(ID_MJMP, id); uint16 msndId = tempData->readUint16LE(); delete tempData; // We've found where the real MSND data is, so go get that - tempData = _mhk[i]->getRawData(tag, msndId); + tempData = _mhk[i]->getResource(tag, msndId); _cache.add(tag, id, tempData); delete tempData; return; } if (_mhk[i]->hasResource(tag, id)) { - Common::SeekableReadStream *tempData = _mhk[i]->getRawData(tag, id); + Common::SeekableReadStream *tempData = _mhk[i]->getResource(tag, id); _cache.add(tag, id, tempData); delete tempData; return; diff --git a/engines/mohawk/resource.cpp b/engines/mohawk/resource.cpp index 899776245d..11e2226847 100644 --- a/engines/mohawk/resource.cpp +++ b/engines/mohawk/resource.cpp @@ -173,6 +173,39 @@ void MohawkArchive::open(Common::SeekableReadStream *stream) { } } +int MohawkArchive::getTypeIndex(uint32 tag) { + for (uint16 i = 0; i < _typeTable.resource_types; i++) + if (_types[i].tag == tag) + return i; + return -1; // not found +} + +int MohawkArchive::getIDIndex(int typeIndex, uint16 id) { + for (uint16 i = 0; i < _types[typeIndex].resTable.resources; i++) + if (_types[typeIndex].resTable.entries[i].id == id) + return i; + return -1; // not found +} + +int MohawkArchive::getIDIndex(int typeIndex, const Common::String &resName) { + int index = -1; + + for (uint16 i = 0; i < _types[typeIndex].nameTable.num; i++) + if (_types[typeIndex].nameTable.entries[i].name.matchString(resName)) { + index = i; + break; + } + + if (index < 0) + return -1; // Not found + + for (uint16 i = 0; i < _types[typeIndex].resTable.resources; i++) + if (_types[typeIndex].resTable.entries[i].index == index) + return i; + + return -1; // Not found +} + bool MohawkArchive::hasResource(uint32 tag, uint16 id) { if (!_mhk) return false; @@ -182,7 +215,19 @@ bool MohawkArchive::hasResource(uint32 tag, uint16 id) { if (typeIndex < 0) return false; - return (getIdIndex(typeIndex, id) >= 0); + return getIDIndex(typeIndex, id) >= 0; +} + +bool MohawkArchive::hasResource(uint32 tag, const Common::String &resName) { + if (!_mhk) + return false; + + int16 typeIndex = getTypeIndex(tag); + + if (typeIndex < 0) + return false; + + return getIDIndex(typeIndex, resName) >= 0; } uint32 MohawkArchive::getOffset(uint32 tag, uint16 id) { @@ -191,25 +236,56 @@ uint32 MohawkArchive::getOffset(uint32 tag, uint16 id) { int16 typeIndex = getTypeIndex(tag); assert(typeIndex >= 0); - int16 idIndex = getIdIndex(typeIndex, id); + int16 idIndex = getIDIndex(typeIndex, id); assert(idIndex >= 0); return _fileTable[_types[typeIndex].resTable.entries[idIndex].index - 1].offset; } -Common::SeekableReadStream *MohawkArchive::getRawData(uint32 tag, uint16 id) { +Common::SeekableReadStream *MohawkArchive::getResource(uint32 tag, uint16 id) { if (!_mhk) - error ("MohawkArchive::getRawData - No File in Use"); + error("MohawkArchive::getResource(): No File in Use"); int16 typeIndex = getTypeIndex(tag); if (typeIndex < 0) - error ("Could not find a tag of \'%s\' in file \'%s\'", tag2str(tag), _curFile.c_str()); + error("Could not find a tag of '%s' in file '%s'", tag2str(tag), _curFile.c_str()); - int16 idIndex = getIdIndex(typeIndex, id); + int16 idIndex = getIDIndex(typeIndex, id); if (idIndex < 0) - error ("Could not find \'%s\' %04x in file \'%s\'", tag2str(tag), id, _curFile.c_str()); + error("Could not find '%s' %04x in file '%s'", tag2str(tag), id, _curFile.c_str()); + + // Note: the fileTableIndex is based off 1, not 0. So, subtract 1 + uint16 fileTableIndex = _types[typeIndex].resTable.entries[idIndex].index - 1; + + // WORKAROUND: tMOV resources pretty much ignore the size part of the file table, + // as the original just passed the full Mohawk file to QuickTime and the offset. + // We need to do this because of the way Mohawk is set up (this is much more "proper" + // than passing _mhk at the right offset). We may want to do that in the future, though. + if (_types[typeIndex].tag == ID_TMOV) { + if (fileTableIndex == _fileTableAmount) + return new Common::SeekableSubReadStream(_mhk, _fileTable[fileTableIndex].offset, _mhk->size()); + else + return new Common::SeekableSubReadStream(_mhk, _fileTable[fileTableIndex].offset, _fileTable[fileTableIndex + 1].offset); + } + + return new Common::SeekableSubReadStream(_mhk, _fileTable[fileTableIndex].offset, _fileTable[fileTableIndex].offset + _fileTable[fileTableIndex].dataSize); +} + +Common::SeekableReadStream *MohawkArchive::getResource(uint32 tag, const Common::String &resName) { + if (!_mhk) + error("MohawkArchive::getResource(): No File in Use"); + + int16 typeIndex = getTypeIndex(tag); + + if (typeIndex < 0) + error("Could not find a tag of '%s' in file '%s'", tag2str(tag), _curFile.c_str()); + + int16 idIndex = getIDIndex(typeIndex, resName); + + if (idIndex < 0) + error("Could not find '%s' '%s' in file '%s'", tag2str(tag), resName.c_str(), _curFile.c_str()); // Note: the fileTableIndex is based off 1, not 0. So, subtract 1 uint16 fileTableIndex = _types[typeIndex].resTable.entries[idIndex].index - 1; @@ -320,27 +396,53 @@ uint32 LivingBooksArchive_v1::getOffset(uint32 tag, uint16 id) { int16 typeIndex = getTypeIndex(tag); assert(typeIndex >= 0); - int16 idIndex = getIdIndex(typeIndex, id); + int16 idIndex = getIDIndex(typeIndex, id); assert(idIndex >= 0); return _types[typeIndex].resTable.entries[idIndex].offset; } -Common::SeekableReadStream *LivingBooksArchive_v1::getRawData(uint32 tag, uint16 id) { +Common::SeekableReadStream *LivingBooksArchive_v1::getResource(uint32 tag, uint16 id) { if (!_mhk) - error ("LivingBooksArchive_v1::getRawData - No File in Use"); + error("LivingBooksArchive_v1::getResource(): No File in Use"); int16 typeIndex = getTypeIndex(tag); if (typeIndex < 0) - error ("Could not find a tag of \'%s\' in file \'%s\'", tag2str(tag), _curFile.c_str()); + error("Could not find a tag of \'%s\' in file \'%s\'", tag2str(tag), _curFile.c_str()); - int16 idIndex = getIdIndex(typeIndex, id); + int16 idIndex = getIDIndex(typeIndex, id); if (idIndex < 0) - error ("Could not find \'%s\' %04x in file \'%s\'", tag2str(tag), id, _curFile.c_str()); + error("Could not find \'%s\' %04x in file \'%s\'", tag2str(tag), id, _curFile.c_str()); return new Common::SeekableSubReadStream(_mhk, _types[typeIndex].resTable.entries[idIndex].offset, _types[typeIndex].resTable.entries[idIndex].offset + _types[typeIndex].resTable.entries[idIndex].size); } +bool LivingBooksArchive_v1::hasResource(uint32 tag, uint16 id) { + if (!_mhk) + return false; + + int16 typeIndex = getTypeIndex(tag); + + if (typeIndex < 0) + return false; + + return getIDIndex(typeIndex, id) >= 0; +} + +int LivingBooksArchive_v1::getTypeIndex(uint32 tag) { + for (uint16 i = 0; i < _typeTable.resource_types; i++) + if (_types[i].tag == tag) + return i; + return -1; // not found +} + +int LivingBooksArchive_v1::getIDIndex(int typeIndex, uint16 id) { + for (uint16 i = 0; i < _types[typeIndex].resTable.resources; i++) + if (_types[typeIndex].resTable.entries[i].id == id) + return i; + return -1; // not found +} + } // End of namespace Mohawk diff --git a/engines/mohawk/resource.h b/engines/mohawk/resource.h index bd63ae7f44..e710cb1b10 100644 --- a/engines/mohawk/resource.h +++ b/engines/mohawk/resource.h @@ -183,8 +183,10 @@ public: virtual void open(Common::SeekableReadStream *stream); void close(); - bool hasResource(uint32 tag, uint16 id); - virtual Common::SeekableReadStream *getRawData(uint32 tag, uint16 id); + virtual bool hasResource(uint32 tag, uint16 id); + virtual bool hasResource(uint32 tag, const Common::String &resName); + virtual Common::SeekableReadStream *getResource(uint32 tag, uint16 id); + virtual Common::SeekableReadStream *getResource(uint32 tag, const Common::String &resName); virtual uint32 getOffset(uint32 tag, uint16 id); protected: @@ -202,19 +204,9 @@ private: uint16 _resourceTableAmount; uint16 _fileTableAmount; - virtual int16 getTypeIndex(uint32 tag) { - for (uint16 i = 0; i < _typeTable.resource_types; i++) - if (_types[i].tag == tag) - return i; - return -1; // not found - } - - virtual int16 getIdIndex(int16 typeIndex, uint16 id) { - for (uint16 i = 0; i < _types[typeIndex].resTable.resources; i++) - if (_types[typeIndex].resTable.entries[i].id == id) - return i; - return -1; // not found - } + int getTypeIndex(uint32 tag); + int getIDIndex(int typeIndex, uint16 id); + int getIDIndex(int typeIndex, const Common::String &resName); }; class LivingBooksArchive_v1 : public MohawkArchive { @@ -222,8 +214,11 @@ public: LivingBooksArchive_v1() : MohawkArchive() {} ~LivingBooksArchive_v1() {} + bool hasResource(uint32 tag, uint16 id); + bool hasResource(uint32 tag, const Common::String &resName) { return false; } void open(Common::SeekableReadStream *stream); - Common::SeekableReadStream *getRawData(uint32 tag, uint16 id); + Common::SeekableReadStream *getResource(uint32 tag, uint16 id); + Common::SeekableReadStream *getResource(uint32 tag, const Common::String &resName) { return 0; } uint32 getOffset(uint32 tag, uint16 id); private: @@ -240,19 +235,8 @@ private: } resTable; } *_types; - int16 getTypeIndex(uint32 tag) { - for (uint16 i = 0; i < _typeTable.resource_types; i++) - if (_types[i].tag == tag) - return i; - return -1; // not found - } - - int16 getIdIndex(int16 typeIndex, uint16 id) { - for (uint16 i = 0; i < _types[typeIndex].resTable.resources; i++) - if (_types[typeIndex].resTable.entries[i].id == id) - return i; - return -1; // not found - } + int getTypeIndex(uint32 tag); + int getIDIndex(int typeIndex, uint16 id); }; } // End of namespace Mohawk diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index 6e292a1a0e..986f753c0e 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -370,7 +370,7 @@ void MohawkEngine_Riven::refreshCard() { void MohawkEngine_Riven::loadCard(uint16 id) { // NOTE: The card scripts are cleared by the RivenScriptManager automatically. - Common::SeekableReadStream* inStream = getRawData(ID_CARD, id); + Common::SeekableReadStream* inStream = getResource(ID_CARD, id); _cardData.name = inStream->readSint16BE(); _cardData.zipModePlace = inStream->readUint16BE(); @@ -397,7 +397,7 @@ void MohawkEngine_Riven::loadHotspots(uint16 id) { // NOTE: The hotspot scripts are cleared by the RivenScriptManager automatically. - Common::SeekableReadStream *inStream = getRawData(ID_HSPT, id); + Common::SeekableReadStream *inStream = getResource(ID_HSPT, id); _hotspotCount = inStream->readUint16BE(); _hotspots = new RivenHotspot[_hotspotCount]; @@ -566,11 +566,11 @@ void MohawkEngine_Riven::checkInventoryClick() { } Common::SeekableReadStream *MohawkEngine_Riven::getExtrasResource(uint32 tag, uint16 id) { - return _extrasFile->getRawData(tag, id); + return _extrasFile->getResource(tag, id); } Common::String MohawkEngine_Riven::getName(uint16 nameResource, uint16 nameID) { - Common::SeekableReadStream* nameStream = getRawData(ID_NAME, nameResource); + Common::SeekableReadStream* nameStream = getResource(ID_NAME, nameResource); uint16 fieldCount = nameStream->readUint16BE(); uint16* stringOffsets = new uint16[fieldCount]; Common::String name; @@ -598,7 +598,7 @@ Common::String MohawkEngine_Riven::getName(uint16 nameResource, uint16 nameID) { uint16 MohawkEngine_Riven::matchRMAPToCard(uint32 rmapCode) { uint16 index = 0; - Common::SeekableReadStream *rmapStream = getRawData(ID_RMAP, 1); + Common::SeekableReadStream *rmapStream = getResource(ID_RMAP, 1); for (uint16 i = 1; rmapStream->pos() < rmapStream->size(); i++) { uint32 code = rmapStream->readUint32BE(); @@ -615,7 +615,7 @@ uint16 MohawkEngine_Riven::matchRMAPToCard(uint32 rmapCode) { } uint32 MohawkEngine_Riven::getCurCardRMAP() { - Common::SeekableReadStream *rmapStream = getRawData(ID_RMAP, 1); + Common::SeekableReadStream *rmapStream = getResource(ID_RMAP, 1); rmapStream->seek(_curCard * 4); uint32 rmapCode = rmapStream->readUint32BE(); delete rmapStream; diff --git a/engines/mohawk/riven_saveload.cpp b/engines/mohawk/riven_saveload.cpp index c63a3f98fb..40062ad27a 100644 --- a/engines/mohawk/riven_saveload.cpp +++ b/engines/mohawk/riven_saveload.cpp @@ -105,7 +105,7 @@ bool RivenSaveLoad::loadGame(Common::String filename) { mhk->open(loadFile); // First, let's make sure we're using a saved game file from this version of Riven by checking the VERS resource - Common::SeekableReadStream *vers = mhk->getRawData(ID_VERS, 1); + Common::SeekableReadStream *vers = mhk->getResource(ID_VERS, 1); uint32 saveGameVersion = vers->readUint32BE(); delete vers; if ((saveGameVersion == kCDSaveGameVersion && (_vm->getFeatures() & GF_DVD)) @@ -116,7 +116,7 @@ bool RivenSaveLoad::loadGame(Common::String filename) { } // Now, we'll read in the variable values. - Common::SeekableReadStream *vars = mhk->getRawData(ID_VARS, 1); + Common::SeekableReadStream *vars = mhk->getResource(ID_VARS, 1); Common::Array<uint32> rawVariables; while (!vars->eos()) { @@ -129,7 +129,7 @@ bool RivenSaveLoad::loadGame(Common::String filename) { // Next, we set the variables based on the name found by the index in the VARS resource. // TODO: Merge with code in mohawk.cpp for loading names? - Common::SeekableReadStream *names = mhk->getRawData(ID_NAME, 1); + Common::SeekableReadStream *names = mhk->getResource(ID_NAME, 1); uint16 namesCount = names->readUint16BE(); uint16 *stringOffsets = new uint16[namesCount]; @@ -183,7 +183,7 @@ bool RivenSaveLoad::loadGame(Common::String filename) { _vm->_zipModeData.clear(); // Finally, we load in zip mode data. - Common::SeekableReadStream *zips = mhk->getRawData(ID_ZIPS, 1); + Common::SeekableReadStream *zips = mhk->getResource(ID_ZIPS, 1); uint16 zipsRecordCount = zips->readUint16BE(); for (uint16 i = 0; i < zipsRecordCount; i++) { ZipMode zip; diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index e70de75bd2..d4eb944660 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -557,7 +557,7 @@ void RivenScript::activateMLSTAndPlay(uint16 op, uint16 argc, uint16 *argv) { // Command 43: activate BLST record (card hotspot enabling lists) void RivenScript::activateBLST(uint16 op, uint16 argc, uint16 *argv) { - Common::SeekableReadStream* blst = _vm->getRawData(ID_BLST, _vm->getCurCard()); + Common::SeekableReadStream* blst = _vm->getResource(ID_BLST, _vm->getCurCard()); uint16 recordCount = blst->readUint16BE(); for (uint16 i = 0; i < recordCount; i++) { @@ -576,7 +576,7 @@ void RivenScript::activateBLST(uint16 op, uint16 argc, uint16 *argv) { // Command 44: activate FLST record (information on which SFXE resource this card should use) void RivenScript::activateFLST(uint16 op, uint16 argc, uint16 *argv) { - Common::SeekableReadStream* flst = _vm->getRawData(ID_FLST, _vm->getCurCard()); + Common::SeekableReadStream* flst = _vm->getResource(ID_FLST, _vm->getCurCard()); uint16 recordCount = flst->readUint16BE(); for (uint16 i = 0; i < recordCount; i++) { diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp index 4a8c923c01..f03fd71005 100644 --- a/engines/mohawk/sound.cpp +++ b/engines/mohawk/sound.cpp @@ -93,23 +93,23 @@ Audio::SoundHandle *Sound::playSound(uint16 id, byte volume, bool loop) { // resource we're looking for. This saves a lot of space from // repeated data. if (_vm->hasResource(ID_MJMP, id)) { - Common::SeekableReadStream *mjmpStream = _vm->getRawData(ID_MJMP, id); + Common::SeekableReadStream *mjmpStream = _vm->getResource(ID_MJMP, id); id = mjmpStream->readUint16LE(); delete mjmpStream; } - audStream = Audio::makeWAVStream(_vm->getRawData(ID_MSND, id), DisposeAfterUse::YES); + audStream = Audio::makeWAVStream(_vm->getResource(ID_MSND, id), DisposeAfterUse::YES); } else - audStream = makeMohawkWaveStream(_vm->getRawData(ID_MSND, id)); + audStream = makeMohawkWaveStream(_vm->getResource(ID_MSND, id)); break; case GType_ZOOMBINI: - audStream = makeMohawkWaveStream(_vm->getRawData(ID_SND, id)); + audStream = makeMohawkWaveStream(_vm->getResource(ID_SND, id)); break; case GType_LIVINGBOOKSV1: - audStream = makeOldMohawkWaveStream(_vm->getRawData(ID_WAV, id)); + audStream = makeOldMohawkWaveStream(_vm->getResource(ID_WAV, id)); break; default: - audStream = makeMohawkWaveStream(_vm->getRawData(ID_TWAV, id)); + audStream = makeMohawkWaveStream(_vm->getResource(ID_TWAV, id)); } if (audStream) { @@ -141,7 +141,7 @@ void Sound::playMidi(uint16 id) { assert(_midiDriver && _midiParser); _midiParser->unloadMusic(); - Common::SeekableReadStream *midi = _vm->getRawData(ID_TMID, id); + Common::SeekableReadStream *midi = _vm->getResource(ID_TMID, id); idTag = midi->readUint32BE(); assert(idTag == ID_MHWK); @@ -177,7 +177,7 @@ byte Sound::convertRivenVolume(uint16 volume) { } void Sound::playSLST(uint16 index, uint16 card) { - Common::SeekableReadStream *slstStream = _vm->getRawData(ID_SLST, card); + Common::SeekableReadStream *slstStream = _vm->getResource(ID_SLST, card); SLSTRecord slstRecord; uint16 recordCount = slstStream->readUint16BE(); @@ -292,7 +292,7 @@ void Sound::playSLSTSound(uint16 id, bool fade, bool loop, uint16 volume, int16 sndHandle.id = id; _currentSLSTSounds.push_back(sndHandle); - Audio::AudioStream *audStream = makeMohawkWaveStream(_vm->getRawData(ID_TWAV, id)); + Audio::AudioStream *audStream = makeMohawkWaveStream(_vm->getResource(ID_TWAV, id)); // Loop here if necessary if (loop) diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp index b7ee4c8a2c..04b880351e 100644 --- a/engines/mohawk/video.cpp +++ b/engines/mohawk/video.cpp @@ -219,7 +219,7 @@ bool VideoManager::updateBackgroundMovies() { } void VideoManager::activateMLST(uint16 mlstId, uint16 card) { - Common::SeekableReadStream *mlstStream = _vm->getRawData(ID_MLST, card); + Common::SeekableReadStream *mlstStream = _vm->getResource(ID_MLST, card); uint16 recordCount = mlstStream->readUint16BE(); for (uint16 i = 0; i < recordCount; i++) { @@ -342,7 +342,7 @@ VideoHandle VideoManager::createVideoHandle(uint16 id, uint16 x, uint16 y, bool entry.loop = loop; entry.enabled = true; entry->setChunkBeginOffset(_vm->getResourceOffset(ID_TMOV, id)); - entry->load(_vm->getRawData(ID_TMOV, id)); + entry->load(_vm->getResource(ID_TMOV, id)); // Search for any deleted videos so we can take a formerly used slot for (uint32 i = 0; i < _videoStreams.size(); i++) |