diff options
author | Max Horn | 2010-06-15 12:17:05 +0000 |
---|---|---|
committer | Max Horn | 2010-06-15 12:17:05 +0000 |
commit | 6248daccfc636533ad294df7739b00c0f011f2e3 (patch) | |
tree | a7d0312be2813da96ec546b202d737de9f4fed55 | |
parent | 88663c9186e5a4282f5553ad401b340db51164c2 (diff) | |
download | scummvm-rg350-6248daccfc636533ad294df7739b00c0f011f2e3.tar.gz scummvm-rg350-6248daccfc636533ad294df7739b00c0f011f2e3.tar.bz2 scummvm-rg350-6248daccfc636533ad294df7739b00c0f011f2e3.zip |
SCI: Get rid of ugly resMan params to ResourceSource methods
We might want to add a ResourceSource::_resMan member, but for
now I am not adding one on purpose; many more things might still
move between ResourceSource and ResourceManager, so we should
wait till the refactoring is complete.
svn-id: r49828
-rw-r--r-- | engines/sci/resource.cpp | 45 | ||||
-rw-r--r-- | engines/sci/resource_intern.h | 26 |
2 files changed, 40 insertions, 31 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index fcff177262..7d6835a336 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -315,21 +315,23 @@ Common::SeekableReadStream *ResourceManager::getVolumeFile(ResourceSource *sourc static uint32 resTypeToMacTag(ResourceType type); void ResourceManager::loadResource(Resource *res) { - res->_source->loadResource(res, this); + res->_source->loadResource(res); } -void PatchResourceSource::loadResource(Resource *res, ResourceManager *resMan) { +void PatchResourceSource::loadResource(Resource *res) { + ResourceManager *resMan = g_sci->getResMan(); bool result = resMan->loadFromPatchFile(res); if (!result) { // TODO: We used to fallback to the "default" code here if loadFromPatchFile // failed, but I am not sure whether that is really appropriate. // In fact it looks like a bug to me, so I commented this out for now. - //ResourceSource::loadResource(res, resMan); + //ResourceSource::loadResource(res); } } -void MacResourceForkResourceSource::loadResource(Resource *res, ResourceManager *resMan) { +void MacResourceForkResourceSource::loadResource(Resource *res) { + ResourceManager *resMan = g_sci->getResMan(); Common::SeekableReadStream *stream = _macResMan->getResource(resTypeToMacTag(res->_id.type), res->_id.number); if (!stream) @@ -343,7 +345,8 @@ void MacResourceForkResourceSource::loadResource(Resource *res, ResourceManager } } -Common::SeekableReadStream *ResourceSource::getVolumeFile(Resource *res, ResourceManager *resMan) { +Common::SeekableReadStream *ResourceSource::getVolumeFile(Resource *res) { + ResourceManager *resMan = g_sci->getResMan(); Common::SeekableReadStream *fileStream = resMan->getVolumeFile(this); if (!fileStream) { @@ -354,8 +357,9 @@ Common::SeekableReadStream *ResourceSource::getVolumeFile(Resource *res, Resourc return fileStream; } -void WaveResourceSource::loadResource(Resource *res, ResourceManager *resMan) { - Common::SeekableReadStream *fileStream = getVolumeFile(res, resMan); +void WaveResourceSource::loadResource(Resource *res) { + ResourceManager *resMan = g_sci->getResMan(); + Common::SeekableReadStream *fileStream = getVolumeFile(res); if (!fileStream) return; @@ -365,8 +369,9 @@ void WaveResourceSource::loadResource(Resource *res, ResourceManager *resMan) { delete fileStream; } -void AudioVolumeResourceSource::loadResource(Resource *res, ResourceManager *resMan) { - Common::SeekableReadStream *fileStream = getVolumeFile(res, resMan); +void AudioVolumeResourceSource::loadResource(Resource *res) { + ResourceManager *resMan = g_sci->getResMan(); + Common::SeekableReadStream *fileStream = getVolumeFile(res); if (!fileStream) return; @@ -423,8 +428,9 @@ void AudioVolumeResourceSource::loadResource(Resource *res, ResourceManager *res delete fileStream; } -void ResourceSource::loadResource(Resource *res, ResourceManager *resMan) { - Common::SeekableReadStream *fileStream = getVolumeFile(res, resMan); +void ResourceSource::loadResource(Resource *res) { + ResourceManager *resMan = g_sci->getResMan(); + Common::SeekableReadStream *fileStream = getVolumeFile(res); if (!fileStream) return; @@ -616,12 +622,13 @@ void ResourceManager::scanNewSources() { if (!source->_scanned) { source->_scanned = true; - source->scanSource(this); + source->scanSource(); } } } -void DirectoryResourceSource::scanSource(ResourceManager *resMan) { +void DirectoryResourceSource::scanSource() { + ResourceManager *resMan = g_sci->getResMan(); resMan->readResourcePatches(this); // We can't use getSciVersion() at this point, thus using _volVersion @@ -631,18 +638,21 @@ void DirectoryResourceSource::scanSource(ResourceManager *resMan) { resMan->readWaveAudioPatches(); } -void ExtMapResourceSource::scanSource(ResourceManager *resMan) { +void ExtMapResourceSource::scanSource() { + ResourceManager *resMan = g_sci->getResMan(); if (resMan->_mapVersion < ResourceManager::kResVersionSci1Late) resMan->readResourceMapSCI0(this); else resMan->readResourceMapSCI1(this); } -void ExtAudioMapResourceSource::scanSource(ResourceManager *resMan) { +void ExtAudioMapResourceSource::scanSource() { + ResourceManager *resMan = g_sci->getResMan(); resMan->readAudioMapSCI1(this); } -void IntMapResourceSource::scanSource(ResourceManager *resMan) { +void IntMapResourceSource::scanSource() { + ResourceManager *resMan = g_sci->getResMan(); resMan->readAudioMapSCI11(this); } @@ -1447,7 +1457,8 @@ static uint32 resTypeToMacTag(ResourceType type) { return 0; } -void MacResourceForkResourceSource::scanSource(ResourceManager *resMan) { +void MacResourceForkResourceSource::scanSource() { + ResourceManager *resMan = g_sci->getResMan(); if (!_macResMan->open(getLocationName().c_str())) error("%s is not a valid Mac resource fork", getLocationName().c_str()); diff --git a/engines/sci/resource_intern.h b/engines/sci/resource_intern.h index f2853951fa..ce5e3ac0e6 100644 --- a/engines/sci/resource_intern.h +++ b/engines/sci/resource_intern.h @@ -69,7 +69,7 @@ public: const Common::String &getLocationName() const { return _name; } // Auxiliary method, used by loadResource implementations. - Common::SeekableReadStream *getVolumeFile(Resource *res, ResourceManager *resMan); + Common::SeekableReadStream *getVolumeFile(Resource *res); /** * TODO: Document this @@ -80,29 +80,27 @@ public: /** * Scan this source for TODO. - * TODO: The resMan param for now is just a hack. */ - virtual void scanSource(ResourceManager *resMan) {} + virtual void scanSource() {} /** * Load a resource. - * TODO: The resMan param for now is just a hack. */ - virtual void loadResource(Resource *res, ResourceManager *resMan); + virtual void loadResource(Resource *res); }; class DirectoryResourceSource : public ResourceSource { public: DirectoryResourceSource(const Common::String &name) : ResourceSource(kSourceDirectory, name) {} - virtual void scanSource(ResourceManager *resMan); + virtual void scanSource(); }; class PatchResourceSource : public ResourceSource { public: PatchResourceSource(const Common::String &name) : ResourceSource(kSourcePatch, name) {} - virtual void loadResource(Resource *res, ResourceManager *resMan); + virtual void loadResource(Resource *res); }; class VolumeResourceSource : public ResourceSource { @@ -130,7 +128,7 @@ public: : ResourceSource(kSourceExtMap, name, volNum, resFile) { } - virtual void scanSource(ResourceManager *resMan); + virtual void scanSource(); }; class IntMapResourceSource : public ResourceSource { @@ -139,14 +137,14 @@ public: : ResourceSource(kSourceIntMap, name, volNum) { } - virtual void scanSource(ResourceManager *resMan); + virtual void scanSource(); }; class AudioVolumeResourceSource : public VolumeResourceSource { public: AudioVolumeResourceSource(const Common::String &name, ResourceSource *map, int volNum); - virtual void loadResource(Resource *res, ResourceManager *resMan); + virtual void loadResource(Resource *res); }; class ExtAudioMapResourceSource : public ResourceSource { @@ -155,14 +153,14 @@ public: : ResourceSource(kSourceExtAudioMap, name, volNum) { } - virtual void scanSource(ResourceManager *resMan); + virtual void scanSource(); }; class WaveResourceSource : public ResourceSource { public: WaveResourceSource(const Common::String &name) : ResourceSource(kSourceWave, name) {} - virtual void loadResource(Resource *res, ResourceManager *resMan); + virtual void loadResource(Resource *res); }; class MacResourceForkResourceSource : public ResourceSource { @@ -176,9 +174,9 @@ public: /** * Reads the SCI1.1+ resource file from a Mac resource fork. */ - virtual void scanSource(ResourceManager *resMan); + virtual void scanSource(); - virtual void loadResource(Resource *res, ResourceManager *resMan); + virtual void loadResource(Resource *res); }; } // End of namespace Sci |