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
This commit is contained in:
Sylvain Dupont 2010-10-11 23:16:15 +00:00
parent 95c0e6cc42
commit eb52eb32a0
3 changed files with 43 additions and 1 deletions

View File

@ -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");

View File

@ -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);

View File

@ -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