[Scummvm-cvs-logs] SF.net SVN: scummvm:[54396] scummvm/trunk/engines/mohawk

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Sun Nov 21 00:53:15 CET 2010


Revision: 54396
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54396&view=rev
Author:   mthreepwood
Date:     2010-11-20 23:53:14 +0000 (Sat, 20 Nov 2010)

Log Message:
-----------
MOHAWK: Cleanup resource handling

- Renamed getRawData() to getResource()
- Add a getResource() and hasResource() function for named resources
- Other minor formatting changes

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/console.cpp
    scummvm/trunk/engines/mohawk/graphics.cpp
    scummvm/trunk/engines/mohawk/livingbooks.cpp
    scummvm/trunk/engines/mohawk/mohawk.cpp
    scummvm/trunk/engines/mohawk/mohawk.h
    scummvm/trunk/engines/mohawk/myst.cpp
    scummvm/trunk/engines/mohawk/resource.cpp
    scummvm/trunk/engines/mohawk/resource.h
    scummvm/trunk/engines/mohawk/riven.cpp
    scummvm/trunk/engines/mohawk/riven_saveload.cpp
    scummvm/trunk/engines/mohawk/riven_scripts.cpp
    scummvm/trunk/engines/mohawk/sound.cpp
    scummvm/trunk/engines/mohawk/video.cpp

Modified: scummvm/trunk/engines/mohawk/console.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/console.cpp	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/console.cpp	2010-11-20 23:53:14 UTC (rev 54396)
@@ -502,7 +502,7 @@
 	_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 @@
 	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 @@
 		// 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 @@
 		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();
 

Modified: scummvm/trunk/engines/mohawk/graphics.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.cpp	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/graphics.cpp	2010-11-20 23:53:14 UTC (rev 54396)
@@ -203,7 +203,7 @@
 		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 @@
 			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::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 @@
 }
 
 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::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::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 @@
 	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 @@
 
 		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();
 

Modified: scummvm/trunk/engines/mohawk/livingbooks.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.cpp	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/livingbooks.cpp	2010-11-20 23:53:14 UTC (rev 54396)
@@ -169,7 +169,7 @@
 
 // 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 @@
 }
 
 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);
 }
 

Modified: scummvm/trunk/engines/mohawk/mohawk.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/mohawk.cpp	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/mohawk.cpp	2010-11-20 23:53:14 UTC (rev 54396)
@@ -84,15 +84,24 @@
 	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;
+}
+
 bool MohawkEngine::hasResource(uint32 tag, uint16 id) {
 	for (uint32 i = 0; i < _mhk.size(); i++)
 		if (_mhk[i]->hasResource(tag, id))
@@ -101,12 +110,20 @@
 	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;
 }
 

Modified: scummvm/trunk/engines/mohawk/mohawk.h
===================================================================
--- scummvm/trunk/engines/mohawk/mohawk.h	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/mohawk.h	2010-11-20 23:53:14 UTC (rev 54396)
@@ -99,8 +99,10 @@
 	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();

Modified: scummvm/trunk/engines/mohawk/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst.cpp	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/myst.cpp	2010-11-20 23:53:14 UTC (rev 54396)
@@ -121,7 +121,7 @@
 
 	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 @@
 	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;

Modified: scummvm/trunk/engines/mohawk/resource.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/resource.cpp	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/resource.cpp	2010-11-20 23:53:14 UTC (rev 54396)
@@ -173,6 +173,39 @@
 	}
 }
 
+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,34 +215,46 @@
 	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) {
 	assert(_mhk);
 
 	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;
@@ -228,6 +273,37 @@
 	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;
+
+	// 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);
+}
+
 void LivingBooksArchive_v1::open(Common::SeekableReadStream *stream) {
 	close();
 	_mhk = stream;
@@ -320,27 +396,53 @@
 	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

Modified: scummvm/trunk/engines/mohawk/resource.h
===================================================================
--- scummvm/trunk/engines/mohawk/resource.h	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/resource.h	2010-11-20 23:53:14 UTC (rev 54396)
@@ -183,8 +183,10 @@
 	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 @@
 	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 @@
 	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 @@
 		} 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

Modified: scummvm/trunk/engines/mohawk/riven.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven.cpp	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/riven.cpp	2010-11-20 23:53:14 UTC (rev 54396)
@@ -370,7 +370,7 @@
 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 @@
 	
 	// 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 @@
 }
 
 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 @@
 
 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 @@
 }
 
 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;

Modified: scummvm/trunk/engines/mohawk/riven_saveload.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_saveload.cpp	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/riven_saveload.cpp	2010-11-20 23:53:14 UTC (rev 54396)
@@ -105,7 +105,7 @@
 	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 @@
 	}
 
 	// 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 @@
 
 	// 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 @@
 	_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;

Modified: scummvm/trunk/engines/mohawk/riven_scripts.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_scripts.cpp	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/riven_scripts.cpp	2010-11-20 23:53:14 UTC (rev 54396)
@@ -557,7 +557,7 @@
 
 // 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 @@
 
 // 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++) {

Modified: scummvm/trunk/engines/mohawk/sound.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/sound.cpp	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/sound.cpp	2010-11-20 23:53:14 UTC (rev 54396)
@@ -93,23 +93,23 @@
 			// 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 @@
 	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 @@
 }
 
 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 @@
 	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)

Modified: scummvm/trunk/engines/mohawk/video.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/video.cpp	2010-11-20 19:52:31 UTC (rev 54395)
+++ scummvm/trunk/engines/mohawk/video.cpp	2010-11-20 23:53:14 UTC (rev 54396)
@@ -219,7 +219,7 @@
 }
 
 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 @@
 	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++)


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