diff options
author | Max Horn | 2010-06-15 12:14:39 +0000 |
---|---|---|
committer | Max Horn | 2010-06-15 12:14:39 +0000 |
commit | 07b896802b3d56748c0e33877a325978db0513ff (patch) | |
tree | 0af408240f65655df033c58e1dc41b9c61d16732 | |
parent | bb1336ca415311ed28195b2b7ac574e2244c2cc5 (diff) | |
download | scummvm-rg350-07b896802b3d56748c0e33877a325978db0513ff.tar.gz scummvm-rg350-07b896802b3d56748c0e33877a325978db0513ff.tar.bz2 scummvm-rg350-07b896802b3d56748c0e33877a325978db0513ff.zip |
SCI: Pass volume number to ResourceSource subclass constructors; make ResourceSource::volume_number const
svn-id: r49822
-rw-r--r-- | engines/sci/resource.cpp | 46 | ||||
-rw-r--r-- | engines/sci/resource.h | 4 | ||||
-rw-r--r-- | engines/sci/resource_audio.cpp | 8 | ||||
-rw-r--r-- | engines/sci/resource_intern.h | 32 |
4 files changed, 46 insertions, 44 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 45ee9b3d0f..69bce4f5d5 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -168,11 +168,10 @@ uint32 Resource::getAudioCompressionType() { } -ResourceSource::ResourceSource(ResSourceType type, const Common::String &name) - : _sourceType(type), _name(name) { +ResourceSource::ResourceSource(ResSourceType type, const Common::String &name, int volNum) + : _sourceType(type), _name(name), volume_number(volNum) { scanned = false; _resourceFile = 0; - volume_number = 0; associated_map = NULL; audioCompressionType = 0; audioCompressionOffsetMapping = NULL; @@ -181,8 +180,8 @@ ResourceSource::ResourceSource(ResSourceType type, const Common::String &name) ResourceSource::~ResourceSource() { } -MacResourceForkResourceSource::MacResourceForkResourceSource(const Common::String &name) - : ResourceSource(kSourceMacResourceFork, name) { +MacResourceForkResourceSource::MacResourceForkResourceSource(const Common::String &name, int volNum) + : ResourceSource(kSourceMacResourceFork, name, volNum) { _macResMan = new Common::MacResManager(); assert(_macResMan); } @@ -196,28 +195,24 @@ MacResourceForkResourceSource::~MacResourceForkResourceSource() { // Resource source list management ResourceSource *ResourceManager::addExternalMap(const Common::String &filename, int volume_nr) { - ResourceSource *newsrc = new ExtMapResourceSource(filename); - - newsrc->volume_number = volume_nr; + ResourceSource *newsrc = new ExtMapResourceSource(filename, volume_nr); _sources.push_back(newsrc); return newsrc; } ResourceSource *ResourceManager::addExternalMap(const Common::FSNode *mapFile, int volume_nr) { - ResourceSource *newsrc = new ExtMapResourceSource(mapFile->getName()); + ResourceSource *newsrc = new ExtMapResourceSource(mapFile->getName(), volume_nr); newsrc->_resourceFile = mapFile; - newsrc->volume_number = volume_nr; _sources.push_back(newsrc); return newsrc; } -ResourceSource *ResourceManager::addSource(ResourceSource *newsrc, int number) { +ResourceSource *ResourceManager::addSource(ResourceSource *newsrc) { assert(newsrc); - newsrc->volume_number = number; if (newsrc->getSourceType() == kSourceAudioVolume) { // TODO: Move this call into the AudioVolumeResourceSource constructor. // Need to verify if this is safe, though; in particular, whether this @@ -230,11 +225,10 @@ ResourceSource *ResourceManager::addSource(ResourceSource *newsrc, int number) { return newsrc; } -ResourceSource *ResourceManager::addSource(ResourceSource *newsrc, const Common::FSNode *resFile, int number) { +ResourceSource *ResourceManager::addSource(ResourceSource *newsrc, const Common::FSNode *resFile) { assert(newsrc); newsrc->_resourceFile = resFile; - newsrc->volume_number = number; if (newsrc->getSourceType() == kSourceAudioVolume) { // TODO: Move this call into the AudioVolumeResourceSource constructor. // Need to verify if this is safe, though; in particular, whether this @@ -492,12 +486,12 @@ int ResourceManager::addAppropriateSources() { const char *dot = strrchr(name.c_str(), '.'); int number = atoi(dot + 1); - addSource(new VolumeResourceSource(name, map), number); + addSource(new VolumeResourceSource(name, map, number)); } #ifdef ENABLE_SCI32 // GK1CD hires content if (Common::File::exists("alt.map") && Common::File::exists("resource.alt")) - addSource(new VolumeResourceSource("resource.alt", addExternalMap("alt.map", 10)), 10); + addSource(new VolumeResourceSource("resource.alt", addExternalMap("alt.map", 10), 10)); #endif } else if (Common::File::exists("Data1")) { // Mac SCI1.1+ file naming scheme @@ -505,7 +499,7 @@ int ResourceManager::addAppropriateSources() { for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) { Common::String filename = (*x)->getName(); - addSource(new MacResourceForkResourceSource(filename), atoi(filename.c_str() + 4)); + addSource(new MacResourceForkResourceSource(filename, atoi(filename.c_str() + 4))); } #ifdef ENABLE_SCI32 // Mac SCI32 games have extra folders for patches @@ -517,7 +511,7 @@ int ResourceManager::addAppropriateSources() { // There can also be a "Patches" resource fork with patches if (Common::File::exists("Patches")) - addSource(new MacResourceForkResourceSource("Patches"), 100); + addSource(new MacResourceForkResourceSource("Patches", 100)); } else { // SCI2.1-SCI3 file naming scheme Common::ArchiveMemberList mapFiles; @@ -537,7 +531,7 @@ int ResourceManager::addAppropriateSources() { int resNumber = atoi(strrchr(resName.c_str(), '.') + 1); if (mapNumber == resNumber) { - addSource(new VolumeResourceSource(resName, addExternalMap(mapName, mapNumber)), mapNumber); + addSource(new VolumeResourceSource(resName, addExternalMap(mapName, mapNumber), mapNumber)); break; } } @@ -546,7 +540,7 @@ int ResourceManager::addAppropriateSources() { // SCI2.1 resource patches if (Common::File::exists("resmap.pat") && Common::File::exists("ressci.pat")) { // We add this resource with a map which surely won't exist - addSource(new VolumeResourceSource("ressci.pat", addExternalMap("resmap.pat", 100)), 100); + addSource(new VolumeResourceSource("ressci.pat", addExternalMap("resmap.pat", 100), 100)); } } #else @@ -556,7 +550,7 @@ int ResourceManager::addAppropriateSources() { addPatchDir("."); if (Common::File::exists("message.map")) - addSource(new VolumeResourceSource("resource.msg", addExternalMap("message.map")), 0); + addSource(new VolumeResourceSource("resource.msg", addExternalMap("message.map"), 0)); return 1; } @@ -600,7 +594,7 @@ int ResourceManager::addAppropriateSources(const Common::FSList &fslist) { #ifdef ENABLE_SCI32 if (sci21PatchMap && sci21PatchRes) - addSource(new VolumeResourceSource(sci21PatchRes->getName(), sci21PatchMap), sci21PatchRes, 100); + addSource(new VolumeResourceSource(sci21PatchRes->getName(), sci21PatchMap, 100), sci21PatchRes); #endif // Now find all the resource.0?? files @@ -615,7 +609,7 @@ int ResourceManager::addAppropriateSources(const Common::FSList &fslist) { const char *dot = strrchr(filename.c_str(), '.'); int number = atoi(dot + 1); - addSource(new VolumeResourceSource(file->getName(), map), file, number); + addSource(new VolumeResourceSource(file->getName(), map, number), file); } } @@ -630,12 +624,12 @@ int ResourceManager::addInternalSources() { Common::List<ResourceId>::iterator itr = resources->begin(); while (itr != resources->end()) { - ResourceSource *src = addSource(new IntMapResourceSource("MAP"), itr->number); + ResourceSource *src = addSource(new IntMapResourceSource("MAP", itr->number)); if ((itr->number == 65535) && Common::File::exists("RESOURCE.SFX")) - addSource(new AudioVolumeResourceSource("RESOURCE.SFX", src), 0); + addSource(new AudioVolumeResourceSource("RESOURCE.SFX", src, 0)); else if (Common::File::exists("RESOURCE.AUD")) - addSource(new AudioVolumeResourceSource("RESOURCE.AUD", src), 0); + addSource(new AudioVolumeResourceSource("RESOURCE.AUD", src, 0)); ++itr; } diff --git a/engines/sci/resource.h b/engines/sci/resource.h index 6d37455f52..bddcbffae7 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -339,9 +339,9 @@ protected: * @param source The new source to add * @return A pointer to the added source structure, or NULL if an error occurred. */ - ResourceSource *addSource(ResourceSource *source, int number); + ResourceSource *addSource(ResourceSource *source); - ResourceSource *addSource(ResourceSource *source, const Common::FSNode *resFile, int number); + ResourceSource *addSource(ResourceSource *source, const Common::FSNode *resFile); /** * Add an external (i.e., separate file) map resource to the resource manager's list of sources. diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp index d94c7d010a..cbd713c906 100644 --- a/engines/sci/resource_audio.cpp +++ b/engines/sci/resource_audio.cpp @@ -33,6 +33,10 @@ namespace Sci { +AudioVolumeResourceSource::AudioVolumeResourceSource(const Common::String &name, ResourceSource *map, int volNum) + : VolumeResourceSource(name, map, volNum, kSourceAudioVolume) { +} + void ResourceManager::checkIfAudioVolumeIsCompressed(ResourceSource *source) { Common::SeekableReadStream *fileStream = getVolumeFile(source); @@ -433,7 +437,7 @@ void ResourceManager::setAudioLanguage(int language) { return; } - _audioMapSCI1 = addSource(new ExtAudioMapResourceSource(fullname), language); + _audioMapSCI1 = addSource(new ExtAudioMapResourceSource(fullname, language)); // Search for audio volumes for this language and add them to the source list Common::ArchiveMemberList files; @@ -443,7 +447,7 @@ void ResourceManager::setAudioLanguage(int language) { const char *dot = strrchr(name.c_str(), '.'); int number = atoi(dot + 1); - addSource(new AudioVolumeResourceSource(name, _audioMapSCI1), number); + addSource(new AudioVolumeResourceSource(name, _audioMapSCI1, number)); } scanNewSources(); diff --git a/engines/sci/resource_intern.h b/engines/sci/resource_intern.h index 560e99ac80..52f47aca8b 100644 --- a/engines/sci/resource_intern.h +++ b/engines/sci/resource_intern.h @@ -55,13 +55,13 @@ protected: public: bool scanned; const Common::FSNode *_resourceFile; - int volume_number; + const int volume_number; ResourceSource *associated_map; // TODO: Move to VolumeResourceSource uint32 audioCompressionType; // TODO: Move to AudioVolumeResourceSource int32 *audioCompressionOffsetMapping; // TODO: Move to AudioVolumeResourceSource protected: - ResourceSource(ResSourceType type, const Common::String &name); + ResourceSource(ResSourceType type, const Common::String &name, int volNum = 0); public: virtual ~ResourceSource(); @@ -74,7 +74,7 @@ public: /** * TODO: Document this */ - virtual ResourceSource *findVolume(ResourceSource *map, int volume_nr) { + virtual ResourceSource *findVolume(ResourceSource *map, int volNum) { return NULL; }; @@ -107,13 +107,13 @@ public: class VolumeResourceSource : public ResourceSource { public: - VolumeResourceSource(const Common::String &name, ResourceSource *map, ResSourceType type = kSourceVolume) - : ResourceSource(type, name) { + VolumeResourceSource(const Common::String &name, ResourceSource *map, int volNum, ResSourceType type = kSourceVolume) + : ResourceSource(type, name, volNum) { associated_map = map; } - virtual ResourceSource *findVolume(ResourceSource *map, int volume_nr) { - if (associated_map == map && volume_number == volume_nr) + virtual ResourceSource *findVolume(ResourceSource *map, int volNum) { + if (associated_map == map && volume_number == volNum) return this; return NULL; }; @@ -121,30 +121,34 @@ public: class ExtMapResourceSource : public ResourceSource { public: - ExtMapResourceSource(const Common::String &name) : ResourceSource(kSourceExtMap, name) {} + ExtMapResourceSource(const Common::String &name, int volNum) + : ResourceSource(kSourceExtMap, name, volNum) { + } virtual void scanSource(ResourceManager *resMan); }; class IntMapResourceSource : public ResourceSource { public: - IntMapResourceSource(const Common::String &name) : ResourceSource(kSourceIntMap, name) {} + IntMapResourceSource(const Common::String &name, int volNum) + : ResourceSource(kSourceIntMap, name, volNum) { + } virtual void scanSource(ResourceManager *resMan); }; class AudioVolumeResourceSource : public VolumeResourceSource { public: - AudioVolumeResourceSource(const Common::String &name, ResourceSource *map) - : VolumeResourceSource(name, map, kSourceAudioVolume) { - } + AudioVolumeResourceSource(const Common::String &name, ResourceSource *map, int volNum); virtual void loadResource(Resource *res, ResourceManager *resMan); }; class ExtAudioMapResourceSource : public ResourceSource { public: - ExtAudioMapResourceSource(const Common::String &name) : ResourceSource(kSourceExtAudioMap, name) {} + ExtAudioMapResourceSource(const Common::String &name, int volNum) + : ResourceSource(kSourceExtAudioMap, name, volNum) { + } virtual void scanSource(ResourceManager *resMan); }; @@ -161,7 +165,7 @@ protected: Common::MacResManager *_macResMan; public: - MacResourceForkResourceSource(const Common::String &name); + MacResourceForkResourceSource(const Common::String &name, int volNum); ~MacResourceForkResourceSource(); /** |