summaryrefslogtreecommitdiff
path: root/src/being/being.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-06-21 16:37:27 +0300
committerAndrei Karas <akaras@inbox.ru>2016-06-21 16:37:27 +0300
commite9b904692840a1e1f39b5e5b449fcc686d0441af (patch)
tree42a30cd3dcfa3c1ad360c18343828c054b59b9b5 /src/being/being.cpp
parentf6e348a03e14d2e7d91774802f3a4153333d20cb (diff)
downloadmv-e9b904692840a1e1f39b5e5b449fcc686d0441af.tar.gz
mv-e9b904692840a1e1f39b5e5b449fcc686d0441af.tar.bz2
mv-e9b904692840a1e1f39b5e5b449fcc686d0441af.tar.xz
mv-e9b904692840a1e1f39b5e5b449fcc686d0441af.zip
Improve Being::setGender.
Diffstat (limited to 'src/being/being.cpp')
-rw-r--r--src/being/being.cpp52
1 files changed, 45 insertions, 7 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index dea303af5..08f1acddd 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -3253,23 +3253,61 @@ BeingCacheEntry* Being::getCacheEntry(const BeingId id)
void Being::setGender(const GenderT gender) restrict2
{
+ if (!charServerHandler)
+ return;
+
if (gender != mGender)
{
mGender = gender;
+ const unsigned int sz = CAST_U32(mSlots.size());
+
+ if (sz > CAST_U32(mSprites.size()))
+ ensureSize(sz);
+
// Reload all subsprites
for (unsigned int i = 0;
- i < CAST_U32(mSlots.size());
+ i < sz;
i++)
{
BeingSlot &beingSlot = mSlots[i];
- if (beingSlot.spriteId != 0)
+ const int id = beingSlot.spriteId;
+ if (id != 0)
{
- setSpriteCards(i,
- beingSlot.spriteId,
- beingSlot.color,
- ItemColor_one,
- beingSlot.cardsId);
+ const ItemInfo &info = ItemDB::get(id);
+ const std::string &restrict filename = info.getSprite(
+ mGender, mSubType);
+ int lastTime = 0;
+ int startTime = 0;
+ AnimatedSprite *restrict equipmentSprite = nullptr;
+
+ if (!filename.empty())
+ {
+ equipmentSprite = AnimatedSprite::delayedLoad(
+ paths.getStringValue("sprites").append(
+ combineDye(filename, beingSlot.color)));
+ }
+
+ if (equipmentSprite)
+ {
+ equipmentSprite->setSpriteDirection(getSpriteDirection());
+ startTime = getStartTime();
+ lastTime = getLastTime();
+ }
+
+ CompoundSprite::setSprite(i, equipmentSprite);
+ setAction(mAction, 0);
+ if (equipmentSprite)
+ {
+ if (lastTime > 0)
+ {
+ equipmentSprite->setLastTime(startTime);
+ equipmentSprite->update(lastTime);
+ }
+ }
+
+ if (beingEquipmentWindow)
+ beingEquipmentWindow->updateBeing(this);
}
}