diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-06 21:12:22 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-07 10:43:54 +0100 |
commit | c74680473e702bacc009897a258387445d6f3eb5 (patch) | |
tree | 800cfb1f83f0c69ae8fcd0096949e660152a80b8 /src/animationparticle.cpp | |
parent | f9a522c72db959b5d63061ed255735d0230fc7de (diff) | |
download | mana-c74680473e702bacc009897a258387445d6f3eb5.tar.gz mana-c74680473e702bacc009897a258387445d6f3eb5.tar.bz2 mana-c74680473e702bacc009897a258387445d6f3eb5.tar.xz mana-c74680473e702bacc009897a258387445d6f3eb5.zip |
Use the native TMX tile animation format
Rewrote the tile animation loading code based on XML tags, replacing
the code that loaded tile animations from tile properties.
Also made a number of code simplifications and optimizations:
* Replaced a number of pointer members with value members.
* Pass around Animation and TileAnimation by value, using std::move to
avoid allocating copies.
* push -> emplace
* push_front -> emplace_front
* push_back -> emplace_back
* Use range-based for loops
* Use std::vector instead of std::list for storing affected tiles
(less fragmentation)
* Avoid string copies and allocations while parsing CSV layer data.
* Replaced xmlNodeGetContent with directly accessing 'content'.
Diffstat (limited to 'src/animationparticle.cpp')
-rw-r--r-- | src/animationparticle.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/animationparticle.cpp b/src/animationparticle.cpp index a5461ecd..db38b526 100644 --- a/src/animationparticle.cpp +++ b/src/animationparticle.cpp @@ -23,29 +23,29 @@ #include "simpleanimation.h" -AnimationParticle::AnimationParticle(Map *map, Animation *animation): +AnimationParticle::AnimationParticle(Map *map, Animation animation): ImageParticle(map, nullptr), - mAnimation(new SimpleAnimation(animation)) + mAnimation(std::move(animation)) { } AnimationParticle::AnimationParticle(Map *map, xmlNodePtr animationNode, - const std::string& dyePalettes): + const std::string &dyePalettes): ImageParticle(map, nullptr), - mAnimation(new SimpleAnimation(animationNode, dyePalettes)) + mAnimation(animationNode, dyePalettes) { } AnimationParticle::~AnimationParticle() { - delete mAnimation; + // Prevent ImageParticle from decreasing the reference count of the image mImage = nullptr; } bool AnimationParticle::update() { - mAnimation->update(10); // particle engine is updated every 10ms - mImage = mAnimation->getCurrentImage(); + mAnimation.update(10); // particle engine is updated every 10ms + mImage = mAnimation.getCurrentImage(); return Particle::update(); } |