[Scummvm-cvs-logs] CVS: scummvm/sword2/driver animation.cpp,1.6,1.7 animation.h,1.8,1.9

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Wed Jan 14 00:15:01 CET 2004


Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1:/tmp/cvs-serv9004/driver

Modified Files:
	animation.cpp animation.h 
Log Message:
I wanted to Valgrind the cutscene code, so I had to fix the warnings about
uninitialized values. Now the only warnings I got were from libmpeg2
itself, and I don't know how serious that is.

I've also added some code - disabled by default - to allow the cutscenes to
run with libmpeg 0.3.1, since that's what I've got on my Linux box. It
appears to work on that one, though I only have the "eye" cutscene on it
yet.

Ogg Vorbis playback is still broken for me under Windows, though. I wonder
if it is because I don't have the very latest Ogg Vorbis libraries on it
(since I didn't manage to compile them under MinGW). But surely the file
format hasn't changed in any important way...?


Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/animation.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- animation.cpp	13 Jan 2004 14:22:29 -0000	1.6
+++ animation.cpp	14 Jan 2004 08:14:25 -0000	1.7
@@ -25,7 +25,6 @@
 #include "sword2/driver/menu.h"
 #include "sword2/driver/render.h"
 
-
 #include "common/file.h"
 
 namespace Sword2 {
@@ -37,7 +36,8 @@
 AnimationState::~AnimationState() {
 #ifdef USE_MPEG2
 	_vm->_mixer->stopHandle(bgSound);
-	mpeg2_close(decoder);
+	if (decoder)
+		mpeg2_close(decoder);
 	delete mpgfile;
 	delete sndfile;
 #endif
@@ -49,8 +49,12 @@
 	char basename[512], tempFile[512];
   	int i, p;
 
+	decoder = NULL;
+	mpgfile = NULL;
+	sndfile = NULL;
+
 	strcpy(basename, name);
-	basename[strlen(basename)-4] = 0;	// FIXME: hack to remove extension
+	basename[strlen(basename) - 4] = 0;	// FIXME: hack to remove extension
 
 	// Load lookup palettes
 	// TODO: Binary format so we can use File class
@@ -64,8 +68,9 @@
 
 	p = 0;
 	while (!feof(f)) {
-		fscanf(f, "%i %i", &palettes[p].end, &palettes[p].cnt);
-  		for (i = 0; i < palettes[p].cnt; i++) {
+		if (fscanf(f, "%i %i", &palettes[p].end, &palettes[p].cnt) != 2)
+			break;
+		for (i = 0; i < palettes[p].cnt; i++) {
   			int r, g, b;
   			fscanf(f, "%i", &r);
   			fscanf(f, "%i", &g);
@@ -73,12 +78,20 @@
 			palettes[p].pal[4 * i] = r;
 			palettes[p].pal[4 * i + 1] = g;
 			palettes[p].pal[4 * i + 2] = b;
+			palettes[p].pal[4 * i + 3] = 0;
+		}
+		for (; i < 256; i++) {
+			palettes[p].pal[4 * i] = 0;
+			palettes[p].pal[4 * i + 1] = 0;
+			palettes[p].pal[4 * i + 2] = 0;
+			palettes[p].pal[4 * i + 3] = 0;
 		}
 		p++;
 	}
 	fclose(f);
 
 	palnum = 0;
+	maxPalnum = p;
 	_vm->_graphics->setPalette(0, 256, palettes[palnum].pal, RDPAL_INSTANT);
 	lut = lut2 = lookup[0];
 	curpal = -1;
@@ -131,6 +144,9 @@
 void AnimationState::buildLookup(int p, int lines) {
 	int y, cb;
 	int r, g, b, ii;
+
+	if (p >= maxPalnum)
+		return;
   
 	if (p != curpal) {
 		curpal = p;

Index: animation.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/animation.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- animation.h	13 Jan 2004 14:22:29 -0000	1.8
+++ animation.h	14 Jan 2004 08:14:25 -0000	1.9
@@ -22,13 +22,24 @@
 #ifndef ANIMATION_H
 #define ANIMATION_H
 
+// Uncomment this if you are using libmpeg2 0.3.1.
+// #define USE_MPEG2_0_3_1
+
 #ifndef _MSC_VER
 #include <inttypes.h>
 #endif
+
 #ifdef USE_MPEG2
 extern "C" {
 	#include <mpeg2dec/mpeg2.h>
 }
+
+#ifdef USE_MPEG2_0_3_1
+typedef int mpeg2_state_t;
+typedef sequence_t mpeg2_sequence_t;
+#define STATE_BUFFER -1
+#endif
+
 #endif
 
 namespace Sword2 {
@@ -46,6 +57,7 @@
 	Sword2Engine *_vm;
 
 	int palnum;
+	int maxPalnum;
 
 	byte lookup[2][BITDEPTH * BITDEPTH * BITDEPTH];
 	byte *lut;





More information about the Scummvm-git-logs mailing list