diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-07-25 03:42:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-07-25 03:42:09 +0300 |
commit | a4252ba2050b16a53247335cdddd7aa13a532239 (patch) | |
tree | 19a41cf0b1c546d5b1cc217194a1fe0a477d545d /src/being.cpp | |
parent | 4afb49eb81f590c2bce56ed28f237a9bf0e2a093 (diff) | |
download | plus-a4252ba2050b16a53247335cdddd7aa13a532239.tar.gz plus-a4252ba2050b16a53247335cdddd7aa13a532239.tar.bz2 plus-a4252ba2050b16a53247335cdddd7aa13a532239.tar.xz plus-a4252ba2050b16a53247335cdddd7aa13a532239.zip |
Add removing palyers sprite logic depend on players direction.
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/src/being.cpp b/src/being.cpp index d8e3119b5..904a59390 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -1073,6 +1073,7 @@ void Being::setDirection(Uint8 direction) mSpriteDirection = dir; CompoundSprite::setSpriteDirection(dir); + recalcSpritesOrder(); } Uint8 Being::calcDirection() const @@ -1660,7 +1661,7 @@ void Being::setSprite(unsigned int slot, int id, std::string color, } else { - ItemInfo info = ItemDB::get(id); + const ItemInfo &info = ItemDB::get(id); std::string filename = info.getSprite(mGender); AnimatedSprite *equipmentSprite = NULL; @@ -2094,6 +2095,9 @@ void Being::recalcSpritesOrder() { slotRemap.push_back(slot); + if (mSpriteIDs.size() <= slot) + continue; + int id = mSpriteIDs[slot]; if (!id) continue; @@ -2102,35 +2106,39 @@ void Being::recalcSpritesOrder() if (info.isRemoveSprites()) { - std::map<int, std::map<int, int> > spriteToItems - = info.getSpriteToItemReplaceMap(); - - std::map<int, std::map<int, int> >::iterator it; + SpriteToItemMap *spriteToItems = info.getSpriteToItemReplaceMap( + mSpriteDirection); - for (it = spriteToItems.begin(); it != spriteToItems.end(); ++it) + if (spriteToItems) { - int removeSprite = it->first; - std::map<int, int> &itemReplacer = it->second; - if (itemReplacer.size() == 0) - { - mSpriteHide[removeSprite] = 1; - } - else + SpriteToItemMap::iterator it; + + for (it = spriteToItems->begin(); + it != spriteToItems->end(); ++it) { - std::map<int, int>::iterator repIt - = itemReplacer.find(mSpriteIDs[removeSprite]); - if (repIt != itemReplacer.end()) + int removeSprite = it->first; + std::map<int, int> &itemReplacer = it->second; + if (itemReplacer.empty()) + { + mSpriteHide[removeSprite] = 1; + } + else { - mSpriteHide[removeSprite] = repIt->second; - if (repIt->second != 1) + std::map<int, int>::iterator repIt + = itemReplacer.find(mSpriteIDs[removeSprite]); + if (repIt != itemReplacer.end()) { - setSprite(removeSprite, repIt->second, - mSpriteColors[removeSprite], 1, false, true); + mSpriteHide[removeSprite] = repIt->second; + if (repIt->second != 1) + { + setSprite(removeSprite, repIt->second, + mSpriteColors[removeSprite], + 1, false, true); + } } } } } - } if (info.getDrawBefore() > 0) @@ -2195,7 +2203,11 @@ void Being::recalcSpritesOrder() { int slot = searchSlotValue(slotRemap, slot0); int val = slotRemap.at(slot); - int id = mSpriteIDs[val]; + int id = 0; + + if ((int)mSpriteIDs.size() > val) + id = mSpriteIDs[val]; + int idx = -1; int idx1 = -1; // logger->log("item %d, id=%d", slot, id); |