Explorar o código

* corrected stack death animation

mateuszb %!s(int64=16) %!d(string=hai) anos
pai
achega
329eab2f6a
Modificáronse 3 ficheiros con 11 adicións e 15 borrados
  1. 3 15
      CBattleInterface.cpp
  2. 7 0
      client/CCreatureAnimation.cpp
  3. 1 0
      client/CCreatureAnimation.h

+ 3 - 15
CBattleInterface.cpp

@@ -1169,27 +1169,16 @@ void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAtt
 		}
 	}
 	//initializing
-	std::map<int, int> animLengths;
-	std::map<int, int> increments;
 	int maxLen = 0;
 	for(size_t g=0; g<attackedInfos.size(); ++g)
 	{
-		int animLen;
 		if(attackedInfos[g].killed)
 		{
 			creAnims[attackedInfos[g].ID]->setType(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::vector<CBattleInterface::SStackAtt
 		SDL_framerateDelay(LOCPLINT->mainFPSmng);
 		for(size_t g=0; g<attackedInfos.size(); ++g)
 		{
-			if((animCount+1)%(4/animSpeed)==0 && increments[attackedInfos[g].ID]<animLengths[attackedInfos[g].ID])
+			if((animCount+1)%(4/animSpeed)==0 && !creAnims[attackedInfos[g].ID]->onLastFrameInGroup())
 			{
 				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; g<attackedInfos.size(); ++g)
 		{
-			if(increments[attackedInfos[g].ID] < animLengths[attackedInfos[g].ID] - 1)
+			if(!creAnims[attackedInfos[g].ID]->onLastFrameInGroup())
 			{
 				isAnotherOne = true;
 				break;

+ 7 - 0
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);

+ 1 - 0
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