aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/director/resource.cpp13
-rw-r--r--engines/director/resource.h23
2 files changed, 29 insertions, 7 deletions
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index 1c4bd33a19..2c0b478053 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -155,6 +155,13 @@ Common::Array<uint16> Archive::getResourceIDList(uint32 type) const {
return idList;
}
+uint32 Archive::convertTagToUppercase(uint32 tag) {
+ uint32 newTag = toupper(tag >> 24) << 24;
+ newTag |= toupper((tag >> 16) & 0xFF) << 16;
+ newTag |= toupper((tag >> 8) & 0xFF) << 8;
+ return newTag | toupper(tag & 0xFF);
+}
+
// Mac Archive code
MacArchive::MacArchive() : Archive(), _resFork(0) {
@@ -212,15 +219,15 @@ Common::SeekableReadStream *MacArchive::getResource(uint32 tag, uint16 id) {
bool RIFFArchive::openStream(Common::SeekableReadStream *stream) {
close();
- if (stream->readUint32BE() != MKTAG('R', 'I', 'F', 'F'))
+ if (convertTagToUppercase(stream->readUint32BE()) != MKTAG('R', 'I', 'F', 'F'))
return false;
stream->readUint32LE(); // size
- if (stream->readUint32BE() != MKTAG('R', 'M', 'M', 'P'))
+ if (convertTagToUppercase(stream->readUint32BE()) != MKTAG('R', 'M', 'M', 'P'))
return false;
- if (stream->readUint32BE() != MKTAG('C', 'F', 'T', 'C'))
+ if (convertTagToUppercase(stream->readUint32BE()) != MKTAG('C', 'F', 'T', 'C'))
return false;
uint32 cftcSize = stream->readUint32LE();
diff --git a/engines/director/resource.h b/engines/director/resource.h
index 055abe98f0..0068912a23 100644
--- a/engines/director/resource.h
+++ b/engines/director/resource.h
@@ -20,15 +20,16 @@
*
*/
+#ifndef DIRECTOR_RESOURCE_H
+#define DIRECTOR_RESOURCE_H
+
#include "common/scummsys.h"
#include "common/endian.h"
+#include "common/func.h"
#include "common/hashmap.h"
#include "common/file.h"
#include "common/str.h"
-#ifndef DIRECTOR_RESOURCE_H
-#define DIRECTOR_RESOURCE_H
-
namespace Common {
class MacResManager;
}
@@ -58,6 +59,8 @@ public:
Common::Array<uint32> getResourceTypeList() const;
Common::Array<uint16> getResourceIDList(uint32 type) const;
+ static uint32 convertTagToUppercase(uint32 tag);
+
protected:
Common::SeekableReadStream *_stream;
@@ -67,8 +70,20 @@ protected:
Common::String name;
};
+ // Have separate hash/equals functions for tags to make them
+ // case-insensitive.
+ struct HashTag : public Common::UnaryFunction<uint32, uint> { // Insert Twitter joke
+ uint operator()(uint32 val) const { return (uint)Archive::convertTagToUppercase(val); }
+ };
+
+ struct EqualsTag : public Common::BinaryFunction<uint32, uint32, uint> {
+ bool operator()(const uint32 &val1, const uint32 &val2) const {
+ return Archive::convertTagToUppercase(val1) == Archive::convertTagToUppercase(val2);
+ }
+ };
+
typedef Common::HashMap<uint16, Resource> ResourceMap;
- typedef Common::HashMap<uint32, ResourceMap> TypeMap;
+ typedef Common::HashMap<uint32, ResourceMap, HashTag, EqualsTag> TypeMap;
TypeMap _types;
};