From e71aed97c2d885c8113561c1e0cad91454adeb57 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 13 Sep 2013 00:49:42 +0300 Subject: fix animaed tiles in csv map format. --- src/resources/mapreader.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/resources') diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 7481ad948..4f39c80a3 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -538,7 +538,7 @@ bool MapReader::readBase64Layer(const XmlNodePtr childNode, Map *const map, } } - std::map &tileAnimations + const std::map &tileAnimations = map->getTileAnimations(); const bool hasAnimations = !tileAnimations.empty(); @@ -592,6 +592,10 @@ bool MapReader::readCsvLayer(const XmlNodePtr childNode, Map *const map, std::string csv(data); size_t oldPos = 0; + const std::map &tileAnimations + = map->getTileAnimations(); + const bool hasAnimations = !tileAnimations.empty(); + while (oldPos != csv.npos) { const size_t pos = csv.find_first_of(",", oldPos); @@ -600,6 +604,16 @@ bool MapReader::readCsvLayer(const XmlNodePtr childNode, Map *const map, const int gid = atoi(csv.substr(oldPos, pos - oldPos).c_str()); setTile(map, layer, x, y, gid); + if (hasAnimations) + { + TileAnimationMapCIter it = tileAnimations.find(gid); + if (it != tileAnimations.end()) + { + TileAnimation *const ani = it->second; + if (ani) + ani->addAffectedTile(layer, x + y * w); + } + } x++; if (x == w) -- cgit v1.2.3-60-g2f50