diff options
author | Colin Snover | 2017-05-07 23:55:36 -0500 |
---|---|---|
committer | Colin Snover | 2017-05-08 11:26:46 -0500 |
commit | 130c9ecbb81f0c078d1cd54f790ee0071d7af752 (patch) | |
tree | b9eb44df05c5dba46637f796cc5627efc4af1eaf | |
parent | c9cbb8e31cba794259905a1c2263d8a3d6d63b9b (diff) | |
download | scummvm-rg350-130c9ecbb81f0c078d1cd54f790ee0071d7af752.tar.gz scummvm-rg350-130c9ecbb81f0c078d1cd54f790ee0071d7af752.tar.bz2 scummvm-rg350-130c9ecbb81f0c078d1cd54f790ee0071d7af752.zip |
SCI: Fix some issues with ChunkResourceSource
1. The chunk number was hard-coded to zero and inaccessible.
2. Running ResourceManager::getVolumeFile for a chunk resource
would always return nullptr instead of a stream of the chunk,
which made it impossible to generically validate that resources
being added were within bounds of the container file (or, in
this case, container chunk).
-rw-r--r-- | engines/sci/resource.cpp | 10 | ||||
-rw-r--r-- | engines/sci/resource_intern.h | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 9a53627df3..0846b93d04 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -345,6 +345,14 @@ Common::SeekableReadStream *ResourceManager::getVolumeFile(ResourceSource *sourc Common::List<Common::File *>::iterator it = _volumeFiles.begin(); Common::File *file; +#ifdef ENABLE_SCI32 + ChunkResourceSource *chunkSource = dynamic_cast<ChunkResourceSource *>(source); + if (chunkSource != nullptr) { + Resource *res = findResource(ResourceId(kResourceTypeChunk, chunkSource->getNumber()), false); + return res ? res->makeStream() : nullptr; + } +#endif + if (source->_resourceFile) return source->_resourceFile->createReadStream(); @@ -843,7 +851,7 @@ void IntMapResourceSource::scanSource(ResourceManager *resMan) { ChunkResourceSource::ChunkResourceSource(const Common::String &name, uint16 number) : ResourceSource(kSourceChunk, name) { - _number = 0; + _number = number; } void ChunkResourceSource::scanSource(ResourceManager *resMan) { diff --git a/engines/sci/resource_intern.h b/engines/sci/resource_intern.h index fe4b0a97f4..f198eddeb3 100644 --- a/engines/sci/resource_intern.h +++ b/engines/sci/resource_intern.h @@ -204,6 +204,8 @@ public: virtual void scanSource(ResourceManager *resMan); virtual void loadResource(ResourceManager *resMan, Resource *res); + uint16 getNumber() const { return _number; } + protected: uint16 _number; |