diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-11-13 22:15:53 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-11-13 22:15:53 +0300 |
commit | ecd456560bf8dbd12822ccc8a5b71e957ab85df4 (patch) | |
tree | b699609e725e09a87e6600a603600fdc535b9e0e | |
parent | b7103fbcef86554476871ad363e2a6b3bad0b77e (diff) | |
download | mv-ecd456560bf8dbd12822ccc8a5b71e957ab85df4.tar.gz mv-ecd456560bf8dbd12822ccc8a5b71e957ab85df4.tar.bz2 mv-ecd456560bf8dbd12822ccc8a5b71e957ab85df4.tar.xz mv-ecd456560bf8dbd12822ccc8a5b71e957ab85df4.zip |
Add support compotability with future mana reorder sprites implimentation.
(support for missing sprite tag)
-rw-r--r-- | src/being.cpp | 48 |
1 files 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<int, int> &itemReplacer = itr->second; - if (itemReplacer.empty()) - { - mSpriteHide[remSprite] = 1; + if (remSprite >= 0) + { // slot known + if (itemReplacer.empty()) + { + mSpriteHide[remSprite] = 1; + } + else + { + std::map<int, int>::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<int, int>::const_iterator repIt - = itemReplacer.find(mSpriteIDs[remSprite]); - if (repIt != itemReplacer.end()) + = itemReplacer.begin(); + std::map<int, int>::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); + } + } } } } |