[Scummvm-cvs-logs] CVS: scummvm/queen display.cpp,1.37,1.38 resource.cpp,1.34,1.35 resource.h,1.25,1.26 sound.cpp,1.25,1.26 talk.cpp,1.61,1.62 talk.h,1.24,1.25

Gregory Montoir cyx at users.sourceforge.net
Mon Dec 29 05:19:03 CET 2003


Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv17310/queen

Modified Files:
	display.cpp resource.cpp resource.h sound.cpp talk.cpp talk.h 
Log Message:
- hack to read patched .dog files (french & italian versions) from game data path instead of data file
- cleanup Resource a bit (add an accessor for ResourceEntry in order to avoid multiple calls to resourceIndex)


Index: display.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/display.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- display.cpp	26 Dec 2003 15:36:28 -0000	1.37
+++ display.cpp	29 Dec 2003 13:18:23 -0000	1.38
@@ -155,12 +155,12 @@
 		char filename[20];
 
 		sprintf(filename, "%s.msk", roomName);
-		_dynalum.valid = _vm->resource()->exists(filename);
+		_dynalum.valid = _vm->resource()->fileExists(filename);
 		if (_dynalum.valid)
 			_vm->resource()->loadFile(filename, 0, (uint8*)_dynalum.msk);
 
 		sprintf(filename, "%s.lum", roomName);
-		_dynalum.valid = _vm->resource()->exists(filename);
+		_dynalum.valid = _vm->resource()->fileExists(filename);
 		if (_dynalum.valid)
 			_vm->resource()->loadFile(filename, 0, (uint8*)_dynalum.lum);
 	}

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/resource.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- resource.cpp	28 Dec 2003 15:29:05 -0000	1.34
+++ resource.cpp	29 Dec 2003 13:18:23 -0000	1.35
@@ -103,6 +103,14 @@
 	return -1;
 }
 
+ResourceEntry *Resource::resourceEntry(const char *filename) const {
+	int32 index = resourceIndex(filename);
+	if (index >= 0)
+		return &_resourceTable[index];
+	else 
+		return NULL;
+}
+
 char *Resource::getJAS2Line() {
 	char *startOfLine = _JAS2Ptr + _JAS2Pos;
 	char *curPos = startOfLine;
@@ -114,11 +122,12 @@
 }
 
 uint8 *Resource::loadFile(const char *filename, uint32 skipBytes, byte *dstBuf) {
-	uint32 size = fileSize(filename) - skipBytes;
-	if (dstBuf == NULL) 
+	ResourceEntry *re = resourceEntry(filename);
+	assert(re != NULL);
+	uint32 size = re->size - skipBytes;
+	if (dstBuf == NULL)
 		dstBuf = new byte[size];
-	// skip 'skipBytes' bytes (useful for headers)
-	_resourceFile->seek(fileOffset(filename) + skipBytes, SEEK_SET);
+	_resourceFile->seek(re->offset + skipBytes);
 	_resourceFile->read(dstBuf, size);
 	return dstBuf;
 }
@@ -164,14 +173,14 @@
 }
 
 void Resource::checkJASVersion() {
-	int32 offset = fileOffset("QUEEN.JAS");
+	int32 offset = resourceEntry("QUEEN.JAS")->offset;
 	if (isDemo())
 		offset += JAS_VERSION_OFFSET_DEMO;
 	else if (isInterview())
 		offset += JAS_VERSION_OFFSET_INTV;
 	else 
 		offset += JAS_VERSION_OFFSET;
-	_resourceFile->seek(offset, SEEK_SET);
+	_resourceFile->seek(offset);
 
 	char versionStr[6];
 	_resourceFile->read(versionStr, 6);
@@ -246,7 +255,7 @@
 
 File *Resource::giveCompressedSound(const char *filename) {
 	assert(strstr(filename, ".SB"));
-	_resourceFile->seek(fileOffset(filename), SEEK_SET);
+	_resourceFile->seek(resourceEntry(filename)->offset);
 	return _resourceFile;
 }
 

Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/resource.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- resource.h	28 Dec 2003 21:18:03 -0000	1.25
+++ resource.h	29 Dec 2003 13:18:23 -0000	1.26
@@ -70,9 +70,8 @@
 
 	uint8 *loadFile(const char *filename, uint32 skipBytes = 0, byte *dstBuf = NULL);
 	uint8 *loadFileMalloc(const char *filename, uint32 skipBytes = 0, byte *dstBuf = NULL);
-	bool exists(const char *filename) const { return resourceIndex(filename) >= 0; }
-	uint32 fileSize(const char *filename) const { return _resourceTable[resourceIndex(filename)].size; }
-	uint32 fileOffset(const char *filename) const { return _resourceTable[resourceIndex(filename)].offset; }
+	bool fileExists(const char *filename) const { return resourceEntry(filename) != NULL; }
+	uint32 fileSize(const char *filename) const { return resourceEntry(filename)->size; }
 
 	File *giveCompressedSound(const char *filename);
 
@@ -109,6 +108,7 @@
 	bool findCompressedVersion();
 	void checkJASVersion();
 	int32 resourceIndex(const char *filename) const;
+	ResourceEntry *resourceEntry(const char *filename) const;
 	bool readTableFile(const GameVersion *gameVersion);
 	void readTableCompResource();
 	void readTableEntries(File *file);

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/sound.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- sound.cpp	28 Dec 2003 01:47:37 -0000	1.25
+++ sound.cpp	29 Dec 2003 13:18:23 -0000	1.26
@@ -147,14 +147,14 @@
 
 void SBSound::sfxPlay(const char *name) {
 	waitSfxFinished();	
-	if (_vm->resource()->exists(name)) 
+	if (_vm->resource()->fileExists(name)) 
 		playSound(_vm->resource()->loadFileMalloc(name, SB_HEADER_SIZE), _vm->resource()->fileSize(name) - SB_HEADER_SIZE);
 }
 
 #ifdef USE_MAD
 void MP3Sound::sfxPlay(const char *name) {
 	waitSfxFinished();
-	if (_vm->resource()->exists(name)) 
+	if (_vm->resource()->fileExists(name)) 
 		_mixer->playMP3(&_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name));
 }
 #endif
