[Scummvm-cvs-logs] CVS: scummvm/saga rscfile.cpp,1.25,1.26 rscfile.h,1.11,1.12

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Sat Jul 23 08:25:45 CEST 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14211

Modified Files:
	rscfile.cpp rscfile.h 
Log Message:
Allow multiple resource contexts of the same type. IHNM has serveral
different voice files, presumably one for each section of the game plus one
for shared voices. The getContext() function takes an optional second
parameter to indicate which of the resource files is requested.


Index: rscfile.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/rscfile.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- rscfile.cpp	19 Jul 2005 21:34:46 -0000	1.25
+++ rscfile.cpp	23 Jul 2005 15:23:01 -0000	1.26
@@ -133,7 +133,7 @@
 }
 
 bool Resource::createContexts() {
-	int i, j;
+	int i;
 	ResourceContext *context;
 	_contextsCount = _vm->getGameDescription()->filesCount;
 	_contexts = (ResourceContext*)calloc(_contextsCount, sizeof(*_contexts));
@@ -143,11 +143,18 @@
 		context->file = new Common::File();
 		context->fileName = _vm->getGameDescription()->filesDescriptions[i].fileName;
 		context->fileType = _vm->getGameDescription()->filesDescriptions[i].fileType;
+		context->serial = 0;
 
-		//self check
-		for (j = 0; j < i; j++) {
-			if ((_contexts[j].fileType & context->fileType) != 0) {
-				error("Resource::createContexts() duplicate fileType");
+		// IHNM has serveral different voice files, so we need to allow
+		// multiple resource contexts of the same type. We tell them
+		// apart by assigning each of the duplicates an unique serial
+		// number. The default behaviour when requesting a context will
+		// be to look for serial number 0.
+
+		for (int j = i - 1; j >= 0; j--) {
+			if (_contexts[j].fileType & context->fileType) {
+				context->serial = _contexts[j].serial + 1;
+				break;
 			}
 		}
 		

Index: rscfile.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/rscfile.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- rscfile.h	19 Jul 2005 19:05:47 -0000	1.11
+++ rscfile.h	23 Jul 2005 15:23:01 -0000	1.12
@@ -48,6 +48,7 @@
 	const char *fileName;
 	uint16 fileType;
 	Common::File *file;
+	int serial;
 
 	bool isBigEndian;
 	ResourceData *table;
@@ -72,10 +73,10 @@
 	size_t getResourceSize(ResourceContext *context, uint32 resourceId);
 	uint32 convertResourceId(uint32 resourceId);
 
-	ResourceContext *getContext(uint16 fileType) {
+	ResourceContext *getContext(uint16 fileType, int serial = 0) {
 		int i;
 		for (i = 0; i < _contextsCount; i++) {
-			if (_contexts[i].fileType & fileType) {
+			if ((_contexts[i].fileType & fileType) && _contexts[i].serial == serial) {
 				return &_contexts[i];
 			}
 		}





More information about the Scummvm-git-logs mailing list