summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-06-21 15:27:11 +0300
committerAndrei Karas <akaras@inbox.ru>2016-06-21 15:27:11 +0300
commitfbadc806e050929f44b54fc2973a28d2fdfc516c (patch)
treeb233a68db2a42025cc68934cd0f71ca21120c581
parent3d524b386e3dd6d89d481749cd0015bff247a703 (diff)
downloadmv-fbadc806e050929f44b54fc2973a28d2fdfc516c.tar.gz
mv-fbadc806e050929f44b54fc2973a28d2fdfc516c.tar.bz2
mv-fbadc806e050929f44b54fc2973a28d2fdfc516c.tar.xz
mv-fbadc806e050929f44b54fc2973a28d2fdfc516c.zip
In Being split setSprite into setSpriteColor and setSpriteColorId.
-rw-r--r--src/actormanager.cpp13
-rw-r--r--src/being/being.cpp115
-rw-r--r--src/being/being.h8
-rw-r--r--src/gui/windows/charcreatedialog.cpp5
-rw-r--r--src/net/eathena/charserverrecv.cpp11
-rw-r--r--src/net/tmwa/beingrecv.cpp73
-rw-r--r--src/net/tmwa/charserverrecv.cpp11
7 files changed, 149 insertions, 87 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 6bae927e9..df87ca937 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -2038,9 +2038,8 @@ Being *ActorManager::cloneBeing(const Being *const srcBeing,
{
const int spriteId = srcBeing->getSpriteID(slot);
const ItemColor color = srcBeing->getSpriteColor(slot);
- dstBeing->setSprite(slot,
+ dstBeing->setSpriteColorId(slot,
spriteId,
- std::string(),
color);
}
const int hairSlot = charServerHandler->hairSprite();
@@ -2048,17 +2047,13 @@ Being *ActorManager::cloneBeing(const Being *const srcBeing,
const ItemColor hairColor = srcBeing->getHairColor();
if (hairStyle != 0)
{
- dstBeing->setSprite(hairSlot,
+ dstBeing->setSpriteColor(hairSlot,
hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor),
- ItemColor_one);
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
}
else
{
- dstBeing->setSprite(hairSlot,
- 0,
- std::string(),
- ItemColor_one);
+ dstBeing->unSetSprite(hairSlot);
}
dstBeing->setHairColor(hairColor);
return dstBeing;
diff --git a/src/being/being.cpp b/src/being/being.cpp
index e0980e4d7..4e6795d70 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -504,10 +504,9 @@ void Being::setSubtype(const BeingTypeId subtype,
setRaceName(info.getName());
if (charServerHandler)
{
- setSprite(charServerHandler->baseSprite(),
+ setSpriteColor(charServerHandler->baseSprite(),
id,
- info.getColor(fromInt(mLook, ItemColor)),
- ItemColor_one);
+ info.getColor(fromInt(mLook, ItemColor)));
}
}
}
@@ -2616,10 +2615,9 @@ void Being::unSetSprite(const unsigned int slot) restrict2
}
// set sprite id, colors, reset cards
-void Being::setSprite(const unsigned int slot,
- const int id,
- std::string color,
- ItemColor colorId) restrict2
+void Being::setSpriteColor(const unsigned int slot,
+ const int id,
+ std::string color) restrict2
{
if (!charServerHandler || slot >= charServerHandler->maxSprite())
return;
@@ -2672,9 +2670,103 @@ void Being::setSprite(const unsigned int slot,
if (!filename.empty())
{
- if (color.empty())
- color = info.getDyeColorsString(colorId);
+ equipmentSprite = AnimatedSprite::delayedLoad(
+ paths.getStringValue("sprites").append(
+ combineDye(filename, color)));
+ }
+
+ if (equipmentSprite)
+ {
+ equipmentSprite->setSpriteDirection(getSpriteDirection());
+ startTime = getStartTime();
+ lastTime = getLastTime();
+ }
+
+ CompoundSprite::setSprite(slot, equipmentSprite);
+ mSpriteDraw[slot] = id;
+
+ addItemParticles(id, info.getDisplay());
+
+ setAction(mAction, 0);
+ if (equipmentSprite)
+ {
+ if (lastTime > 0)
+ {
+ equipmentSprite->setLastTime(startTime);
+ equipmentSprite->update(lastTime);
+ }
+ }
+ }
+
+ BeingSlot &beingSlot = mSlots[slot];
+ beingSlot.spriteId = id;
+ beingSlot.color = color;
+ beingSlot.colorId = ItemColor_one;
+ beingSlot.cardsId = CardsList(nullptr);
+ recalcSpritesOrder();
+ if (beingEquipmentWindow)
+ beingEquipmentWindow->updateBeing(this);
+}
+
+// set sprite id, colors, reset cards
+void Being::setSpriteColorId(const unsigned int slot,
+ const int id,
+ ItemColor colorId) 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;
+
+ std::string color;
+
+ // id = 0 means unequip
+ if (id == 0)
+ {
+ removeSprite(slot);
+ mSpriteDraw[slot] = 0;
+
+ const int id1 = mSlots[slot].spriteId;
+ if (id1)
+ {
+ const ItemInfo &info = ItemDB::get(id1);
+ if (mMap &&
+ mType == ActorType::Player)
+ {
+ const BeingId pet = fromInt(info.getPet(), BeingId);
+ if (pet != BeingId_zero)
+ removePet(pet);
+ }
+ removeItemParticles(id1);
+ }
+ }
+ 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 (mType == ActorType::Player)
+ {
+ const BeingId pet = fromInt(info.getPet(), BeingId);
+ if (pet != BeingId_zero)
+ addPet(pet);
+ }
+
+ if (!filename.empty())
+ {
+ color = info.getDyeColorsString(colorId);
equipmentSprite = AnimatedSprite::delayedLoad(
paths.getStringValue("sprites").append(
combineDye(filename, color)));
@@ -2898,10 +2990,9 @@ void Being::setHairColorSpriteID(const unsigned int slot,
const int id) restrict2
{
BeingSlot &beingSlot = mSlots[slot];
- setSprite(slot,
+ setSpriteColor(slot,
id,
- beingSlot.color,
- ItemColor_one);
+ beingSlot.color);
}
void Being::setSpriteColor(const unsigned int slot,
diff --git a/src/being/being.h b/src/being/being.h
index 03626bc75..e39baa079 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -320,6 +320,14 @@ class Being notfinal : public ActorSprite,
std::string color,
ItemColor colorId) restrict2;
+ void setSpriteColor(const unsigned int slot,
+ const int id,
+ std::string color) restrict2;
+
+ void setSpriteColorId(const unsigned int slot,
+ const int id,
+ ItemColor colorId) restrict2;
+
void setSpriteCards(const unsigned int slot,
const int id,
std::string color,
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index 762d76c00..af23b6b28 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -766,10 +766,9 @@ void CharCreateDialog::updateHair()
mHairColorNameLabel->resizeTo(150, 150);
}
- mPlayer->setSprite(charServerHandler->hairSprite(),
+ mPlayer->setSpriteColor(charServerHandler->hairSprite(),
mHairStyle * -1,
- item.getDyeColorsString(fromInt(mHairColor, ItemColor)),
- ItemColor_one);
+ item.getDyeColorsString(fromInt(mHairColor, ItemColor)));
}
void CharCreateDialog::updateRace()
diff --git a/src/net/eathena/charserverrecv.cpp b/src/net/eathena/charserverrecv.cpp
index 3ddb6af95..38cca2208 100644
--- a/src/net/eathena/charserverrecv.cpp
+++ b/src/net/eathena/charserverrecv.cpp
@@ -129,10 +129,8 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg,
const int option A_UNUSED = (msg.readInt16("weapon") | 1) ^ 1;
const int weapon = 0;
- tempPlayer->setSprite(SPRITE_BODY,
- weapon,
- "",
- ItemColor_one);
+ tempPlayer->setSpriteId(SPRITE_BODY,
+ weapon);
tempPlayer->setWeaponId(weapon);
data.mAttributes[Attributes::LEVEL] = msg.readInt16("level");
@@ -151,11 +149,10 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg,
}
else
{
- tempPlayer->setSprite(SPRITE_HAIR_COLOR,
+ tempPlayer->setSpriteColor(SPRITE_HAIR_COLOR,
hairStyle * -1,
ItemDB::get(-hairStyle).getDyeColorsString(
- color),
- ItemColor_one);
+ color));
}
const uint16_t look = msg.readInt16("clothes color");
diff --git a/src/net/tmwa/beingrecv.cpp b/src/net/tmwa/beingrecv.cpp
index 2ece0e993..8b073ea7d 100644
--- a/src/net/tmwa/beingrecv.cpp
+++ b/src/net/tmwa/beingrecv.cpp
@@ -127,7 +127,6 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg,
if (dstBeing->getType() == ActorType::Player)
dstBeing->setOtherTime();
- const std::string color;
switch (type)
{
case 0: // change race
@@ -143,34 +142,26 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg,
break;
}
case 2: // Weapon ID in id, Shield ID in id2
- dstBeing->setSprite(SPRITE_BODY,
- id,
- "",
- ItemColor_one);
+ dstBeing->setSpriteId(SPRITE_BODY,
+ id);
dstBeing->setWeaponId(id);
dstBeing->setSpriteId(SPRITE_FLOOR,
id2);
localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
break;
case 3: // Change lower headgear for eAthena, pants for us
- dstBeing->setSprite(SPRITE_WEAPON,
- id,
- color,
- ItemColor_one);
+ dstBeing->setSpriteId(SPRITE_WEAPON,
+ id);
localPlayer->imitateOutfit(dstBeing, SPRITE_WEAPON);
break;
case 4: // Change upper headgear for eAthena, hat for us
- dstBeing->setSprite(SPRITE_CLOTHES_COLOR,
- id,
- color,
- ItemColor_one);
+ dstBeing->setSpriteId(SPRITE_CLOTHES_COLOR,
+ id);
localPlayer->imitateOutfit(dstBeing, SPRITE_CLOTHES_COLOR);
break;
case 5: // Change middle headgear for eathena, armor for us
- dstBeing->setSprite(SPRITE_HEAD_BOTTOM,
- id,
- color,
- ItemColor_one);
+ dstBeing->setSpriteId(SPRITE_HEAD_BOTTOM,
+ id);
localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_BOTTOM);
break;
case 6: // eAthena LOOK_HAIR_COLOR
@@ -181,59 +172,43 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg,
// ignoring it
break;
case 8: // eAthena LOOK_SHIELD
- dstBeing->setSprite(SPRITE_FLOOR,
- id,
- color,
- ItemColor_one);
+ dstBeing->setSpriteId(SPRITE_FLOOR,
+ id);
localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
break;
case 9: // eAthena LOOK_SHOES
- dstBeing->setSprite(SPRITE_HAIR,
- id,
- color,
- ItemColor_one);
+ dstBeing->setSpriteId(SPRITE_HAIR,
+ id);
localPlayer->imitateOutfit(dstBeing, SPRITE_HAIR);
break;
case 10: // LOOK_GLOVES
- dstBeing->setSprite(SPRITE_SHOES,
- id,
- color,
- ItemColor_one);
+ dstBeing->setSpriteId(SPRITE_SHOES,
+ id);
localPlayer->imitateOutfit(dstBeing, SPRITE_SHOES);
break;
case 11: // LOOK_CAPE
- dstBeing->setSprite(SPRITE_SHIELD,
- id,
- color,
- ItemColor_one);
+ dstBeing->setSpriteId(SPRITE_SHIELD,
+ id);
localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD);
break;
case 12:
- dstBeing->setSprite(SPRITE_HEAD_TOP,
- id,
- color,
- ItemColor_one);
+ dstBeing->setSpriteId(SPRITE_HEAD_TOP,
+ id);
localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_TOP);
break;
case 13:
- dstBeing->setSprite(SPRITE_HEAD_MID,
- id,
- color,
- ItemColor_one);
+ dstBeing->setSpriteId(SPRITE_HEAD_MID,
+ id);
localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_MID);
break;
case 14:
- dstBeing->setSprite(SPRITE_ROBE,
- id,
- color,
- ItemColor_one);
+ dstBeing->setSpriteId(SPRITE_ROBE,
+ id);
localPlayer->imitateOutfit(dstBeing, SPRITE_ROBE);
break;
case 15:
- dstBeing->setSprite(SPRITE_EVOL2,
- id,
- color,
- ItemColor_one);
+ dstBeing->setSpriteId(SPRITE_EVOL2,
+ id);
localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL2);
break;
case 16:
diff --git a/src/net/tmwa/charserverrecv.cpp b/src/net/tmwa/charserverrecv.cpp
index 242e3e489..e54b092e0 100644
--- a/src/net/tmwa/charserverrecv.cpp
+++ b/src/net/tmwa/charserverrecv.cpp
@@ -104,10 +104,8 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg,
const uint16_t look = msg.readUInt8("look");
tempPlayer->setSubtype(fromInt(race, BeingTypeId), look);
const uint16_t weapon = msg.readInt16("weapon");
- tempPlayer->setSprite(SPRITE_BODY,
- weapon,
- "",
- ItemColor_one);
+ tempPlayer->setSpriteId(SPRITE_BODY,
+ weapon);
tempPlayer->setWeaponId(weapon);
data.mAttributes[Attributes::LEVEL] = msg.readInt16("level");
@@ -128,10 +126,9 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg,
}
else
{
- tempPlayer->setSprite(SPRITE_HAIR_COLOR,
+ tempPlayer->setSpriteColor(SPRITE_HAIR_COLOR,
hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor),
- ItemColor_one);
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
}
tempPlayer->setHairColor(hairColor);