Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix skin error #2616

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/game/Objects/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21466,6 +21466,12 @@ void Player::SetControlledBy(Unit* pWho)

bool Player::ChangeRace(uint8 newRace)
{
uint8 oldRace = GetRace();
uint8 pClass = GetClass();
uint8 gender = GetGender();
uint8 team = GetTeam();
Powers powertype = GetPowerType();

if (IsSavingDisabled() || IsBot())
{
sLog.Out(LOG_BASIC, LOG_LVL_ERROR, "Cannot change race of bot or temporary character!");
Expand All @@ -21476,7 +21482,6 @@ bool Player::ChangeRace(uint8 newRace)
if (!info)
return false;

uint8 oldRace = GetRace();
bool bChangeTeam = (TeamForRace(oldRace) != TeamForRace(newRace));

m_saveDisabled = true;
Expand All @@ -21486,11 +21491,19 @@ bool Player::ChangeRace(uint8 newRace)
return false;
}

ResetSpells();

// Change the race
SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE, newRace);
LearnDefaultSpells();

SetFactionForRace(newRace);
SetFloatValue(OBJECT_FIELD_SCALE_X, ((newRace == RACE_TAUREN) ? 1.3f : 1.0f));
SetUInt32Value(UNIT_FIELD_BYTES_0, ((newRace) | (pClass << 8) | (gender << 16) | (powertype << 24)));
SetUInt32Value(UNIT_FIELD_DISPLAYID, gender == GENDER_MALE ? info->displayId_m : info->displayId_f);
SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, gender == GENDER_MALE ? info->displayId_m : info->displayId_f);
SetUInt32Value(PLAYER_BYTES, 1 | (1 << 8) | (1 << 16) | (1 << 24));
SetUInt32Value(PLAYER_BYTES_2, (1) | (0x02 << 24));
SetByteValue(PLAYER_BYTES_2, 2, 7); // keep bank tabs

if (!ChangeReputationsForRace(oldRace, newRace))
{
Expand All @@ -21512,6 +21525,11 @@ bool Player::ChangeRace(uint8 newRace)
RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);

// Save with the new race
SetHealth(GetMaxHealth());

SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
SetPower(POWER_RAGE, 0);
SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY));
m_saveDisabled = false;
SaveToDB();
m_saveDisabled = true;
Expand Down