[Scummvm-cvs-logs] CVS: scummvm/saga game.cpp,1.86,1.87 rscfile.cpp,1.28,1.29 rscfile.h,1.13,1.14 sndres.cpp,1.48,1.49

Andrew Kurushin h00ligan at users.sourceforge.net
Sat Jul 30 10:31:04 CEST 2005


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

Modified Files:
	game.cpp rscfile.cpp rscfile.h sndres.cpp 
Log Message:
added Patch.re_ support

Index: game.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/game.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- game.cpp	29 Jul 2005 19:44:25 -0000	1.86
+++ game.cpp	30 Jul 2005 17:28:58 -0000	1.87
@@ -601,7 +601,7 @@
 	{"musicfm.res", GAME_MUSICFILE_FM},
 	{"musicgm.res", GAME_MUSICFILE_GM},
 	{"scream.res", GAME_RESOURCEFILE},
-	{"patch.re_", GAME_PATCHFILE},
+	{"patch.re_", GAME_PATCHFILE | GAME_RESOURCEFILE},
 	{"scripts.res", GAME_SCRIPTFILE},
 	{"sfx.res", GAME_SOUNDFILE},
 	{"voicess.res", GAME_VOICEFILE}, //order of voice bank file is important
@@ -619,7 +619,7 @@
 	{"musicgm.res", GAME_MUSICFILE_GM},
 	{"scream.res", GAME_RESOURCEFILE},
 	{"scripts.res", GAME_SCRIPTFILE},
-	{"patch.re_", GAME_PATCHFILE},
+	{"patch.re_", GAME_PATCHFILE | GAME_RESOURCEFILE},
 	{"sfx.res", GAME_SOUNDFILE},
 	{"voicess.res", GAME_VOICEFILE}, //order of voice bank file is important
 	{"voices1.res", GAME_VOICEFILE},

Index: rscfile.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/rscfile.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- rscfile.cpp	29 Jul 2005 17:57:59 -0000	1.28
+++ rscfile.cpp	30 Jul 2005 17:28:58 -0000	1.29
@@ -48,6 +48,11 @@
 	ResourceData *resourceData;
 	byte *tableBuffer;
 	size_t tableSize;
+	uint16 subjectResourceType;
+	ResourceContext *subjectContext;
+	uint32 subjectResourceId;
+	uint32 patchResourceId;
+	ResourceData *subjectResourceData;
 
 	if (!context->file->open(context->fileName)) {
 		return false;
@@ -103,7 +108,29 @@
 
 	free(tableBuffer);
 
-	//process patch files
+	//process internal patch files
+	if (GAME_PATCHFILE & context->fileType) {
+		subjectResourceType = ~GAME_PATCHFILE & context->fileType;
+		subjectContext = getContext(subjectResourceType);
+		if (subjectContext == NULL) {
+			error("Resource::loadContext() Subject context not found");
+		}
+		loadResource(context, context->count - 1, tableBuffer, tableSize);
+
+		MemoryReadStreamEndian readS2(tableBuffer, tableSize, context->isBigEndian);
+		for (i = 0; i < tableSize / 8; i++) {
+			subjectResourceId = readS2.readUint32();
+			patchResourceId = readS2.readUint32();
+			subjectResourceData = getResourceData(subjectContext, subjectResourceId);
+			resourceData = getResourceData(context, patchResourceId);
+			subjectResourceData->patchData = new PatchData(context->file);
+			subjectResourceData->offset = resourceData->offset;
+			subjectResourceData->size = resourceData->size;
+		}
+
+	}
+
+	//process external patch files
 	if (result) {
 		for (j = 0; j < _vm->getGameDescription()->patchsCount; j++) {
 			patchDescription = &_vm->getGameDescription()->patchDescriptions[j];

Index: rscfile.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/rscfile.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- rscfile.h	26 Jul 2005 19:40:58 -0000	1.13
+++ rscfile.h	30 Jul 2005 17:28:58 -0000	1.14
@@ -36,18 +36,21 @@
 
 #define RSC_MIN_FILESIZE (RSC_TABLEINFO_SIZE + RSC_TABLEENTRY_SIZE + 1)
 
-//TODO: good PATCH.RE_ support
-
 struct PatchData {
+	bool _deletePatchFile;
 	Common::File *_patchFile;
 	GamePatchDescription *_patchDescription;
 	
-	PatchData(GamePatchDescription *patchDescription): _patchDescription(patchDescription) {
+	PatchData(GamePatchDescription *patchDescription): _patchDescription(patchDescription), _deletePatchFile(true) {
 		_patchFile = new Common::File();
 	}
+	PatchData(Common::File *patchFile): _patchDescription(NULL), _patchFile(patchFile), _deletePatchFile(false) {
+	}
 
 	~PatchData() {
-		delete _patchFile;
+		if (_deletePatchFile) {
+			delete _patchFile;
+		}
 	}
 };
 
@@ -55,6 +58,15 @@
 	size_t offset;
 	size_t size;
 	PatchData *patchData;
+	void fillSoundPatch(const GameSoundInfo *&soundInfo) {
+		if (patchData != NULL) {
+			if (patchData->_patchDescription != NULL) {
+				if (patchData->_patchDescription->soundInfo != NULL) {
+					soundInfo = patchData->_patchDescription->soundInfo;
+				}
+			}
+		}
+	}
 };
 
 struct ResourceContext {

Index: sndres.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sndres.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- sndres.cpp	29 Jul 2005 17:58:00 -0000	1.48
+++ sndres.cpp	30 Jul 2005 17:28:58 -0000	1.49
@@ -116,11 +116,8 @@
 	} else {
 		soundInfo = _vm->getSfxInfo();
 	}
-	if (context->table[resourceId].patchData != NULL) {
-		if (context->table[resourceId].patchData->_patchDescription->soundInfo != NULL) {
-			soundInfo = context->table[resourceId].patchData->_patchDescription->soundInfo;
-		}
-	}
+	
+	context->table[resourceId].fillSoundPatch(soundInfo);
 
 	MemoryReadStream readS(soundResource, soundResourceLength);
 





More information about the Scummvm-git-logs mailing list