Jump to content

Barbershop - skin tone


Guest thenecromancer

Recommended Posts

What does it change:

Do not skip part of barbershop packet changing skin tone

Misc info:

Sorry for weird patch format, if it's possible I've missed something that will prevent this to apply smoothly

75% of the cost seems to be in sync with game display.

Note that currently this is useful for only a single race in game, other's are sending null value ( though I did not check for it, I'm sure they're not creating any conflicts with this )

diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index 20ac51d..2e97f07 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -1064,8 +1064,8 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
{
    sLog.outDebug("CMSG_ALTER_APPEARANCE");

-    uint32 Hair, Color, FacialHair;
-    recv_data >> Hair >> Color >> FacialHair;
+    uint32 Hair, Color, FacialHair, SkinColor;
+    recv_data >> Hair >> Color >> FacialHair >> SkinColor;

    BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(Hair);

@@ -1077,7 +1077,12 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
    if(!bs_facialHair || bs_facialHair->type != 2 || bs_facialHair->race != _player->getRace() || bs_facialHair->gender != _player->getGender())
        return;

-    uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id);
+    BarberShopStyleEntry const* bs_skinColor = sBarberShopStyleStore.LookupEntry(SkinColor);
+
+    if( bs_skinColor && (bs_skinColor->type != 3 || bs_skinColor->race != _player->getRace() || bs_skinColor->gender != _player->getGender()))
+        return;
+
+    uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id, bs_skinColor);

    // 0 - ok
    // 1,3 - not enough money
@@ -1102,6 +1107,8 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
    _player->SetByteValue(PLAYER_BYTES, 2, uint8(bs_hair->hair_id));
    _player->SetByteValue(PLAYER_BYTES, 3, uint8(Color));
    _player->SetByteValue(PLAYER_BYTES_2, 0, uint8(bs_facialHair->hair_id));
+    if (bs_skinColor)
+        _player->SetByteValue(PLAYER_BYTES, 0, uint8(bs_skinColor->hair_id));

    _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP, 1);

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 05130dd..4d499ea 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -19532,7 +19532,7 @@ bool Player::CanCaptureTowerPoint()
           );
}

-uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair)
+uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin )
{
    uint32 level = getLevel();

@@ -19542,8 +19542,9 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n
    uint8 hairstyle = GetByteValue(PLAYER_BYTES, 2);
    uint8 haircolor = GetByteValue(PLAYER_BYTES, 3);
    uint8 facialhair = GetByteValue(PLAYER_BYTES_2, 0);
+    uint8 skincolor = GetByteValue(PLAYER_BYTES, 0);

-    if((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair))
+    if((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair) && (!newSkin || (newSkin->hair_id == skincolor)))
        return 0;

    GtBarberShopCostBaseEntry const *bsc = sGtBarberShopCostBaseStore.LookupEntry(level - 1);
@@ -19562,6 +19563,9 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n
    if(facialhair != newfacialhair)
        cost += bsc->cost * 0.75f;                          // +3/4 of price

+    if(newSkin && skincolor != newSkin->hair_id)
+        cost += bsc->cost * 0.75f;                          // ??
+
    return uint32(cost);
}

diff --git a/src/game/Player.h b/src/game/Player.h
index 39a25e8..8fd4149 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1059,7 +1059,7 @@ class MANGOS_DLL_SPEC Player : public Unit
        std::string afkMsg;
        std::string dndMsg;

-        uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair);
+        uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin=NULL);

        PlayerSocial *GetSocial() { return m_social; }

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use