summaryrefslogtreecommitdiff
path: root/src/being/being.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-31 21:25:05 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-31 21:51:44 +0300
commit1dfc22f53967ad7e39d42ba8aabe0afa7445476e (patch)
treed6a2bda66d2e50646162a15220063a360730ff5b /src/being/being.cpp
parentd6f42c15612b9d40d0a496b2b34efe66df0b74f9 (diff)
downloadmanaverse-1dfc22f53967ad7e39d42ba8aabe0afa7445476e.tar.gz
manaverse-1dfc22f53967ad7e39d42ba8aabe0afa7445476e.tar.bz2
manaverse-1dfc22f53967ad7e39d42ba8aabe0afa7445476e.tar.xz
manaverse-1dfc22f53967ad7e39d42ba8aabe0afa7445476e.zip
Improve drawing player sprites performance.
Diffstat (limited to 'src/being/being.cpp')
-rw-r--r--src/being/being.cpp42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 57529b734..c20bb4ce1 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -202,6 +202,7 @@ Being::Being(const BeingId id,
mPets(),
mOwner(nullptr),
mSpecialParticle(nullptr),
+ mDrawSprites(),
#ifdef EATHENA_SUPPORT
mChat(nullptr),
mHorseInfo(nullptr),
@@ -349,6 +350,7 @@ Being::~Being()
}
}
mPets.clear();
+ mDrawSprites.clear();
removeAllItemsParticles();
#ifdef EATHENA_SUPPORT
@@ -2579,6 +2581,7 @@ void Being::setSprite(const unsigned int slot,
if (beingEquipmentWindow)
beingEquipmentWindow->updateBeing(this);
}
+ updateDrawSprites();
}
void Being::setSpriteID(const unsigned int slot,
@@ -2984,14 +2987,10 @@ void Being::drawPlayerSprites(Graphics *restrict const graphics,
const int posX,
const int posY) const restrict2
{
- const int sz = CompoundSprite::getNumberOfLayers();
- for (int f = 0; f < sz; f ++)
+ const size_t sz = mDrawSprites.size();
+ for (size_t f = 0; f < sz; f ++)
{
- const int rSprite = mSpriteHide[mSpriteRemap[f]];
- if (rSprite == 1)
- continue;
-
- Sprite *restrict const sprite = mSprites[mSpriteRemap[f]];
+ Sprite *restrict const sprite = mDrawSprites[f];
if (sprite)
{
sprite->setAlpha(mAlpha);
@@ -3004,14 +3003,10 @@ void Being::drawSpritesSDL(Graphics *restrict const graphics,
const int posX,
const int posY) const restrict2
{
- const size_t sz = mSprites.size();
+ const size_t sz = mDrawSprites.size();
for (size_t f = 0; f < sz; f ++)
{
- const int rSprite = mSpriteHide[mSpriteRemap[f]];
- if (rSprite == 1)
- continue;
-
- const Sprite *restrict const sprite = mSprites[mSpriteRemap[f]];
+ const Sprite *restrict const sprite = mDrawSprites[f];
if (sprite)
sprite->draw(graphics, posX, posY);
}
@@ -3570,6 +3565,7 @@ void Being::recalcSpritesOrder() restrict2
}
}
}
+ updateDrawSprites();
}
int Being::searchSlotValue(const std::vector<int> &restrict slotRemap,
@@ -4407,6 +4403,26 @@ void Being::serverRemove() restrict2 noexcept
mTrickDead = false;
}
+void Being::updateDrawSprites()
+{
+ if (mType != ActorType::Player)
+ return;
+ mDrawSprites.clear();
+ const size_t sz = CompoundSprite::getNumberOfLayers();
+ for (size_t f = 0; f < sz; f ++)
+ {
+ const int rSprite = mSpriteHide[mSpriteRemap[f]];
+ if (rSprite == 1)
+ continue;
+
+ Sprite *const sprite = mSprites[mSpriteRemap[f]];
+ if (sprite)
+ {
+ mDrawSprites.push_back(sprite);
+ }
+ }
+}
+
#ifdef EATHENA_SUPPORT
void Being::removeHorse() restrict2
{