summaryrefslogtreecommitdiff
path: root/src/net/tmwa
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/tmwa
parentcd327e877804a824db51d1e0831ad9e13b0e18b3 (diff)
downloadmanaplus-f6e76f469a81ff2d9e3714d39d1a8f4012cda2b8.tar.gz
manaplus-f6e76f469a81ff2d9e3714d39d1a8f4012cda2b8.tar.bz2
manaplus-f6e76f469a81ff2d9e3714d39d1a8f4012cda2b8.tar.xz
manaplus-f6e76f469a81ff2d9e3714d39d1a8f4012cda2b8.zip
Fix some false positive asserts in working with hair style equal to zero.
Diffstat (limited to 'src/net/tmwa')
-rw-r--r--src/net/tmwa/beingrecv.cpp74
-rw-r--r--src/net/tmwa/charserverrecv.cpp14
2 files changed, 76 insertions, 12 deletions
diff --git a/src/net/tmwa/beingrecv.cpp b/src/net/tmwa/beingrecv.cpp
index 04c4a0444..cb5eefd92 100644
--- a/src/net/tmwa/beingrecv.cpp
+++ b/src/net/tmwa/beingrecv.cpp
@@ -316,8 +316,18 @@ void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg)
dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- dstBeing->updateSprite(SPRITE_HAIR_COLOR, hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ if (hairStyle == 0)
+ {
+ dstBeing->updateSprite(SPRITE_HAIR_COLOR,
+ 0,
+ std::string());
+ }
+ else
+ {
+ dstBeing->updateSprite(SPRITE_HAIR_COLOR,
+ hairStyle * -1,
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ }
dstBeing->setHairColor(hairColor);
}
localPlayer->imitateOutfit(dstBeing);
@@ -448,8 +458,18 @@ void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg)
dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- dstBeing->updateSprite(SPRITE_HAIR_COLOR, hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ if (hairStyle == 0)
+ {
+ dstBeing->updateSprite(SPRITE_HAIR_COLOR,
+ 0,
+ std::string());
+ }
+ else
+ {
+ dstBeing->updateSprite(SPRITE_HAIR_COLOR,
+ hairStyle * -1,
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ }
dstBeing->setHairColor(hairColor);
}
localPlayer->imitateOutfit(dstBeing);
@@ -580,8 +600,18 @@ void BeingRecv::processPlayerMove(Net::MessageIn &msg)
dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- dstBeing->updateSprite(SPRITE_HAIR_COLOR, hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ if (hairStyle == 0)
+ {
+ dstBeing->updateSprite(SPRITE_HAIR_COLOR,
+ 0,
+ std::string());
+ }
+ else
+ {
+ dstBeing->updateSprite(SPRITE_HAIR_COLOR,
+ hairStyle * -1,
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ }
dstBeing->setHairColor(hairColor);
}
localPlayer->imitateOutfit(dstBeing);
@@ -794,8 +824,20 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
gender &= 3;
dstBeing->setGender(Being::intToGender(gender));
// 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));
+ }
dstBeing->setHairColor(hairColor);
Ea::BeingRecv::setSprite(dstBeing, SPRITE_WEAPON, headBottom);
Ea::BeingRecv::setSprite(dstBeing, SPRITE_HEAD_BOTTOM, headMid);
@@ -995,8 +1037,20 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
gender &= 3;
dstBeing->setGender(Being::intToGender(gender));
// 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));
+ }
dstBeing->setHairColor(hairColor);
Ea::BeingRecv::setSprite(dstBeing, SPRITE_WEAPON, headBottom);
Ea::BeingRecv::setSprite(dstBeing, SPRITE_HEAD_BOTTOM, headMid);
diff --git a/src/net/tmwa/charserverrecv.cpp b/src/net/tmwa/charserverrecv.cpp
index 5032e4c39..428693678 100644
--- a/src/net/tmwa/charserverrecv.cpp
+++ b/src/net/tmwa/charserverrecv.cpp
@@ -118,8 +118,18 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg,
const ItemColor hairColor = fromInt(
msg.readUInt8("hair color"), ItemColor);
msg.readUInt8("unused");
- tempPlayer->setSprite(SPRITE_HAIR_COLOR, hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ if (hairStyle == 0)
+ {
+ tempPlayer->setSprite(SPRITE_HAIR_COLOR,
+ 0,
+ std::string());
+ }
+ else
+ {
+ tempPlayer->setSprite(SPRITE_HAIR_COLOR,
+ hairStyle * -1,
+ ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
+ }
tempPlayer->setHairColor(hairColor);
const int misc2 = msg.readInt16("misc2");