[Scummvm-cvs-logs] SF.net SVN: scummvm:[53157] scummvm/trunk/engines/toon

sylvaintv at users.sourceforge.net sylvaintv at users.sourceforge.net
Tue Oct 12 01:16:15 CEST 2010


Revision: 53157
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53157&view=rev
Author:   sylvaintv
Date:     2010-10-11 23:16:15 +0000 (Mon, 11 Oct 2010)

Log Message:
-----------
TOON: Fixed Flux disappearing in barn when talking to the cow

Several animations are not present for every Flux facing.
There is an hardcoded table to handle this.

Modified Paths:
--------------
    scummvm/trunk/engines/toon/character.cpp
    scummvm/trunk/engines/toon/flux.cpp
    scummvm/trunk/engines/toon/flux.h

Modified: scummvm/trunk/engines/toon/character.cpp
===================================================================
--- scummvm/trunk/engines/toon/character.cpp	2010-10-11 23:14:32 UTC (rev 53156)
+++ scummvm/trunk/engines/toon/character.cpp	2010-10-11 23:16:15 UTC (rev 53157)
@@ -25,6 +25,7 @@
 
 #include "toon/character.h"
 #include "toon/drew.h"
+#include "toon/flux.h"
 #include "toon/path.h"
 
 namespace Toon {
@@ -936,8 +937,15 @@
 
 	char animName[20];
 	strcpy(animName, anim->_filename);
+
+	int32 facing = _facing;
+	if (_id == 1) {
+		// flux special case... some animations are not for every facing
+		facing = CharacterFlux::fixFacingForAnimation(facing, animId);
+	}
+
 	if (strchr(animName, '?'))
-		*strchr(animName, '?') = '0' + _facing;
+		*strchr(animName, '?') = '0' + facing;
 	strcat(animName, ".CAF");
 
 

Modified: scummvm/trunk/engines/toon/flux.cpp
===================================================================
--- scummvm/trunk/engines/toon/flux.cpp	2010-10-11 23:14:32 UTC (rev 53156)
+++ scummvm/trunk/engines/toon/flux.cpp	2010-10-11 23:16:15 UTC (rev 53157)
@@ -67,6 +67,39 @@
 	_animationInstance->setLooping(true);
 }
 
+int32 CharacterFlux::fixFacingForAnimation(int32 originalFacing, int32 animationId) {
+
+	static const byte fixFluxAnimationFacing[] = {
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xee, 0xff, 0xff, 0xff,
+		0xff, 0xff, 0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x55,
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
+	byte animFacingFlag = fixFluxAnimationFacing[animationId];
+	int32 v5 = 1 << originalFacing;
+	int32 v6 = 1 << originalFacing;
+	int32 facingMask = 0;
+	do {
+		if ( v6 & animFacingFlag) {
+			facingMask = v6;
+		} else if (v5 & animFacingFlag) {
+			facingMask = v5;
+		}
+		v5 >>= 1;
+		v6 <<= 1;
+	}
+	while (!facingMask);
+
+	int32 finalFacing = 0;
+	for (finalFacing = 0; ; ++finalFacing ) {
+		facingMask >>= 1;
+		if ( !facingMask )
+			break;
+	}
+	
+	return finalFacing;
+}
+
 void CharacterFlux::setPosition(int32 x, int32 y) {
 	debugC(5, kDebugCharacter, "setPosition(%d, %d)", x, y);
 

Modified: scummvm/trunk/engines/toon/flux.h
===================================================================
--- scummvm/trunk/engines/toon/flux.h	2010-10-11 23:14:32 UTC (rev 53156)
+++ scummvm/trunk/engines/toon/flux.h	2010-10-11 23:16:15 UTC (rev 53157)
@@ -44,6 +44,7 @@
 	void update(int32 timeIncrement);
 	int32 getRandomIdleAnim();
 	void setVisible(bool visible);
+	static int32 fixFacingForAnimation(int32 originalFacing, int32 animationId);
 };
 
 } // End of namespace Toon


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list