From f6e76f469a81ff2d9e3714d39d1a8f4012cda2b8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 27 May 2016 23:28:11 +0300 Subject: Fix some false positive asserts in working with hair style equal to zero. --- src/net/eathena/beingrecv.cpp | 48 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'src/net/eathena/beingrecv.cpp') 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); -- cgit v1.2.3-70-g09d2