summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-05-27 23:28:11 +0300
committerAndrei Karas <akaras@inbox.ru>2016-05-27 23:28:11 +0300
commitf6e76f469a81ff2d9e3714d39d1a8f4012cda2b8 (patch)
treecf512c32dbc37283ce8c16901fb4df0082508d28 /src/net/eathena
parentcd327e877804a824db51d1e0831ad9e13b0e18b3 (diff)
downloadplus-f6e76f469a81ff2d9e3714d39d1a8f4012cda2b8.tar.gz
plus-f6e76f469a81ff2d9e3714d39d1a8f4012cda2b8.tar.bz2
plus-f6e76f469a81ff2d9e3714d39d1a8f4012cda2b8.tar.xz
plus-f6e76f469a81ff2d9e3714d39d1a8f4012cda2b8.zip
Fix some false positive asserts in working with hair style equal to zero.
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/beingrecv.cpp48
-rw-r--r--src/net/eathena/charserverrecv.cpp13
2 files changed, 52 insertions, 9 deletions
diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp
index 5c5e18ce8..5d4c59d00 100644
--- a/src/net/eathena/beingrecv.cpp
+++ b/src/net/eathena/beingrecv.cpp
@@ -380,8 +380,20 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
dstBeing->setGender(Being::intToGender(gender));
dstBeing->setHairColor(hairColor);
// Set these after the gender, as the sprites may be gender-specific
- Ea::BeingRecv::setSprite(dstBeing, SPRITE_HAIR_COLOR, hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ if (hairStyle == 0)
+ {
+ Ea::BeingRecv::setSprite(dstBeing,
+ SPRITE_HAIR_COLOR,
+ 0,
+ std::string());
+ }
+ else
+ {
+ Ea::BeingRecv::setSprite(dstBeing,
+ SPRITE_HAIR_COLOR,
+ hairStyle * -1,
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ }
Ea::BeingRecv::setSprite(dstBeing, SPRITE_WEAPON, headBottom);
Ea::BeingRecv::setSprite(dstBeing, SPRITE_HEAD_BOTTOM, headMid);
Ea::BeingRecv::setSprite(dstBeing, SPRITE_CLOTHES_COLOR, headTop);
@@ -568,8 +580,20 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
dstBeing->setGender(Being::intToGender(gender));
dstBeing->setHairColor(hairColor);
// Set these after the gender, as the sprites may be gender-specific
- Ea::BeingRecv::setSprite(dstBeing, SPRITE_HAIR_COLOR, hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ if (hairStyle == 0)
+ {
+ Ea::BeingRecv::setSprite(dstBeing,
+ SPRITE_HAIR_COLOR,
+ 0,
+ std::string());
+ }
+ else
+ {
+ Ea::BeingRecv::setSprite(dstBeing,
+ SPRITE_HAIR_COLOR,
+ hairStyle * -1,
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ }
if (!serverFeatures->haveMove3())
{
Ea::BeingRecv::setSprite(dstBeing, SPRITE_WEAPON, headBottom);
@@ -758,8 +782,20 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
dstBeing->setGender(Being::intToGender(gender));
dstBeing->setHairColor(hairColor);
// Set these after the gender, as the sprites may be gender-specific
- Ea::BeingRecv::setSprite(dstBeing, SPRITE_HAIR_COLOR, hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ if (hairStyle == 0)
+ {
+ Ea::BeingRecv::setSprite(dstBeing,
+ SPRITE_HAIR_COLOR,
+ 0,
+ std::string());
+ }
+ else
+ {
+ Ea::BeingRecv::setSprite(dstBeing,
+ SPRITE_HAIR_COLOR,
+ hairStyle * -1,
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ }
Ea::BeingRecv::setSprite(dstBeing, SPRITE_WEAPON, headBottom);
Ea::BeingRecv::setSprite(dstBeing, SPRITE_HEAD_BOTTOM, headMid);
Ea::BeingRecv::setSprite(dstBeing, SPRITE_CLOTHES_COLOR, headTop);
diff --git a/src/net/eathena/charserverrecv.cpp b/src/net/eathena/charserverrecv.cpp
index a1417b9c8..fcf90acc9 100644
--- a/src/net/eathena/charserverrecv.cpp
+++ b/src/net/eathena/charserverrecv.cpp
@@ -141,9 +141,16 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg,
const ItemColor color = fromInt(msg.readInt16("hair color"), ItemColor);
tempPlayer->setHairColor(color);
- tempPlayer->setSprite(SPRITE_HAIR_COLOR, hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(
- color));
+ if (hairStyle == 0)
+ {
+ tempPlayer->setSprite(SPRITE_HAIR_COLOR, 0, std::string());
+ }
+ else
+ {
+ tempPlayer->setSprite(SPRITE_HAIR_COLOR, hairStyle * -1,
+ ItemDB::get(-hairStyle).getDyeColorsString(
+ color));
+ }
const uint16_t look = msg.readInt16("clothes color");
tempPlayer->setSubtype(fromInt(race, BeingTypeId), look);