summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-07-26 21:54:07 +0300
committerAndrei Karas <akaras@inbox.ru>2011-07-26 21:54:07 +0300
commit7b15124d28592ee7b9248c9ff3b19e710c1ce4ee (patch)
treefecbaa33f8424404228c561c49274a9c76486732 /src/being.cpp
parentbadba244423ba8fccb246afaa8b1dd0c1448b370 (diff)
downloadmanaplus-7b15124d28592ee7b9248c9ff3b19e710c1ce4ee.tar.gz
manaplus-7b15124d28592ee7b9248c9ff3b19e710c1ce4ee.tar.bz2
manaplus-7b15124d28592ee7b9248c9ff3b19e710c1ce4ee.tar.xz
manaplus-7b15124d28592ee7b9248c9ff3b19e710c1ce4ee.zip
Small optimisation in reorder sprites function.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 40c41cb64..034478067 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -2084,6 +2084,9 @@ void Being::recalcSpritesOrder()
// logger->log("preparation start");
std::vector<int>::iterator it;
int oldHide[20];
+ int dir = mSpriteDirection;
+ if (dir < 0 || dir >= 9)
+ dir = 0;
for (unsigned slot = 0; slot < sz; slot ++)
{
@@ -2141,16 +2144,15 @@ void Being::recalcSpritesOrder()
}
}
- if (info.getDrawBefore(mSpriteDirection) > 0)
+ if (info.mDrawBefore[dir] > 0)
{
- int id2 = mSpriteIDs[info.getDrawBefore(mSpriteDirection)];
+ int id2 = mSpriteIDs[info.mDrawBefore[dir]];
std::map<int, int>::iterator orderIt = itemSlotRemap.find(id2);
if (orderIt != itemSlotRemap.end())
{
// logger->log("found duplicate (before)");
const ItemInfo &info2 = ItemDB::get(id2);
- if (info.getDrawPriority(mSpriteDirection)
- < info2.getDrawPriority(mSpriteDirection))
+ if (info.mDrawPriority[dir] < info2.mDrawPriority[dir])
{
// logger->log("old more priority");
continue;
@@ -2162,19 +2164,18 @@ void Being::recalcSpritesOrder()
}
}
- itemSlotRemap[id] = -info.getDrawBefore(mSpriteDirection);
+ itemSlotRemap[id] = -info.mDrawBefore[dir];
// logger->log("item slot->slot %d %d->%d", id, slot, itemSlotRemap[id]);
}
- else if (info.getDrawAfter(mSpriteDirection) > 0)
+ else if (info.mDrawAfter[dir] > 0)
{
- int id2 = mSpriteIDs[info.getDrawAfter(mSpriteDirection)];
+ int id2 = mSpriteIDs[info.mDrawAfter[dir]];
std::map<int, int>::iterator orderIt = itemSlotRemap.find(id2);
if (orderIt != itemSlotRemap.end())
{
// logger->log("found duplicate (after)");
const ItemInfo &info2 = ItemDB::get(id2);
- if (info.getDrawPriority(mSpriteDirection)
- < info2.getDrawPriority(mSpriteDirection))
+ if (info.mDrawPriority[dir] < info2.mDrawPriority[dir])
{
// logger->log("old more priority");
continue;
@@ -2186,7 +2187,7 @@ void Being::recalcSpritesOrder()
}
}
- itemSlotRemap[id] = info.getDrawAfter(mSpriteDirection);
+ itemSlotRemap[id] = info.mDrawAfter[dir];
// logger->log("item slot->slot %d %d->%d", id, slot, itemSlotRemap[id]);
}
}