diff options
author | Walter van Niftrik | 2009-06-07 02:18:38 +0000 |
---|---|---|
committer | Walter van Niftrik | 2009-06-07 02:18:38 +0000 |
commit | e3d3195a43db521a16c2a0badc126bd8f43a8399 (patch) | |
tree | 830ff1430ad011a475422c563605410ef720aa10 /engines/sci/resource.h | |
parent | 77f114ffcbeb1b4a3df4cd99b93e3f5caef2a574 (diff) | |
download | scummvm-rg350-e3d3195a43db521a16c2a0badc126bd8f43a8399.tar.gz scummvm-rg350-e3d3195a43db521a16c2a0badc126bd8f43a8399.tar.bz2 scummvm-rg350-e3d3195a43db521a16c2a0badc126bd8f43a8399.zip |
SCI: Resmgr cleanup and preparations for moving resource36 handling into resmgr.
svn-id: r41318
Diffstat (limited to 'engines/sci/resource.h')
-rw-r--r-- | engines/sci/resource.h | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/engines/sci/resource.h b/engines/sci/resource.h index 219979b383..211e160144 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -141,6 +141,38 @@ struct ResourceSource { class ResourceManager; +class ResourceId { +public: + ResourceType type; + uint16 number; + uint32 tuple; // Only used for audio36 and sync36 + + ResourceId() : type(kResourceTypeInvalid), number(0), tuple(0) { }; + ResourceId(ResourceType type_, uint16 number_, uint32 tuple_ = 0) : type(type_), number(number_), tuple(tuple_) { } + + Common::String toString() { + char buf[32]; + + snprintf(buf, 32, "%s.%i", getResourceTypeName(type), number); + Common::String retStr = buf; + + if (tuple != 0) { + snprintf(buf, 32, "(%i, %i, %i, %i)", tuple >> 24, (tuple >> 16) & 0xff, (tuple >> 8) & 0xff, tuple & 0xff); + retStr += buf; + } + + return retStr; + } +}; + +struct ResourceIdHash : public Common::UnaryFunction<ResourceId, uint> { + uint operator()(ResourceId val) const { return ((uint)((val.type << 16) | val.number)) ^ val.tuple; } +}; + +struct ResourceIdEqualTo : public Common::BinaryFunction<ResourceId, ResourceId, bool> { + bool operator()(const ResourceId &x, const ResourceId &y) const { return (x.type == y.type) && (x.number == y.number) && (x.tuple == y.tuple); } +}; + /** Class for storing resources in memory */ class Resource { friend class ResourceManager; @@ -153,9 +185,7 @@ public: // to let the rest of the engine compile without changes public: byte *data; - uint16 number; - ResourceType type; - uint32 id; //!< contains number and type. + ResourceId id; uint32 size; byte *header; uint32 headerSize; @@ -166,6 +196,7 @@ protected: ResourceSource *source; }; +typedef Common::HashMap<ResourceId, Resource *, ResourceIdHash, ResourceIdEqualTo> ResourceMap; class ResourceManager { public: @@ -223,7 +254,7 @@ protected: int _memoryLocked; //!< Amount of resource bytes in locked memory int _memoryLRU; //!< Amount of resource bytes under LRU control Common::List<Resource *> _LRU; //!< Last Resource Used list - Common::HashMap<uint32, Resource *> _resMap; + ResourceMap _resMap; Common::List<Common::File *> _volumeFiles; //!< list of opened volume files /** |