summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-02-12 04:18:44 +0200
committerAndrei Karas <akaras@inbox.ru>2011-02-12 04:18:44 +0200
commit98731375f9a39319cf2c30274f2ee73a139ba4f0 (patch)
tree246fa29893ab465e970c331c07a8ffc8d818929a /src/being.cpp
parent689ff9aa487b706731b02e44d7c3f05d5f2e15fa (diff)
downloadmv-98731375f9a39319cf2c30274f2ee73a139ba4f0.tar.gz
mv-98731375f9a39319cf2c30274f2ee73a139ba4f0.tar.bz2
mv-98731375f9a39319cf2c30274f2ee73a139ba4f0.tar.xz
mv-98731375f9a39319cf2c30274f2ee73a139ba4f0.zip
Add support for items attribute RemoveSprite.
Usefull for example for hiding hair if equiped helmet.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 8cde401f2..7851725d4 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -207,9 +207,13 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map):
mPvpRank(0)
{
mSpriteRemap = new int[20];
+ mSpriteHide = new int[20];
for (int f = 0; f < 20; f ++)
+ {
mSpriteRemap[f] = f;
+ mSpriteHide[f] = 0;
+ }
setMap(map);
setSubtype(subtype);
@@ -238,6 +242,8 @@ Being::~Being()
delete[] mSpriteRemap;
mSpriteRemap = 0;
+ delete[] mSpriteHide;
+ mSpriteHide = 0;
delete mSpeechBubble;
mSpeechBubble = 0;
@@ -1699,6 +1705,9 @@ void Being::drawSprites(Graphics* graphics, int posX, int posY) const
// CompoundSprite::drawSprites(graphics, posX, posY);
for (int f = 0; f < getNumberOfLayers(); f ++)
{
+ if (mSpriteHide[mSpriteRemap[f]])
+ continue;
+
Sprite *sprite = getSprite(mSpriteRemap[f]);
if (sprite)
{
@@ -1716,6 +1725,9 @@ void Being::drawSpritesSDL(Graphics* graphics, int posX, int posY) const
for (unsigned f = 0; f < size(); f ++)
{
+ if (mSpriteHide[mSpriteRemap[f]])
+ continue;
+
Sprite *sprite = getSprite(mSpriteRemap[f]);
if (sprite)
sprite->draw(graphics, posX, posY);
@@ -1875,6 +1887,10 @@ void Being::recalcSpritesOrder()
// logger->log("preparation start");
std::vector<int>::iterator it;
+
+ for (unsigned slot = 0; slot < sz; slot ++)
+ mSpriteHide[slot] = 0;
+
for (unsigned slot = 0; slot < sz; slot ++)
{
slotRemap.push_back(slot);
@@ -1884,6 +1900,9 @@ void Being::recalcSpritesOrder()
continue;
const ItemInfo &info = ItemDB::get(id);
+ if (info.getRemoveSprite() > 0)
+ mSpriteHide[info.getRemoveSprite()] = 1;
+
if (info.getDrawBefore() > 0)
{
int id2 = mSpriteIDs[info.getDrawBefore()];