[Scummvm-cvs-logs] CVS: scummvm/bs2/driver d_sound.cpp,1.11,1.12

Jonathan Gray khalek at users.sourceforge.net
Tue Aug 26 23:34:04 CEST 2003


Update of /cvsroot/scummvm/scummvm/bs2/driver
In directory sc8-pr-cvs1:/tmp/cvs-serv7205/driver

Modified Files:
	d_sound.cpp 
Log Message:
use file class for speech so people with clusters in different directories get to hear sound as well

Index: d_sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/driver/d_sound.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- d_sound.cpp	27 Aug 2003 00:48:55 -0000	1.11
+++ d_sound.cpp	27 Aug 2003 06:32:42 -0000	1.12
@@ -359,6 +359,7 @@
 #include "driver96.h"
 #include "rdwin.h"			// for hwnd.
 #include "d_sound.h"
+#include "../sword2.h"
 
 // Decompression macros
 #define MakeCompressedByte(shift,sign,amplitude) (((shift)<<4) + ((sign)<<3) + (amplitude))
@@ -982,7 +983,7 @@
 	uint8			*data8;
 	uint32			speechIndex[2];
 	void 			*lpv1;
-	FILE		   *fp;
+	File fp;
 	uint32	bufferSize;
 	
 	if (!speechMuted)
@@ -991,25 +992,26 @@
 			return RDERR_SPEECHPLAYING;
 
 	    //  Open the speech cluster and find the data offset & size
-		fp = fopen(filename, "rb");
-		if (fp == NULL) 
+		if (fp.open(filename, g_sword2->getGameDataPath()) == false)
 			return(RDERR_INVALIDFILENAME);
-		
-		if (fseek(fp, (++speechid) * 8, SEEK_SET))
+	/*	FIXME ? our fseek returns void not int
+		if (fp.seek((++speechid) * 8, SEEK_SET))
 		{
-			fclose(fp);
+			fp.close();
 			return (RDERR_READERROR);
 		}
-
-		if (fread(speechIndex, sizeof(uint32), 2, fp) != 2)
+	*/
+		fp.seek((++speechid) * 8, SEEK_SET);
+		
+		if (fp.read(speechIndex, sizeof(uint32) * 2) != (2 * sizeof(uint32)))
 		{
-			fclose(fp);
+			fp.close();
 			return (RDERR_READERROR);
 		}
 
 		if (speechIndex[0] == 0 || speechIndex[1] == 0)
 		{
-			fclose(fp);
+			fp.close();
 			return (RDERR_INVALIDID);
 		}
 
@@ -1018,25 +1020,27 @@
 		// Create tempory buffer for compressed speech
 		if ((data8 = (uint8 *)malloc(speechIndex[1])) == NULL)
 		{
-			fclose(fp);
+			fp.close();
 			return(RDERR_OUTOFMEMORY);
 		}
-
-		if (fseek(fp, speechIndex[0], SEEK_SET))
+	/* FIXME ? see above
+		if (fp.seek(speechIndex[0], SEEK_SET))
 		{
-			fclose(fp);
+			fp.close();
 			free(data8);
 			return (RDERR_INVALIDID);
 		}
+	*/
+		fp.seek(speechIndex[0], SEEK_SET);
 
-		if (fread(data8, sizeof(uint8), speechIndex[1], fp) != speechIndex[1])
+		if (fp.read(data8, sizeof(uint8) * speechIndex[1]) != (speechIndex[1] * sizeof(uint8)))
 		{
-			fclose(fp);
+			fp.close();
 			free(data8);
 			return (RDERR_INVALIDID);
 		}
 
-		fclose(fp);
+		fp.close();
 
 		//	Create the speech sample buffer
 		/*





More information about the Scummvm-git-logs mailing list