summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being/being.cpp64
1 files changed, 59 insertions, 5 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index fae5224b6..dea303af5 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -2995,12 +2995,66 @@ void Being::setHairColorSpriteID(const unsigned int slot,
void Being::setSpriteColor(const unsigned int slot,
const std::string &restrict color) restrict2
{
+ if (!charServerHandler || slot >= charServerHandler->maxSprite())
+ return;
+
+ if (slot >= CAST_U32(mSprites.size()))
+ ensureSize(slot + 1);
+
+ if (slot >= CAST_U32(mSlots.size()))
+ mSlots.resize(slot + 1, BeingSlot());
+
+ // disabled for now, because it may broke replace/reorder sprites logic
+// if (slot && mSlots[slot].spriteId == id)
+// return;
+
BeingSlot &beingSlot = mSlots[slot];
- setSpriteCards(slot,
- beingSlot.spriteId,
- color,
- ItemColor_one,
- beingSlot.cardsId);
+ const int id = beingSlot.spriteId;
+
+ // id = 0 means unequip
+ if (id == 0)
+ {
+ }
+ else
+ {
+ 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, color)));
+ }
+
+ if (equipmentSprite)
+ {
+ equipmentSprite->setSpriteDirection(getSpriteDirection());
+ startTime = getStartTime();
+ lastTime = getLastTime();
+ }
+
+ CompoundSprite::setSprite(slot, equipmentSprite);
+
+ setAction(mAction, 0);
+ if (equipmentSprite)
+ {
+ if (lastTime > 0)
+ {
+ equipmentSprite->setLastTime(startTime);
+ equipmentSprite->update(lastTime);
+ }
+ }
+ }
+
+ beingSlot.color = color;
+ beingSlot.colorId = ItemColor_one;
+ if (beingEquipmentWindow)
+ beingEquipmentWindow->updateBeing(this);
}
void Being::setHairStyle(const unsigned int slot,