From 4daef0577708047ed1bec41f2907ec815f3c1176 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 1 Jun 2013 03:24:06 +0000 Subject: [PATCH] bugfix for animation progress --- source/glest_game/type_instances/unit.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 8e960ad7..f53075a7 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -2043,13 +2043,28 @@ bool Unit::update() { } if(getAnimProgressAsFloat() < targetProgress) { float diff = targetProgress - getAnimProgressAsFloat(); - this->animProgress = this->animProgress + static_cast(diff * 100.f) / (GameConstants::updateFps); + int progressIncrease = this->animProgress + static_cast(diff * 100.f) / (GameConstants::updateFps); + // Ensure we increment at least a value of 1 of the action will be stuck infinitely + if(diff > 0 && GameConstants::updateFps > 0 && progressIncrease == 0) { + progressIncrease = 1; + } + this->animProgress = progressIncrease; } } else { int speedDenominator = speedDivider * game->getWorld()->getUpdateFps(this->getFactionIndex()); - this->animProgress += (currSkill->getAnimSpeed() * heightFactor) / speedDenominator; + int progressIncrease = (currSkill->getAnimSpeed() * heightFactor) / speedDenominator; + // Ensure we increment at least a value of 1 of the action will be stuck infinitely + if(currSkill->getAnimSpeed() > 0 && heightFactor > 0 && progressIncrease == 0) { + progressIncrease = 1; + } + this->animProgress += progressIncrease; + //this->animProgress += (currSkill->getAnimSpeed() * heightFactor) / speedDenominator; + + //if(currSkill->getClass() == scDie) { + // printf("Unit died progress: %d anim: %d\n",progress,this->animProgress); + //} } //update target updateTarget();