[Scummvm-cvs-logs] SF.net SVN: scummvm:[54179] scummvm/trunk/engines/sci/resource.cpp

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Wed Nov 10 04:34:08 CET 2010


Revision: 54179
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54179&view=rev
Author:   mthreepwood
Date:     2010-11-10 03:34:08 +0000 (Wed, 10 Nov 2010)

Log Message:
-----------
SCI: Fix SCI2.1+ fallback detection

Each map has to be mapped with its own specific volume (as opposed to earlier versions that had one map for all volumes); this code was passing the same map pointer for all volumes.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/resource.cpp

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2010-11-10 01:08:17 UTC (rev 54178)
+++ scummvm/trunk/engines/sci/resource.cpp	2010-11-10 03:34:08 UTC (rev 54179)
@@ -587,6 +587,8 @@
 
 int ResourceManager::addAppropriateSources(const Common::FSList &fslist) {
 	ResourceSource *map = 0;
+	Common::Array<ResourceSource *> sci21Maps;
+
 #ifdef ENABLE_SCI32
 	ResourceSource *sci21PatchMap = 0;
 	const Common::FSNode *sci21PatchRes = 0;
@@ -605,8 +607,13 @@
 
 		if (filename.contains("resmap.0")) {
 			const char *dot = strrchr(file->getName().c_str(), '.');
-			int number = atoi(dot + 1);
-			map = addExternalMap(file, number);
+			uint number = atoi(dot + 1);
+
+			// We need to store each of these maps for use later on
+			if (number >= sci21Maps.size())
+				sci21Maps.resize(number + 1);
+
+			sci21Maps[number] = addExternalMap(file, number);
 		}
 
 #ifdef ENABLE_SCI32
@@ -619,7 +626,7 @@
 #endif
 	}
 
-	if (!map)
+	if (!map && sci21Maps.empty())
 		return 0;
 
 #ifdef ENABLE_SCI32
@@ -635,11 +642,17 @@
 		Common::String filename = file->getName();
 		filename.toLowercase();
 
-		if (filename.contains("resource.0")	|| filename.contains("ressci.0")) {
+		if (filename.contains("resource.0")) {
 			const char *dot = strrchr(filename.c_str(), '.');
 			int number = atoi(dot + 1);
 
 			addSource(new VolumeResourceSource(file->getName(), map, number, file));
+		} else if (filename.contains("ressci.0")) {
+			const char *dot = strrchr(filename.c_str(), '.');
+			int number = atoi(dot + 1);
+
+			// Match this volume to its own map
+			addSource(new VolumeResourceSource(file->getName(), sci21Maps[number], number, file));
 		}
 	}
 
@@ -1146,7 +1159,7 @@
 
 	for (Common::List<ResourceSource *>::iterator it = _sources.begin(); it != _sources.end(); ++it) {
 		rsrc = *it;
-
+	
 		if (rsrc->getSourceType() == kSourceVolume) {
 			if (rsrc->_resourceFile) {
 				fileStream = rsrc->_resourceFile->createReadStream();
@@ -1593,11 +1606,9 @@
 			// the actual resource file.
 			int mapVolumeNr = volume_nr + map->_volumeNumber;
 			ResourceSource *source = findVolume(map, mapVolumeNr);
-			// FIXME: this code has serious issues with multiple RESMAP.* files (like in unmodified gk2)
-			//         adding a resource with source == NULL would crash later on
-			if (!source)
-				error("Unable to find volume for map %s volumeNr %d", map->getLocationName().c_str(), mapVolumeNr);
 
+			assert(source);
+
 			Resource *resource = _resMap.getVal(resId, NULL);
 			if (!resource) {
 				addResource(resId, source, fileOffset);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list