summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-03 03:18:21 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-04 03:02:23 +0300
commitebecb0cf42f2066943908fa158ac91527e0e6629 (patch)
tree83dfe4650746e6b31803f7876ab3c0a50179a794 /src
parentfa21c1b65dbe91a1e6ac880db977416162f268df (diff)
downloadmv-ebecb0cf42f2066943908fa158ac91527e0e6629.tar.gz
mv-ebecb0cf42f2066943908fa158ac91527e0e6629.tar.bz2
mv-ebecb0cf42f2066943908fa158ac91527e0e6629.tar.xz
mv-ebecb0cf42f2066943908fa158ac91527e0e6629.zip
Fix hair colors color if old and new hair using different paletes.
Also fix hair replace logic between hairs with different paletes.
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp69
-rw-r--r--src/being.h14
-rw-r--r--src/net/ea/beinghandler.cpp1
-rw-r--r--src/net/tmwa/beinghandler.cpp6
-rw-r--r--src/net/tmwa/charserverhandler.cpp4
5 files changed, 83 insertions, 11 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 6eecb9989..ce6ec1a0e 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -241,7 +241,8 @@ Being::Being(const int id, const Type type, const uint16_t subtype,
mShop(false),
mAway(false),
mInactive(false),
- mNumber(100)
+ mNumber(100),
+ mHairColor(0)
{
for (int f = 0; f < 20; f ++)
@@ -1767,6 +1768,37 @@ void Being::setSpriteColor(const unsigned int slot, const std::string &color)
setSprite(slot, mSpriteIDs[slot], color);
}
+void Being::setHairStyle(const unsigned int slot, const int id)
+{
+// dumpSprites();
+ setSprite(slot, id, ItemDB::get(id).getDyeColorsString(mHairColor));
+// dumpSprites();
+}
+
+void Being::setHairColor(const unsigned int slot, const unsigned char color)
+{
+ mHairColor = color;
+ setSprite(slot, mSpriteIDs[slot], ItemDB::get(
+ getSpriteID(slot)).getDyeColorsString(color));
+}
+
+void Being::dumpSprites()
+{
+ std::vector<int>::const_iterator it1 = mSpriteIDs.begin();
+ const std::vector<int>::const_iterator it1_end = mSpriteIDs.end();
+ StringVectCIter it2 = mSpriteColors.begin();
+ const StringVectCIter it2_end = mSpriteColors.end();
+ std::vector<int>::const_iterator it3 = mSpriteColorsIds.begin();
+ const std::vector<int>::const_iterator it3_end = mSpriteColorsIds.end();
+
+ logger->log("sprites");
+ for (; it1 != it1_end && it2 != it2_end && it3 != it3_end;
+ ++ it1, ++ it2, ++ it3)
+ {
+ logger->log("%d,%s,%d", *it1, (*it2).c_str(), *it3);
+ }
+}
+
void Being::load()
{
// Hairstyles are encoded as negative numbers. Count how far negative
@@ -2181,6 +2213,8 @@ void Being::recalcSpritesOrder()
if (mAction == DEAD)
dir = 9;
+ const unsigned int hairSlot = Net::getCharHandler()->hairSprite();
+
for (unsigned slot = 0; slot < sz; slot ++)
{
oldHide[slot] = mSpriteHide[slot];
@@ -2233,9 +2267,19 @@ void Being::recalcSpritesOrder()
mSpriteHide[remSprite] = repIt->second;
if (repIt->second != 1)
{
- setSprite(remSprite, repIt->second,
- mSpriteColors[remSprite],
- 1, false, true);
+ if (remSprite != hairSlot)
+ {
+ setSprite(remSprite, repIt->second,
+ mSpriteColors[remSprite],
+ 1, false, true);
+ }
+ else
+ {
+ setSprite(remSprite, repIt->second,
+ ItemDB::get(repIt->second)
+ .getDyeColorsString(mHairColor),
+ 1, false, true);
+ }
}
}
}
@@ -2254,9 +2298,20 @@ void Being::recalcSpritesOrder()
mSpriteHide[slot2] = repIt->second;
if (repIt->second != 1)
{
- setSprite(slot2, repIt->second,
- mSpriteColors[slot2],
- 1, false, true);
+ if (slot2 != hairSlot)
+ {
+ setSprite(slot2, repIt->second,
+ mSpriteColors[slot2],
+ 1, false, true);
+ }
+ else
+ {
+ setSprite(slot2, repIt->second,
+ ItemDB::get(repIt->second)
+ .getDyeColorsString(
+ mHairColor),
+ 1, false, true);
+ }
}
}
}
diff --git a/src/being.h b/src/being.h
index 4e78f7eb9..8c1fc81f9 100644
--- a/src/being.h
+++ b/src/being.h
@@ -821,6 +821,17 @@ class Being : public ActorSprite, public ConfigListener
int getSpriteID(const int slot) const;
+ void setHairStyle(const unsigned int slot, const int id);
+
+ void setHairColor(const unsigned int slot,
+ const unsigned char color);
+
+ void setHairColor(const unsigned char color)
+ { mHairColor = color; }
+
+ unsigned char getHairColor() const
+ { return mHairColor; }
+
void recalcSpritesOrder();
static uint8_t genderToInt(const Gender sex);
@@ -911,6 +922,8 @@ class Being : public ActorSprite, public ConfigListener
std::vector<int> &slotRemap,
const int val) const;
+ void dumpSprites();
+
const Type mType;
/** Speech Bubble components */
@@ -971,6 +984,7 @@ class Being : public ActorSprite, public ConfigListener
bool mAway;
bool mInactive;
unsigned mNumber;
+ unsigned char mHairColor;
};
extern std::list<BeingCacheEntry*> beingInfoCache;
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 1dc98f776..d234bca6a 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -265,6 +265,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
// Set these after the gender, as the sprites may be gender-specific
setSprite(dstBeing, EA_SPRITE_HAIR, hairStyle * -1,
ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ dstBeing->setHairColor(hairColor);
setSprite(dstBeing, EA_SPRITE_BOTTOMCLOTHES, headBottom);
setSprite(dstBeing, EA_SPRITE_TOPCLOTHES, headMid);
setSprite(dstBeing, EA_SPRITE_HAT, headTop);
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 2eac3c4a2..f816c9e04 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -299,7 +299,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, bool look2)
dstBeing->setSubtype(static_cast<uint16_t>(id));
break;
case 1: // eAthena LOOK_HAIR
- dstBeing->setSpriteID(SPRITE_HAIR, id *-1);
+ dstBeing->setHairStyle(SPRITE_HAIR, id * -1);
break;
case 2: // Weapon ID in id, Shield ID in id2
dstBeing->setSprite(SPRITE_WEAPON, id, "", 1, true);
@@ -323,8 +323,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, bool look2)
player_node->imitateOutfit(dstBeing, SPRITE_TOPCLOTHES);
break;
case 6: // eAthena LOOK_HAIR_COLOR
- dstBeing->setSpriteColor(SPRITE_HAIR, ItemDB::get(
- dstBeing->getSpriteID(SPRITE_HAIR)).getDyeColorsString(id));
+ dstBeing->setHairColor(SPRITE_HAIR, id);
break;
case 7: // Clothes color
// ignoring it
@@ -541,6 +540,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
//dstBeing->setSprite(SPRITE_MISC2, misc2);
dstBeing->setSprite(SPRITE_HAIR, hairStyle * -1,
ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ dstBeing->setHairColor(hairColor);
player_node->imitateOutfit(dstBeing);
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 235028f71..4261887fb 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -215,8 +215,10 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
const int hat = msg.readInt16(); // head option top
const int topClothes = msg.readInt16();
+ const int hairColor = msg.readInt16();
tempPlayer->setSprite(SPRITE_HAIR, hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(msg.readInt16()));
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ tempPlayer->setHairColor(hairColor);
const int misc2 = msg.readInt16();
tempPlayer->setName(msg.readString(24));