Core/Misc: Barbershop fixes

* Fixed selection validation
* Implemented new 6.0 feature allowing to change face
* Fixed cost calculation
This commit is contained in:
Shauren
2015-04-21 00:24:26 +02:00
parent ad945dc476
commit 4208c0d839
7 changed files with 33 additions and 22 deletions
+1 -1
View File
@@ -153,7 +153,7 @@ struct BarberShopStyleEntry
uint32 Type; // 1 value 0 -> hair, value 2 -> facialhair
//char* DisplayName_lang; // 2
//char* Description_lang // 3
//float CostModifier; // 4
float CostModifier; // 4
uint32 Race; // 5
uint32 Sex; // 6
uint32 Data; // 7 (real ID to hair/facial hair)
+1 -1
View File
@@ -31,7 +31,7 @@ char const ArmorLocationfmt[] = "nfffff";
char const AuctionHouseEntryfmt[] = "niiix";
char const BankBagSlotPricesEntryfmt[] = "ni";
char const BannedAddOnsfmt[] = "nxxxxxxxxxx";
char const BarberShopStyleEntryfmt[] = "nixxxiii";
char const BarberShopStyleEntryfmt[] = "nixxfiii";
char const BattlemasterListEntryfmt[] = "niiiiiiiiiiiiiiiiixsiiiixxxxxxx";
char const CharStartOutfitEntryfmt[] = "dbbbXiiiiiiiiiiiiiiiiiiiiiiiiii";
char const CharSectionsEntryfmt[] = "diiixxxiii";
+15 -12
View File
@@ -24212,7 +24212,7 @@ bool Player::CanCaptureTowerPoint()
IsAlive()); // live player
}
uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin)
uint32 Player::GetBarberShopCost(BarberShopStyleEntry const* newHairStyle, uint8 newHairColor, BarberShopStyleEntry const* newFacialHair, BarberShopStyleEntry const* newSkin /*= nullptr*/, BarberShopStyleEntry const* newFace /*= nullptr*/)
{
uint8 level = getLevel();
@@ -24223,30 +24223,33 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n
uint8 haircolor = GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_COLOR_ID);
uint8 facialhair = GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE);
uint8 skincolor = GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID);
uint8 face = GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID);
if ((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair) && (!newSkin || (newSkin->Data == skincolor)))
if ((hairstyle == newHairStyle->Data) && (haircolor == newHairColor) && (facialhair == newFacialHair->Data) && (!newSkin || (newSkin->Data == skincolor)) && (!newFace || (newFace->Data == face)))
return 0;
GtBarberShopCostBaseEntry const* bsc = sGtBarberShopCostBaseStore.EvaluateTable(level - 1, 0);
if (!bsc) // shouldn't happen
return 0xFFFFFFFF;
float cost = 0;
uint32 cost = 0;
if (hairstyle != newhairstyle)
cost += bsc->cost; // full price
if (hairstyle != newHairStyle->Data)
cost += uint32(bsc->cost * newHairStyle->CostModifier);
if ((haircolor != newhaircolor) && (hairstyle == newhairstyle))
cost += bsc->cost * 0.5f; // +1/2 of price
if ((haircolor != newHairColor) && (hairstyle == newHairStyle->Data))
cost += uint32(bsc->cost * 0.5f); // +1/2 of price
if (facialhair != newfacialhair)
cost += bsc->cost * 0.75f; // +3/4 of price
if (facialhair != newFacialHair->Data)
cost += uint32(bsc->cost * newFacialHair->CostModifier);
if (newSkin && skincolor != newSkin->Data)
cost += bsc->cost * 0.75f; // +5/6 of price
cost += uint32(bsc->cost * newSkin->CostModifier);
return uint32(cost);
if (newFace && face != newFace->Data)
cost += uint32(bsc->cost * newFace->CostModifier);
return cost;
}
void Player::InitGlyphsForLevel()
+1 -1
View File
@@ -1374,7 +1374,7 @@ class Player : public Unit, public GridObject<Player>
uint8 GetChatFlags() const;
std::string autoReplyMsg;
uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin=NULL);
uint32 GetBarberShopCost(BarberShopStyleEntry const* newHairStyle, uint8 newHairColor, BarberShopStyleEntry const* newFacialHair, BarberShopStyleEntry const* newSkin = nullptr, BarberShopStyleEntry const* newFace = nullptr);
PlayerSocial* GetSocial() { return m_social; }
void RemoveSocial();
+13 -5
View File
@@ -1396,21 +1396,27 @@ void WorldSession::HandleAlterAppearance(WorldPackets::Character::AlterApperance
TC_LOG_DEBUG("network", "CMSG_ALTER_APPEARANCE");
BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(packet.NewHairStyle);
if (!bs_hair || bs_hair->Type != 0 || bs_hair->Race != _player->getRace() || bs_hair->Sex != _player->getGender())
return;
BarberShopStyleEntry const* bs_facialHair = sBarberShopStyleStore.LookupEntry(packet.NewFacialHair);
if (!bs_facialHair || bs_facialHair->Type != 2 || bs_facialHair->Race != _player->getRace() || bs_facialHair->Sex != _player->getGender())
return;
BarberShopStyleEntry const* bs_skinColor = sBarberShopStyleStore.LookupEntry(packet.NewSkinColor);
if (bs_skinColor && (bs_skinColor->Type != 3 || bs_skinColor->Race != _player->getRace() || bs_skinColor->Sex != _player->getGender()))
return;
if (!Player::ValidateAppearance(_player->getRace(), _player->getClass(), _player->getGender(), bs_hair->Data, packet.NewHairColor, uint8(_player->GetUInt32Value(PLAYER_FLAGS) >> 8), bs_facialHair->Data, bs_skinColor ? bs_skinColor->Data : 0))
BarberShopStyleEntry const* bs_face = sBarberShopStyleStore.LookupEntry(packet.NewFace);
if (bs_face && (bs_face->Type != 4 || bs_face->Race != _player->getRace() || bs_face->Sex != _player->getGender()))
return;
if (!Player::ValidateAppearance(_player->getRace(), _player->getClass(), _player->getGender(),
bs_hair->Data,
packet.NewHairColor,
bs_face ? bs_face->Data : _player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID),
bs_facialHair->Data,
bs_skinColor ? bs_skinColor->Data : _player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID)))
return;
GameObject* go = _player->FindNearestGameObjectOfType(GAMEOBJECT_TYPE_BARBER_CHAIR, 5.0f);
@@ -1426,7 +1432,7 @@ void WorldSession::HandleAlterAppearance(WorldPackets::Character::AlterApperance
return;
}
uint32 cost = _player->GetBarberShopCost(bs_hair->Data, packet.NewHairColor, bs_facialHair->Data, bs_skinColor);
uint32 cost = _player->GetBarberShopCost(bs_hair, packet.NewHairColor, bs_facialHair, bs_skinColor, bs_face);
// 0 - ok
// 1, 3 - not enough money
@@ -1447,6 +1453,8 @@ void WorldSession::HandleAlterAppearance(WorldPackets::Character::AlterApperance
_player->SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE, uint8(bs_facialHair->Data));
if (bs_skinColor)
_player->SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID, uint8(bs_skinColor->Data));
if (bs_face)
_player->SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID, uint8(bs_face->Data));
_player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP, 1);
@@ -435,7 +435,7 @@ void WorldPackets::Character::AlterApperance::Read()
_worldPacket >> NewHairColor;
_worldPacket >> NewFacialHair;
_worldPacket >> NewSkinColor;
_worldPacket >> Unk;
_worldPacket >> NewFace;
}
WorldPacket const* WorldPackets::Character::BarberShopResultServer::Write()
@@ -598,7 +598,7 @@ namespace WorldPackets
uint32 NewHairColor = 0;
uint32 NewFacialHair = 0;
uint32 NewSkinColor = 0;
uint32 Unk = 0;
uint32 NewFace = 0;
};
class BarberShopResultServer final : public ServerPacket