From f9a522c72db959b5d63061ed255735d0230fc7de Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Wed, 6 Mar 2024 20:59:54 +0100 Subject: Fixed tile animations for CSV maps The affected tiles were only tracked for base64-encoded layer data. --- src/map.h | 2 ++ src/resources/mapreader.cpp | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/map.h b/src/map.h index d03570d8..ae0b07a8 100644 --- a/src/map.h +++ b/src/map.h @@ -93,6 +93,8 @@ class MapLayer ~MapLayer(); + int getWidth() const { return mWidth; } + /** * Set tile image, with x and y in layer coordinates. */ diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index aba9f85d..8479cc6c 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -239,6 +239,9 @@ static void setTile(Map *map, MapLayer *layer, int x, int y, unsigned gid) // Set regular tile on a layer Image * const img = set ? set->get(gid - set->getFirstGid()) : nullptr; layer->setTile(x, y, img); + + if (TileAnimation *ani = map->getAnimationForGid(gid)) + ani->addAffectedTile(layer, x + y * layer->getWidth()); } else { @@ -371,12 +374,6 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) setTile(map, layer, x, y, gid); - TileAnimation* ani = map->getAnimationForGid(gid); - if (ani) - { - ani->addAffectedTile(layer, x + y * w); - } - x++; if (x == w) { -- cgit v1.2.3-70-g09d2