aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/resource.cpp38
-rw-r--r--engines/sci/resource.h3
-rw-r--r--engines/sci/resource_intern.h12
3 files changed, 35 insertions, 18 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index ad4daab005..35e0c93d59 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -176,7 +176,6 @@ ResourceSource::ResourceSource(ResSourceType type, const Common::String &name)
associated_map = NULL;
audioCompressionType = 0;
audioCompressionOffsetMapping = NULL;
- _macResMan = NULL;
}
ResourceSource::~ResourceSource() {
@@ -185,6 +184,7 @@ ResourceSource::~ResourceSource() {
MacResourceForkResourceSource::MacResourceForkResourceSource(const Common::String &name)
: ResourceSource(kSourceMacResourceFork, name) {
_macResMan = new Common::MacResManager();
+ assert(_macResMan);
}
MacResourceForkResourceSource::~MacResourceForkResourceSource() {
@@ -351,27 +351,32 @@ void ResourceManager::loadResource(Resource *res) {
res->_source->loadResource(res, this);
}
-void ResourceSource::loadResource(Resource *res, ResourceManager *resMan) {
- if (getSourceType() == kSourcePatch && resMan->loadFromPatchFile(res))
- return;
+void PatchResourceSource::loadResource(Resource *res, ResourceManager *resMan) {
+ 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);
+ }
+}
- if (getSourceType() == kSourceMacResourceFork) {
- assert(_macResMan);
- Common::SeekableReadStream *stream = _macResMan->getResource(resTypeToMacTag(res->_id.type), res->_id.number);
+void MacResourceForkResourceSource::loadResource(Resource *res, ResourceManager *resMan) {
+ Common::SeekableReadStream *stream = _macResMan->getResource(resTypeToMacTag(res->_id.type), res->_id.number);
- if (!stream)
- error("Could not get Mac resource fork resource: %d %d", res->_id.type, res->_id.number);
+ if (!stream)
+ error("Could not get Mac resource fork resource: %d %d", res->_id.type, res->_id.number);
- int error = resMan->decompress(res, stream);
- if (error) {
- warning("Error %d occured while reading %s from Mac resource file: %s",
- error, res->_id.toString().c_str(), sci_error_types[error]);
- res->unalloc();
- }
- return;
+ int error = resMan->decompress(res, stream);
+ if (error) {
+ warning("Error %d occured while reading %s from Mac resource file: %s",
+ error, res->_id.toString().c_str(), sci_error_types[error]);
+ res->unalloc();
}
+}
+void ResourceSource::loadResource(Resource *res, ResourceManager *resMan) {
Common::SeekableReadStream *fileStream = resMan->getVolumeFile(this);
if (!fileStream) {
@@ -1471,7 +1476,6 @@ static uint32 resTypeToMacTag(ResourceType type) {
}
void MacResourceForkResourceSource::scanSource(ResourceManager *resMan) {
- assert(_macResMan);
if (!_macResMan->open(getLocationName().c_str()))
error("%s is not a valid Mac resource fork", getLocationName().c_str());
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index 89af97df7e..ff848d24b2 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -204,9 +204,12 @@ class ResourceManager {
// ease transition to the ResourceSource class system.
friend class ResourceSource;
friend class DirectoryResourceSource;
+ friend class PatchResourceSource;
friend class ExtMapResourceSource;
friend class IntMapResourceSource;
+ friend class AudioVolumeResourceSource;
friend class ExtAudioMapResourceSource;
+ friend class WaveResourceSource;
friend class MacResourceForkResourceSource;
public:
diff --git a/engines/sci/resource_intern.h b/engines/sci/resource_intern.h
index 5c63436b1b..3d51e0ae02 100644
--- a/engines/sci/resource_intern.h
+++ b/engines/sci/resource_intern.h
@@ -59,7 +59,6 @@ public:
ResourceSource *associated_map; // TODO: Move to VolumeResourceSource
uint32 audioCompressionType; // TODO: Move to AudioVolumeResourceSource
int32 *audioCompressionOffsetMapping; // TODO: Move to AudioVolumeResourceSource
- Common::MacResManager *_macResMan; // TODO: Move to MacResourceForkResourceSource
protected:
ResourceSource(ResSourceType type, const Common::String &name);
@@ -99,6 +98,8 @@ public:
class PatchResourceSource : public ResourceSource {
public:
PatchResourceSource(const Common::String &name) : ResourceSource(kSourcePatch, name) {}
+
+ virtual void loadResource(Resource *res, ResourceManager *resMan);
};
class VolumeResourceSource : public ResourceSource {
@@ -134,6 +135,8 @@ public:
AudioVolumeResourceSource(const Common::String &name, ResourceSource *map)
: VolumeResourceSource(name, map, kSourceAudioVolume) {
}
+
+ //virtual void loadResource(Resource *res, ResourceManager *resMan);
};
class ExtAudioMapResourceSource : public ResourceSource {
@@ -146,9 +149,14 @@ public:
class WaveResourceSource : public ResourceSource {
public:
WaveResourceSource(const Common::String &name) : ResourceSource(kSourceWave, name) {}
+
+ //virtual void loadResource(Resource *res, ResourceManager *resMan);
};
class MacResourceForkResourceSource : public ResourceSource {
+protected:
+ Common::MacResManager *_macResMan;
+
public:
MacResourceForkResourceSource(const Common::String &name);
~MacResourceForkResourceSource();
@@ -157,6 +165,8 @@ public:
* Reads the SCI1.1+ resource file from a Mac resource fork.
*/
virtual void scanSource(ResourceManager *resMan);
+
+ virtual void loadResource(Resource *res, ResourceManager *resMan);
};
} // End of namespace Sci