Jump to content

[patch] Tauren skintone change at the barbershop


Guest Scyzor

Recommended Posts

Taurens could choose their skintone at the barbershop, but when they try to apply the change, nothing gets subtracted from their money and their skin reverts back to the one they were created with. This patch calculates the correct amount of money needed and applies the change to PLAYER_BYTES.

From ae2ea7d1ef2a0a70b20c9198b6018f9c033a95aa Mon Sep 17 00:00:00 2001
From: GS <[email protected]>
Date: Tue, 15 Jun 2010 13:14:28 +0300
Subject: [PATCH] Tauren can now change their skin tone colour at the barbershop.

Signed-off-by: GS <[email protected]>
---
src/game/CharacterHandler.cpp |   12 +++++++++---
src/game/Player.cpp           |    9 +++++++--
src/game/Player.h             |    2 +-
3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index 8357ede..08c52b3 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -1075,8 +1075,8 @@ void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
{
    DEBUG_LOG("CMSG_ALTER_APPEARANCE");

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

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

@@ -1088,7 +1088,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_skinTone = sBarberShopStyleStore.LookupEntry(SkinTone);
+
+    if(!bs_skinTone || bs_skinTone->type != 3 || bs_skinTone->race != _player->getRace() || bs_facialHair->gender != _player->getGender())
+        return;
+
+    uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id, bs_skinTone->hair_id);

    // 0 - ok
    // 1,3 - not enough money
@@ -1113,6 +1118,7 @@ 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));
+    _player->SetByteValue(PLAYER_BYTES, 0, uint8(bs_skinTone->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 6abae6f..e4a03fc 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -20615,7 +20615,7 @@ bool Player::CanCaptureTowerPoint()
           );
}

-uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair)
+uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, uint8 newskintone)
{
    uint32 level = getLevel();

@@ -20625,8 +20625,10 @@ 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 skintone = GetByteValue(PLAYER_BYTES, 0);

-    if((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair))
+    if((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair) &&
+        (skintone == newskintone))
        return 0;

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

+    if(skintone != newskintone)
+        cost += bsc->cost * 0.5f;                           // +1/2 of price
+
    return uint32(cost);
}

diff --git a/src/game/Player.h b/src/game/Player.h
index 8d6d64a..dfbb46e 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1136,7 +1136,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, uint8 newskintone);

        PlayerSocial *GetSocial() { return m_social; }

-- 
1.7.0.2.msysgit.0

Link to comment
Share on other sites

×
×
  • 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