diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-02-05 00:55:56 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-02-05 00:55:56 +0300 |
commit | 370d1c43e73d4c06aabb4432b61e772ba6a66f13 (patch) | |
tree | a85b7c30d8b7c29428d36d1c24b5c26a3057b15b | |
parent | b671f16dd633944ed3ea01dd8b50c0d51f77b081 (diff) | |
download | manaverse-370d1c43e73d4c06aabb4432b61e772ba6a66f13.tar.gz manaverse-370d1c43e73d4c06aabb4432b61e772ba6a66f13.tar.bz2 manaverse-370d1c43e73d4c06aabb4432b61e772ba6a66f13.tar.xz manaverse-370d1c43e73d4c06aabb4432b61e772ba6a66f13.zip |
Improve a bit image particle limits checking.
-rw-r--r-- | src/imageparticle.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/imageparticle.cpp b/src/imageparticle.cpp index c2d253641..4eab16fc9 100644 --- a/src/imageparticle.cpp +++ b/src/imageparticle.cpp @@ -23,6 +23,7 @@ #include "imageparticle.h" #include "graphics.h" +#include "logger.h" #include "resources/image.h" @@ -38,16 +39,13 @@ ImageParticle::ImageParticle(Map *const map, Image *const image): { mImage->incRef(); - std::string name = mImage->getIdPath(); - if (ImageParticle::imageParticleCountByName.find(name) - == ImageParticle::imageParticleCountByName.end()) - { + const std::string &name = mImage->getIdPath(); + std::map<std::string, int>::iterator it + = ImageParticle::imageParticleCountByName.find(name); + if (it == ImageParticle::imageParticleCountByName.end()) ImageParticle::imageParticleCountByName[name] = 1; - } else - { - ImageParticle::imageParticleCountByName[name] ++; - } + (*it).second ++; } } @@ -55,9 +53,15 @@ ImageParticle::~ImageParticle() { if (mImage) { - std::string name = mImage->getIdPath(); - if (ImageParticle::imageParticleCountByName[name] > 0) - ImageParticle::imageParticleCountByName[name] --; + const std::string &name = mImage->getIdPath(); + std::map<std::string, int>::iterator it + = ImageParticle::imageParticleCountByName.find(name); + if (it != ImageParticle::imageParticleCountByName.end()) + { + int &cnt = (*it).second; + if (cnt > 0) + cnt --; + } mImage->decRef(); mImage = nullptr; |