From cc6c7e33bff84f12512d01058c3f5a384ff36c83 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 22 Nov 2010 17:50:30 +0000 Subject: MOHAWK: Switch slider bitmap ID's to matching via string; fixes some versions svn-id: r54416 --- engines/mohawk/resource.cpp | 47 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 32 deletions(-) (limited to 'engines/mohawk/resource.cpp') diff --git a/engines/mohawk/resource.cpp b/engines/mohawk/resource.cpp index 1ae069e459..e9e1c6b792 100644 --- a/engines/mohawk/resource.cpp +++ b/engines/mohawk/resource.cpp @@ -192,7 +192,7 @@ int MohawkArchive::getIDIndex(int typeIndex, const Common::String &resName) { for (uint16 i = 0; i < _types[typeIndex].nameTable.num; i++) if (_types[typeIndex].nameTable.entries[i].name.matchString(resName)) { - index = i; + index = _types[typeIndex].nameTable.entries[i].index; break; } @@ -206,6 +206,20 @@ int MohawkArchive::getIDIndex(int typeIndex, const Common::String &resName) { return -1; // Not found } +uint16 MohawkArchive::findResourceID(uint32 type, const Common::String &resName) { + int typeIndex = getTypeIndex(type); + + if (typeIndex < 0) + return 0xFFFF; + + int idIndex = getIDIndex(typeIndex, resName); + + if (idIndex < 0) + return 0xFFFF; + + return _types[typeIndex].resTable.entries[idIndex].id; +} + bool MohawkArchive::hasResource(uint32 tag, uint16 id) { if (!_mhk) return false; @@ -273,37 +287,6 @@ Common::SeekableReadStream *MohawkArchive::getResource(uint32 tag, uint16 id) { 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; -- cgit v1.2.3