summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-05-31 17:31:46 +0300
committerAndrei Karas <akaras@inbox.ru>2012-05-31 17:31:46 +0300
commit02677a3b9b3abefb84e24023697466c892c6ded4 (patch)
tree4e563d4fb0af1a8fb8e99a5b97c58281a21d3182
parentd4e5b8fb2b9b72e750845b874f3e60d3aea31543 (diff)
downloadmanaplus-02677a3b9b3abefb84e24023697466c892c6ded4.tar.gz
manaplus-02677a3b9b3abefb84e24023697466c892c6ded4.tar.bz2
manaplus-02677a3b9b3abefb84e24023697466c892c6ded4.tar.xz
manaplus-02677a3b9b3abefb84e24023697466c892c6ded4.zip
Add support for each hair style own palete.
-rw-r--r--src/being.cpp8
-rw-r--r--src/being.h2
-rw-r--r--src/gui/charcreatedialog.cpp2
-rw-r--r--src/net/ea/beinghandler.cpp4
-rw-r--r--src/net/tmwa/beinghandler.cpp8
-rw-r--r--src/net/tmwa/charserverhandler.cpp4
-rw-r--r--src/resources/colordb.cpp25
-rw-r--r--src/resources/colordb.h2
-rw-r--r--src/resources/itemdb.cpp13
-rw-r--r--src/resources/iteminfo.h2
10 files changed, 35 insertions, 35 deletions
diff --git a/src/being.cpp b/src/being.cpp
index c58cc4696..8414d93a6 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -2656,6 +2656,14 @@ Gender Being::intToGender(int sex)
}
}
+int Being::getSpriteID(int slot)
+{
+ if (slot < 0 || (unsigned)slot >= mSpriteIDs.size())
+ return -1;
+
+ return mSpriteIDs[slot];
+}
+
BeingEquipBackend::BeingEquipBackend(Being *being):
mBeing(being)
{
diff --git a/src/being.h b/src/being.h
index ee4efef0f..6337e30f1 100644
--- a/src/being.h
+++ b/src/being.h
@@ -780,6 +780,8 @@ class Being : public ActorSprite, public ConfigListener
std::string getRaceName()
{ return mRaceName; }
+ int getSpriteID(int slot);
+
static int genderToInt(Gender sex);
static Gender intToGender(int sex);
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index db6916a62..52e59f095 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -513,7 +513,7 @@ void CharCreateDialog::updateHair()
mHairColorNameLabel->adjustSize();
mPlayer->setSprite(Net::getCharHandler()->hairSprite(),
- mHairStyle * -1, ColorDB::getHairColor(mHairColor));
+ mHairStyle * -1, item.getDyeColorsString(mHairColor));
}
void CharCreateDialog::updateRace()
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index a773ef0b1..1e73f5670 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -50,6 +50,8 @@
#include "net/net.h"
#include "resources/colordb.h"
+#include "resources/itemdb.h"
+#include "resources/iteminfo.h"
#include <iostream>
@@ -264,7 +266,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
dstBeing->setGender(Being::intToGender(gender));
// Set these after the gender, as the sprites may be gender-specific
setSprite(dstBeing, EA_SPRITE_HAIR, hairStyle * -1,
- ColorDB::getHairColor(hairColor));
+ ItemDB::get(-hairStyle).getDyeColorsString(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 5eb02d299..61924f1f4 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -49,6 +49,8 @@
#include "net/tmwa/protocol.h"
#include "resources/colordb.h"
+#include "resources/itemdb.h"
+#include "resources/iteminfo.h"
#include <iostream>
@@ -325,8 +327,8 @@ 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,
- ColorDB::getHairColor(id));
+ dstBeing->setSpriteColor(SPRITE_HAIR, ItemDB::get(
+ dstBeing->getSpriteID(SPRITE_HAIR)).getDyeColorsString(id));
break;
case 7: // Clothes color
// ignoring it
@@ -540,7 +542,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
//dstBeing->setSprite(SPRITE_MISC1, misc1);
//dstBeing->setSprite(SPRITE_MISC2, misc2);
dstBeing->setSprite(SPRITE_HAIR, hairStyle * -1,
- ColorDB::getHairColor(hairColor));
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
player_node->imitateOutfit(dstBeing);
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 04274a70b..e18c33a5a 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -38,6 +38,8 @@
#include "net/tmwa/protocol.h"
#include "resources/colordb.h"
+#include "resources/itemdb.h"
+#include "resources/iteminfo.h"
#include "utils/dtor.h"
@@ -214,7 +216,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
int topClothes = msg.readInt16();
tempPlayer->setSprite(SPRITE_HAIR, hairStyle * -1,
- ColorDB::getHairColor(msg.readInt16()));
+ ItemDB::get(-hairStyle).getDyeColorsString(msg.readInt16()));
int misc2 = msg.readInt16();
tempPlayer->setName(msg.readString(24));
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
index 66c8de0a2..2b9a21500 100644
--- a/src/resources/colordb.cpp
+++ b/src/resources/colordb.cpp
@@ -155,31 +155,6 @@ void ColorDB::unload()
mLoaded = false;
}
-std::string &ColorDB::getHairColor(int id)
-{
- if (!mLoaded)
- load();
-
- ColorListsIterator it = mColorLists.find("hair");
- if (it == mColorLists.end())
- {
- logger->log1("ColorDB: Error, hair colors list empty");
- return mFail;
- }
-
- ColorIterator i = (*it).second.find(id);
-
- if (i == (*it).second.end())
- {
- logger->log("ColorDB: Error, unknown dye ID# %d", id);
- return mFail;
- }
- else
- {
- return i->second.color;
- }
-}
-
std::string &ColorDB::getHairColorName(int id)
{
if (!mLoaded)
diff --git a/src/resources/colordb.h b/src/resources/colordb.h
index ade4227f8..27ca6173a 100644
--- a/src/resources/colordb.h
+++ b/src/resources/colordb.h
@@ -68,8 +68,6 @@ namespace ColorDB
*/
void unload();
- std::string &getHairColor(int id);
-
std::string &getHairColorName(int id);
int getHairSize();
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 8d4cf8002..cf05a28f0 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -213,9 +213,20 @@ void ItemDB::load()
// std::string removeSprite = XML::getProperty(node, "removeSprite", "");
std::string colors;
if (serverVersion >= 1)
+ {
colors = XML::getProperty(node, "colors", "");
+
+ // check for empty hair palete
+ if (colors.empty() && id <= -1 && id > -100)
+ colors = "hair";
+ }
else
- colors = "";
+ {
+ if (id <= -1 && id > -100)
+ colors = "hair";
+ else
+ colors = "";
+ }
std::string tags[3];
tags[0] = XML::getProperty(node, "tag",
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 9d1f94954..33727b136 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -244,7 +244,7 @@ class ItemInfo
SpriteToItemMap *getSpriteToItemReplaceMap(int directions) const;
- std::string getDyeString(int color) const;
+// std::string getDyeString(int color) const;
std::string getDyeColorsString(int color) const;