瀏覽代碼

Fixed: Animation errors should not lead to hanging

Dmitry Orlov 4 年之前
父節點
當前提交
1ce7701168
共有 1 個文件被更改,包括 9 次插入4 次删除
  1. 9 4
      client/battle/CCreatureAnimation.cpp

+ 9 - 4
client/battle/CCreatureAnimation.cpp

@@ -210,14 +210,19 @@ bool CCreatureAnimation::incrementFrame(float timePassed)
 {
 	elapsedTime += timePassed;
 	currentFrame += timePassed * speed;
+	const auto framesNumber = framesInGroup(type);
 
-	if (currentFrame >= float(framesInGroup(type)))
+	if(framesNumber <= 0)
+	{
+		endAnimation();
+	}
+	else if(currentFrame >= float(framesNumber))
 	{
 		// just in case of extremely low fps (or insanely high speed)
-		while (currentFrame >= float(framesInGroup(type)))
-			currentFrame -= framesInGroup(type);
+		while(currentFrame >= float(framesNumber))
+			currentFrame -= framesNumber;
 
-		if (once)
+		if(once)
 			setType(CCreatureAnim::HOLDING);
 
 		endAnimation();