From 329eab2f6a30a03611b4b1d5d844fa8a490200c8 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Thu, 5 Mar 2009 17:57:26 +0000 Subject: [PATCH] * corrected stack death animation --- CBattleInterface.cpp | 18 +++--------------- client/CCreatureAnimation.cpp | 7 +++++++ client/CCreatureAnimation.h | 1 + 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/CBattleInterface.cpp b/CBattleInterface.cpp index 526451634..b6d1841cf 100644 --- a/CBattleInterface.cpp +++ b/CBattleInterface.cpp @@ -1169,27 +1169,16 @@ void CBattleInterface::stacksAreAttacked(std::vector animLengths; - std::map increments; int maxLen = 0; for(size_t g=0; gsetType(5); //death - animLen = creAnims[attackedInfos[g].ID]->framesInGroup(5); } else { creAnims[attackedInfos[g].ID]->setType(3); //getting hit - animLen = creAnims[attackedInfos[g].ID]->framesInGroup(3); - } - animLengths.insert(std::make_pair(attackedInfos[g].ID, animLen)); - increments.insert(std::make_pair(attackedInfos[g].ID, 0)); - if(animLen > maxLen) - { - maxLen = animLen; } } //main showing loop @@ -1201,18 +1190,17 @@ void CBattleInterface::stacksAreAttacked(std::vectormainFPSmng); for(size_t g=0; gonLastFrameInGroup()) { creAnims[attackedInfos[g].ID]->incrementFrame(); - ++(increments[attackedInfos[g].ID]); } - if(increments[attackedInfos[g].ID]>=animLengths[attackedInfos[g].ID] && creAnims[attackedInfos[g].ID]->getType() == 3) + if(creAnims[attackedInfos[g].ID]->onLastFrameInGroup() && creAnims[attackedInfos[g].ID]->getType() == 3) creAnims[attackedInfos[g].ID]->setType(2); } bool isAnotherOne = false; //if true, there is a stack whose hit/death anim must be continued for(size_t g=0; gonLastFrameInGroup()) { isAnotherOne = true; break; diff --git a/client/CCreatureAnimation.cpp b/client/CCreatureAnimation.cpp index 2287ef61e..0b60a7b4e 100644 --- a/client/CCreatureAnimation.cpp +++ b/client/CCreatureAnimation.cpp @@ -137,6 +137,13 @@ int CCreatureAnimation::getFrame() const return curFrame; } +bool CCreatureAnimation::onLastFrameInGroup() +{ + if(internalFrame == frameGroups[type].size() - 1) + return true; + return false; +} + void CCreatureAnimation::playOnce(int type) { setType(type); diff --git a/client/CCreatureAnimation.h b/client/CCreatureAnimation.h index 660b33735..35829fce1 100644 --- a/client/CCreatureAnimation.h +++ b/client/CCreatureAnimation.h @@ -50,6 +50,7 @@ public: int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next void incrementFrame(); int getFrame() const; + bool onLastFrameInGroup(); bool once; void playOnce(int type); //plays once given stage of animation, then resets to 2