From c74680473e702bacc009897a258387445d6f3eb5 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Wed, 6 Mar 2024 21:12:22 +0100 Subject: 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'. --- src/actorsprite.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/actorsprite.cpp') diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 088bc9f4..90176dcd 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -437,16 +437,16 @@ void ActorSprite::loadTargetCursor(const std::string &filename, return; } - auto *anim = new Animation; + Animation anim; for (unsigned int i = 0; i < currentImageSet->size(); ++i) { - anim->addFrame(currentImageSet->get(i), DEFAULT_FRAME_DELAY, + anim.addFrame(currentImageSet->get(i), DEFAULT_FRAME_DELAY, -(currentImageSet->getWidth() / 2), -(currentImageSet->getHeight() / 2)); } - auto *currentCursor = new SimpleAnimation(anim); + auto *currentCursor = new SimpleAnimation(std::move(anim)); targetCursorImages[type][size] = currentImageSet; targetCursor[type][size] = currentCursor; -- cgit v1.2.3-70-g09d2