summaryrefslogtreecommitdiff
path: root/src
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
parentbadba244423ba8fccb246afaa8b1dd0c1448b370 (diff)
downloadmanaverse-7b15124d28592ee7b9248c9ff3b19e710c1ce4ee.tar.gz
manaverse-7b15124d28592ee7b9248c9ff3b19e710c1ce4ee.tar.bz2
manaverse-7b15124d28592ee7b9248c9ff3b19e710c1ce4ee.tar.xz
manaverse-7b15124d28592ee7b9248c9ff3b19e710c1ce4ee.zip
Small optimisation in reorder sprites function.
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp21
-rw-r--r--src/resources/iteminfo.h6
2 files changed, 14 insertions, 13 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]);
}
}
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index d8b8c7b0d..daa9d590c 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -256,6 +256,9 @@ class ItemInfo
const std::string replaceColors(std::string str,
unsigned char color) const;
+ int mDrawBefore[9];
+ int mDrawAfter[9];
+ int mDrawPriority[9];
protected:
SpriteDisplay mDisplay; /**< Display info (like icon) */
@@ -267,9 +270,6 @@ class ItemInfo
int mWeight; /**< Weight in grams. */
int mView; /**< Item ID of how this item looks. */
int mId; /**< Item ID */
- int mDrawBefore[9];
- int mDrawAfter[9];
- int mDrawPriority[9];
bool mIsRemoveSprites;
// sprite, <itemfrom, itemto> [direction]
SpriteToItemMap *mSpriteToItemReplaceMap[9];