aboutsummaryrefslogtreecommitdiff
path: root/engines/toon
diff options
context:
space:
mode:
authorSylvain Dupont2010-10-11 23:16:15 +0000
committerSylvain Dupont2010-10-11 23:16:15 +0000
commiteb52eb32a065375ef996af438261be3b70a27c33 (patch)
tree0472cfda64a05accf27041a62c7d07d114789c40 /engines/toon
parent95c0e6cc4270cc32e371094437c3a2beeb59eed6 (diff)
downloadscummvm-rg350-eb52eb32a065375ef996af438261be3b70a27c33.tar.gz
scummvm-rg350-eb52eb32a065375ef996af438261be3b70a27c33.tar.bz2
scummvm-rg350-eb52eb32a065375ef996af438261be3b70a27c33.zip
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. svn-id: r53157
Diffstat (limited to 'engines/toon')
-rw-r--r--engines/toon/character.cpp10
-rw-r--r--engines/toon/flux.cpp33
-rw-r--r--engines/toon/flux.h1
3 files changed, 43 insertions, 1 deletions
diff --git a/engines/toon/character.cpp b/engines/toon/character.cpp
index 6f7258d43c..50913f89c7 100644
--- a/engines/toon/character.cpp
+++ b/engines/toon/character.cpp
@@ -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 @@ void Character::playAnim(int32 animId, int32 unused, int32 flags) {
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");
diff --git a/engines/toon/flux.cpp b/engines/toon/flux.cpp
index f7c6bebf0b..524b058e63 100644
--- a/engines/toon/flux.cpp
+++ b/engines/toon/flux.cpp
@@ -67,6 +67,39 @@ void CharacterFlux::playWalkAnim(int32 start, int32 end) {
_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);
diff --git a/engines/toon/flux.h b/engines/toon/flux.h
index ca67cfc563..7981799cba 100644
--- a/engines/toon/flux.h
+++ b/engines/toon/flux.h
@@ -44,6 +44,7 @@ public:
void update(int32 timeIncrement);
int32 getRandomIdleAnim();
void setVisible(bool visible);
+ static int32 fixFacingForAnimation(int32 originalFacing, int32 animationId);
};
} // End of namespace Toon