From ecd456560bf8dbd12822ccc8a5b71e957ab85df4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 13 Nov 2011 22:15:53 +0300 Subject: Add support compotability with future mana reorder sprites implimentation. (support for missing sprite tag) --- src/being.cpp | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/src/being.cpp b/src/being.cpp index b344e9709..036f823e6 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -2171,22 +2171,48 @@ void Being::recalcSpritesOrder() { int remSprite = itr->first; const std::map &itemReplacer = itr->second; - if (itemReplacer.empty()) - { - mSpriteHide[remSprite] = 1; + if (remSprite >= 0) + { // slot known + if (itemReplacer.empty()) + { + mSpriteHide[remSprite] = 1; + } + else + { + std::map::const_iterator repIt + = itemReplacer.find(mSpriteIDs[remSprite]); + if (repIt != itemReplacer.end()) + { + mSpriteHide[remSprite] = repIt->second; + if (repIt->second != 1) + { + setSprite(remSprite, repIt->second, + mSpriteColors[remSprite], + 1, false, true); + } + } + } } else - { + { // slot unknown. Search for real slot, this can be slow std::map::const_iterator repIt - = itemReplacer.find(mSpriteIDs[remSprite]); - if (repIt != itemReplacer.end()) + = itemReplacer.begin(); + std::map::const_iterator repIt_end + = itemReplacer.end(); + for (;repIt != repIt_end; ++ repIt) { - mSpriteHide[remSprite] = repIt->second; - if (repIt->second != 1) + for (unsigned slot2 = 0; slot2 < sz; slot2 ++) { - setSprite(remSprite, repIt->second, - mSpriteColors[remSprite], - 1, false, true); + if (mSpriteIDs[slot2] == repIt->first) + { + mSpriteHide[slot2] = repIt->second; + if (repIt->second != 1) + { + setSprite(slot2, repIt->second, + mSpriteColors[slot2], + 1, false, true); + } + } } } } -- cgit v1.2.3-70-g09d2