From 0b734fa8db3cfcef12f4dc35bd4f8da1bb86944d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 13 Sep 2012 16:34:10 +0300 Subject: Improve a bit map load speed. --- src/map.h | 3 +++ src/resources/mapreader.cpp | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/map.h b/src/map.h index 66cf8b707..b90cbc2a7 100644 --- a/src/map.h +++ b/src/map.h @@ -392,6 +392,9 @@ class Map : public Properties, public ConfigListener bool isCustom() const { return mCustom; } + std::map &getTileAnimations() + { return mTileAnimations; } + protected: friend class Actor; friend class Minimap; diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index f133e273d..48d63144a 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -568,6 +568,10 @@ void MapReader::readLayer(const XmlNodePtr node, Map *const map) } } + std::map &tileAnimations + = map->getTileAnimations(); + + const bool hasAnimations = !tileAnimations.empty(); for (int i = 0; i < binLen - 3; i += 4) { const int gid = binData[i] | @@ -577,10 +581,16 @@ void MapReader::readLayer(const XmlNodePtr node, Map *const map) setTile(map, layer, x, y, gid); - TileAnimation *const ani = map->getAnimationForGid(gid); - if (ani) - ani->addAffectedTile(layer, x + y * w); - + if (hasAnimations) + { + TileAnimationMapCIter i = tileAnimations.find(gid); + if (i != tileAnimations.end()) + { + TileAnimation *const ani = i->second; + if (ani) + ani->addAffectedTile(layer, x + y * w); + } + } x++; if (x == w) { -- cgit v1.2.3-70-g09d2