[Scummvm-cvs-logs] CVS: scummvm/saga animation.cpp,1.35,1.36 animation.h,1.18,1.19

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Mon Jan 3 09:40:13 CET 2005


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

Modified Files:
	animation.cpp animation.h 
Log Message:
Fixed a regression where - I think - the last animation frame wasn't
displayed. This was most noticeable in looping animations, in particular
the spinning "Dreamer's Guild" logo in the IHNM intro.

In the process I changed the name of 'n_frames' and 'nframes' to 'maxframe'
since that's what they are. I could, of course, have added 1 to the value
instead, but that would have introduced a subtle difference compared to the
original code. Probably not a good idea at this stage.


Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/animation.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- animation.cpp	2 Jan 2005 14:52:00 -0000	1.35
+++ animation.cpp	3 Jan 2005 17:39:20 -0000	1.36
@@ -91,18 +91,18 @@
 	MemoryReadStreamEndian headerReadS(anim_resdata, anim_resdata_len, IS_BIG_ENDIAN);
 
 	readAnimHeader(headerReadS, ah);
-	new_anim->n_frames = ah.nframes;
+	new_anim->maxframe = ah.maxframe;
 	new_anim->loopframe = ah.loopframe;
 
 	if (_vm->_gameType == GType_ITE) {
 		// Cache frame offsets
-		new_anim->frame_offsets = (size_t *)malloc(new_anim->n_frames * sizeof(*new_anim->frame_offsets));
+		new_anim->frame_offsets = (size_t *)malloc((new_anim->maxframe + 1) * sizeof(*new_anim->frame_offsets));
 		if (new_anim->frame_offsets == NULL) {
 			warning("Anim::load Allocation failure");
 			return MEM;
 		}
 
-		for (i = 0; i < new_anim->n_frames; i++) {
+		for (i = 0; i <= new_anim->maxframe; i++) {
 			getFrameOffset(anim_resdata, anim_resdata_len, i, &new_anim->frame_offsets[i]);
 		}
 	} else {
@@ -113,7 +113,7 @@
 	// Set animation data
 	new_anim->current_frame = 0;
 	new_anim->completed = 0;
-	new_anim->cycles = new_anim->n_frames;
+	new_anim->cycles = new_anim->maxframe;
 
 	new_anim->frame_time = DEFAULT_FRAME_TIME;
 	new_anim->flags = 0;
@@ -233,7 +233,7 @@
 		anim->current_frame++;
 		anim->completed++;
 
-		if (anim->current_frame >= anim->n_frames) {
+		if (anim->current_frame > anim->maxframe) {
 			anim->current_frame = anim->loopframe;
 			
 			// FIXME: HACK. probably needs more testing for IHNM
@@ -262,7 +262,7 @@
 			anim_id = link_anim_id;
 		} else {
 			// No link, stop playing
-			anim->current_frame = anim->n_frames - 1;
+			anim->current_frame = anim->maxframe;
 			anim->state = ANIM_PAUSE;
 
 			if (anim->flags & ANIM_ENDSCENE) {
@@ -424,7 +424,7 @@
 
 	ah.unknown06 = readS.readByte();
 	ah.unknown07 = readS.readByte();
-	ah.nframes = readS.readByte() - 1;
+	ah.maxframe = readS.readByte() - 1;
 	ah.loopframe = readS.readByte() - 1;
 	ah.start = readS.readUint16BE();
 
@@ -836,7 +836,6 @@
 int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_frame, size_t *frame_offset_p) {
 	ANIMATION_HEADER ah;
 
-	uint16 num_frames;
 	uint16 current_frame;
 
 	byte mark_byte;
@@ -850,9 +849,7 @@
 
 	readAnimHeader(readS, ah);
 
-	num_frames = ah.nframes;
-
-	if (find_frame >= num_frames) {
+	if (find_frame > ah.maxframe) {
 		return FAILURE;
 	}
 
@@ -954,7 +951,7 @@
 			idx++;
 		}
 
-		_vm->_console->DebugPrintf("%02d: Frames: %u Flags: %u\n", i, _anim_tbl[idx]->n_frames, _anim_tbl[idx]->flags);
+		_vm->_console->DebugPrintf("%02d: Frames: %u Flags: %u\n", i, _anim_tbl[idx]->maxframe, _anim_tbl[idx]->flags);
 	}
 }
 

Index: animation.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/animation.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- animation.h	1 Jan 2005 16:18:36 -0000	1.18
+++ animation.h	3 Jan 2005 17:39:20 -0000	1.19
@@ -57,7 +57,7 @@
 	byte unknown06;
 	byte unknown07;
 
-	byte nframes;
+	byte maxframe;
 	byte loopframe;
 
 	uint16 start;
@@ -80,7 +80,7 @@
 	const byte *resdata;
 	size_t resdata_len;
 
-	uint16 n_frames;
+	uint16 maxframe;
 	size_t *frame_offsets;
 	int16 current_frame;
 	uint16 completed;





More information about the Scummvm-git-logs mailing list