aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMax Horn2010-06-15 12:12:44 +0000
committerMax Horn2010-06-15 12:12:44 +0000
commitd15e09fdc27a2a65857ab0d7fa42c923470021ae (patch)
tree009cae57d73b75e6ef95e7906aa3e02d1b8861a2 /engines/sci
parent055ee6ab5b51c0e0fbaa8e6e9e66850ac48504aa (diff)
downloadscummvm-rg350-d15e09fdc27a2a65857ab0d7fa42c923470021ae.tar.gz
scummvm-rg350-d15e09fdc27a2a65857ab0d7fa42c923470021ae.tar.bz2
scummvm-rg350-d15e09fdc27a2a65857ab0d7fa42c923470021ae.zip
SCI: Merge MacResourceForkResourceSource::scanSource and ResourceManager::readMacResourceFork
svn-id: r49817
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/resource.cpp28
-rw-r--r--engines/sci/resource.h13
-rw-r--r--engines/sci/resource_intern.h3
3 files changed, 19 insertions, 25 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 74f99ecd03..4f6b557ea4 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -653,10 +653,6 @@ void IntMapResourceSource::scanSource(ResourceManager *resMan) {
resMan->readAudioMapSCI11(this);
}
-void MacResourceForkResourceSource::scanSource(ResourceManager *resMan) {
- resMan->readMacResourceFork(this);
-}
-
void ResourceManager::freeResourceSources() {
for (Common::List<ResourceSource *>::iterator it = _sources.begin(); it != _sources.end(); ++it)
@@ -1465,12 +1461,12 @@ static uint32 resTypeToMacTag(ResourceType type) {
return 0;
}
-int ResourceManager::readMacResourceFork(ResourceSource *source) {
- assert(source->_macResMan);
- if (!source->_macResMan->open(source->getLocationName().c_str()))
- error("%s is not a valid Mac resource fork", source->getLocationName().c_str());
+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());
- Common::MacResTagArray tagArray = source->_macResMan->getResTagArray();
+ Common::MacResTagArray tagArray = _macResMan->getResTagArray();
for (uint32 i = 0; i < tagArray.size(); i++) {
ResourceType type = kResourceTypeInvalid;
@@ -1485,11 +1481,11 @@ int ResourceManager::readMacResourceFork(ResourceSource *source) {
if (type == kResourceTypeInvalid)
continue;
- Common::MacResIDArray idArray = source->_macResMan->getResIDArray(tagArray[i]);
+ Common::MacResIDArray idArray = _macResMan->getResIDArray(tagArray[i]);
for (uint32 j = 0; j < idArray.size(); j++) {
// Get the size of the file
- Common::SeekableReadStream *stream = source->_macResMan->getResource(tagArray[i], idArray[j]);
+ Common::SeekableReadStream *stream = _macResMan->getResource(tagArray[i], idArray[j]);
// Some IBIS resources have a size of 0, so we skip them
if (!stream)
@@ -1503,22 +1499,20 @@ int ResourceManager::readMacResourceFork(ResourceSource *source) {
Resource *newrsc = NULL;
// Prepare destination, if neccessary. Resource forks may contain patches.
- if (!_resMap.contains(resId)) {
+ if (!resMan->_resMap.contains(resId)) {
newrsc = new Resource;
- _resMap.setVal(resId, newrsc);
+ resMan->_resMap.setVal(resId, newrsc);
} else
- newrsc = _resMap.getVal(resId);
+ newrsc = resMan->_resMap.getVal(resId);
// Overwrite everything
newrsc->_id = resId;
newrsc->_status = kResStatusNoMalloc;
- newrsc->_source = source;
+ newrsc->_source = this;
newrsc->size = fileSize;
newrsc->_headerSize = 0;
}
}
-
- return 0;
}
void ResourceManager::addResource(ResourceId resId, ResourceSource *src, uint32 offset, uint32 size) {
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index 8720e8eabb..fa5d757def 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -163,6 +163,11 @@ struct ResourceIdLess : public Common::BinaryFunction<ResourceId, ResourceId, bo
/** Class for storing resources in memory */
class Resource {
friend class ResourceManager;
+
+ // FIXME: These 'friend' declarations are meant to be a temporary hack to
+ // ease transition to the ResourceSource class system.
+ friend class MacResourceForkResourceSource;
+
public:
Resource();
~Resource();
@@ -196,7 +201,6 @@ typedef Common::HashMap<ResourceId, Resource *, ResourceIdHash, ResourceIdEqualT
class ResourceManager {
// FIXME: These 'friend' declarations are meant to be a temporary hack to
// ease transition to the ResourceSource class system.
- friend class ResourceSource;
friend class DirectoryResourceSource;
friend class ExtMapResourceSource;
friend class IntMapResourceSource;
@@ -407,13 +411,6 @@ protected:
int readResourceMapSCI1(ResourceSource *map);
/**
- * Reads the SCI1.1+ resource file from a Mac resource fork.
- * @param source The source
- * @return 0 on success, an SCI_ERROR_* code otherwise
- */
- int readMacResourceFork(ResourceSource *source);
-
- /**
* Reads SCI1.1 audio map resources
* @param map The map
* @return 0 on success, an SCI_ERROR_* code otherwise
diff --git a/engines/sci/resource_intern.h b/engines/sci/resource_intern.h
index fc07572cea..617977c3dc 100644
--- a/engines/sci/resource_intern.h
+++ b/engines/sci/resource_intern.h
@@ -143,6 +143,9 @@ class MacResourceForkResourceSource : public ResourceSource {
public:
MacResourceForkResourceSource(const Common::String &name) : ResourceSource(kSourceMacResourceFork, name) {}
+ /**
+ * Reads the SCI1.1+ resource file from a Mac resource fork.
+ */
virtual void scanSource(ResourceManager *resMan);
};