@@ -162,7 +162,7 @@
 #ifdef USE_VORBIS
 void OGGSound::sfxPlay(const char *name) {
 	waitSfxFinished();	
-	if (_vm->resource()->exists(name))
+	if (_vm->resource()->fileExists(name))
 		_mixer->playVorbis(&_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name));
 }
 #endif

Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- talk.cpp	20 Dec 2003 16:54:46 -0000	1.61
+++ talk.cpp	29 Dec 2003 13:18:24 -0000	1.62
@@ -31,6 +31,8 @@
 #include "queen/sound.h"
 #include "queen/state.h"
 
+#include "common/file.h"
+
 namespace Queen {
 
 /*
@@ -378,10 +380,37 @@
 		warning("Failed to find string with ID %i", id);
 }
 
+byte *Talk::loadDialogFile(const char *filename) {
+	static const struct {
+		const char *filename;
+		Language lang;
+	} dogFiles[] = {
+		{ "chief1.dog", FRENCH  },
+		{ "chief2.dog", FRENCH  },
+		{ "bud1.dog",   ITALIAN }
+	};	
+	for (int i = 0; i < ARRAYSIZE(dogFiles); ++i) {
+		if (!scumm_stricmp(filename, dogFiles[i].filename) &&
+			_vm->resource()->getLanguage() == dogFiles[i].lang) {
+			File fdog;
+			fdog.open(filename, _vm->getGameDataPath());
+			if (fdog.isOpen()) {
+				debug(0, "Loading dog file '%s' from game data path", filename);
+				uint32 size = fdog.size() - DOG_HEADER_SIZE;
+				byte *buf = new byte[size];
+				fdog.seek(DOG_HEADER_SIZE);
+				fdog.read(buf, size);
+				return buf;
+			}
+		}
+	}
+	return _vm->resource()->loadFile(filename, DOG_HEADER_SIZE);
+}
+
 void Talk::load(const char *filename) {
 	int i;
 	
-	byte *ptr = _fileData = _vm->resource()->loadFile(filename, 20);
+	byte *ptr = _fileData = loadDialogFile(filename);
 	if (!_fileData) {
 		error("Failed to load resource data file '%s'", filename);
 	}

Index: talk.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- talk.h	11 Dec 2003 22:16:35 -0000	1.24
+++ talk.h	29 Dec 2003 13:18:24 -0000	1.25
@@ -60,7 +60,8 @@
 	  ARROW_BOB_UP = 62,
 	  ARROW_BOB_DOWN = 63,
 	  ARROW_ZONE_UP   = 5,
-	  ARROW_ZONE_DOWN = 6
+	  ARROW_ZONE_DOWN = 6,
+	  DOG_HEADER_SIZE = 20
 	};
 
 	//! Special commands for speech
@@ -152,6 +153,8 @@
 
 	//! Perform talk in file and return a cutaway filename
 	void talk(const char *filename, int personInRoom, char *cutawayFilename);
+
+	byte *loadDialogFile(const char *filename);
 
 	//! Load talk data from .dog file 
 	void load(const char *filename);





More information about the Scummvm-git-logs mailing list