summaryrefslogtreecommitdiff
path: root/src/resources/mapreader.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-13 16:34:10 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-13 16:34:10 +0300
commit0b734fa8db3cfcef12f4dc35bd4f8da1bb86944d (patch)
tree88f05a8270b03c0d50e2a3f7b6ca61f8969bf4fc /src/resources/mapreader.cpp
parent63c7c0bca65489b3f4ce29ffca05d638858c7e19 (diff)
downloadmanaplus-0b734fa8db3cfcef12f4dc35bd4f8da1bb86944d.tar.gz
manaplus-0b734fa8db3cfcef12f4dc35bd4f8da1bb86944d.tar.bz2
manaplus-0b734fa8db3cfcef12f4dc35bd4f8da1bb86944d.tar.xz
manaplus-0b734fa8db3cfcef12f4dc35bd4f8da1bb86944d.zip
Improve a bit map load speed.
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r--src/resources/mapreader.cpp18
1 files changed, 14 insertions, 4 deletions
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<int, TileAnimation*> &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)
{