summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-08-04 18:23:48 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-08-04 18:23:48 +0000
commit682cabf5d7269ac751ad9be433f300801c704128 (patch)
tree128e5875fbed4fa8a84afa6b7478333a80933f21
parent9d76e6b415c665686ee52c1979ad4d0be79cd111 (diff)
downloadmana-682cabf5d7269ac751ad9be433f300801c704128.tar.gz
mana-682cabf5d7269ac751ad9be433f300801c704128.tar.bz2
mana-682cabf5d7269ac751ad9be433f300801c704128.tar.xz
mana-682cabf5d7269ac751ad9be433f300801c704128.zip
Small code cleanup. Removed unused headers.
-rw-r--r--ChangeLog1
-rw-r--r--src/animation.cpp35
2 files changed, 16 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 5d569920..7ff57a9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
2006-08-04 Björn Steinbrink <B.Steinbrink@gmx
+ * src/animation.cpp: Small code cleanups. Removed unused headers.
* src/animatedsprite.cpp: Small code cleanup/lower indentation.
2006-08-04 Bjørn Lindeijer <bjorn@lindeijer.nl>
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();
}