diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-08-04 18:23:48 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-08-04 18:23:48 +0000 |
commit | 682cabf5d7269ac751ad9be433f300801c704128 (patch) | |
tree | 128e5875fbed4fa8a84afa6b7478333a80933f21 /src/animation.cpp | |
parent | 9d76e6b415c665686ee52c1979ad4d0be79cd111 (diff) | |
download | mana-client-682cabf5d7269ac751ad9be433f300801c704128.tar.gz mana-client-682cabf5d7269ac751ad9be433f300801c704128.tar.bz2 mana-client-682cabf5d7269ac751ad9be433f300801c704128.tar.xz mana-client-682cabf5d7269ac751ad9be433f300801c704128.zip |
Small code cleanup. Removed unused headers.
Diffstat (limited to 'src/animation.cpp')
-rw-r--r-- | src/animation.cpp | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/animation.cpp b/src/animation.cpp index 1af8c616..1213d0d6 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -23,13 +23,9 @@ #include "animation.h" -#include <cassert> +#include <algorithm> -#include "log.h" - -#include "resources/image.h" -#include "resources/resourcemanager.h" -#include "resources/spriteset.h" +#include "utils/dtor.h" Animation::Animation(): mTime(0) @@ -41,17 +37,20 @@ void Animation::update(unsigned int time) { mTime += time; - if (!mAnimationPhases.empty()) + if (mAnimationPhases.empty()) + return; + + unsigned int delay = iCurrentPhase->delay; + if (!delay) + return; + + while (mTime > delay) { - unsigned int delay = iCurrentPhase->delay; - while (mTime > delay && delay > 0) + mTime -= delay; + iCurrentPhase++; + if (iCurrentPhase == mAnimationPhases.end()) { - mTime -= delay; - iCurrentPhase++; - if (iCurrentPhase == mAnimationPhases.end()) - { - iCurrentPhase = mAnimationPhases.begin(); - } + iCurrentPhase = mAnimationPhases.begin(); } } } @@ -79,7 +78,6 @@ Animation::getLength() if (mAnimationPhases.empty()) return 0; - std::list<AnimationPhase>::iterator i; int length = 0; for (i = mAnimationPhases.begin(); i != mAnimationPhases.end(); i++) @@ -96,10 +94,7 @@ Action::Action(): Action::~Action() { - for (AnimationIterator i = mAnimations.begin(); i != mAnimations.end(); i++) - { - delete i->second; - } + std::for_each(mAnimations.begin(), mAnimations.end(), make_dtor(mAnimations)); mAnimations.clear(); } |