mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
Character re-customization fix
This commit is contained in:
parent
3b753b830b
commit
e848a52da9
3 changed files with 52 additions and 44 deletions
|
|
@ -6504,12 +6504,13 @@ bool ChatHandler::HandleModifyGenderCommand(const char *args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayerInfo const* info = objmgr.GetPlayerInfo(player->getRace(), player->getClass());
|
||||||
|
if(!info)
|
||||||
|
return false;
|
||||||
|
|
||||||
char const* gender_str = (char*)args;
|
char const* gender_str = (char*)args;
|
||||||
int gender_len = strlen(gender_str);
|
int gender_len = strlen(gender_str);
|
||||||
|
|
||||||
uint32 displayId = player->GetNativeDisplayId();
|
|
||||||
char const* gender_full = NULL;
|
|
||||||
uint32 new_displayId = displayId;
|
|
||||||
Gender gender;
|
Gender gender;
|
||||||
|
|
||||||
if(!strncmp(gender_str, "male", gender_len)) // MALE
|
if(!strncmp(gender_str, "male", gender_len)) // MALE
|
||||||
|
|
@ -6517,8 +6518,6 @@ bool ChatHandler::HandleModifyGenderCommand(const char *args)
|
||||||
if(player->getGender() == GENDER_MALE)
|
if(player->getGender() == GENDER_MALE)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
gender_full = "male";
|
|
||||||
new_displayId = player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1;
|
|
||||||
gender = GENDER_MALE;
|
gender = GENDER_MALE;
|
||||||
}
|
}
|
||||||
else if (!strncmp(gender_str, "female", gender_len)) // FEMALE
|
else if (!strncmp(gender_str, "female", gender_len)) // FEMALE
|
||||||
|
|
@ -6526,8 +6525,6 @@ bool ChatHandler::HandleModifyGenderCommand(const char *args)
|
||||||
if(player->getGender() == GENDER_FEMALE)
|
if(player->getGender() == GENDER_FEMALE)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
gender_full = "female";
|
|
||||||
new_displayId = player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1;
|
|
||||||
gender = GENDER_FEMALE;
|
gender = GENDER_FEMALE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -6539,13 +6536,18 @@ bool ChatHandler::HandleModifyGenderCommand(const char *args)
|
||||||
|
|
||||||
// Set gender
|
// Set gender
|
||||||
player->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender);
|
player->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender);
|
||||||
|
player->SetByteValue(PLAYER_BYTES_3, 0, gender);
|
||||||
|
|
||||||
// Change display ID
|
// Change display ID
|
||||||
player->SetDisplayId(new_displayId);
|
player->SetDisplayId(gender ? info->displayId_f : info->displayId_m);
|
||||||
player->SetNativeDisplayId(new_displayId);
|
player->SetNativeDisplayId(gender ? info->displayId_f : info->displayId_m);
|
||||||
|
|
||||||
|
char const* gender_full = gender ? "female" : "male";
|
||||||
|
|
||||||
PSendSysMessage(LANG_YOU_CHANGE_GENDER, player->GetName(), gender_full);
|
PSendSysMessage(LANG_YOU_CHANGE_GENDER, player->GetName(), gender_full);
|
||||||
|
|
||||||
if (needReportToTarget(player))
|
if (needReportToTarget(player))
|
||||||
ChatHandler(player).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, GetName());
|
ChatHandler(player).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, GetName());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15775,26 +15775,32 @@ void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8
|
||||||
if(!LoadValuesArrayFromDB(tokens, guid))
|
if(!LoadValuesArrayFromDB(tokens, guid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32 player_bytes = atol(tokens[PLAYER_BYTES].c_str());
|
uint32 unit_bytes0 = GetUInt32ValueFromArray(tokens, UNIT_FIELD_BYTES_0);
|
||||||
((uint8*)player_bytes)[0] = skin;
|
uint8 race = unit_bytes0 & 0xFF;
|
||||||
((uint8*)player_bytes)[1] = face;
|
uint8 class_ = (unit_bytes0 >> 8) & 0xFF;
|
||||||
((uint8*)player_bytes)[2] = hairStyle;
|
|
||||||
((uint8*)player_bytes)[3] = hairColor;
|
|
||||||
char buf[11];
|
|
||||||
snprintf(buf,11,"%u",player_bytes);
|
|
||||||
tokens[PLAYER_BYTES] = buf;
|
|
||||||
|
|
||||||
uint32 player_bytes2 = atol(tokens[PLAYER_BYTES_2].c_str());
|
PlayerInfo const* info = objmgr.GetPlayerInfo(race, class_);
|
||||||
((uint8*)player_bytes2)[0] = facialHair;
|
if(!info)
|
||||||
char buf2[11];
|
return;
|
||||||
snprintf(buf2,11,"%u",player_bytes2);
|
|
||||||
tokens[PLAYER_BYTES_2] = buf;
|
|
||||||
|
|
||||||
uint32 player_bytes3 = atol(tokens[PLAYER_BYTES_3].c_str());
|
unit_bytes0 &= ~(0xFF << 16);
|
||||||
((uint8*)player_bytes3)[0] = gender;
|
unit_bytes0 |= (gender << 16);
|
||||||
char buf3[11];
|
SetUInt32ValueInArray(tokens, UNIT_FIELD_BYTES_0, unit_bytes0);
|
||||||
snprintf(buf3,11,"%u",player_bytes3);
|
|
||||||
tokens[PLAYER_BYTES_3] = buf;
|
SetUInt32ValueInArray(tokens, UNIT_FIELD_DISPLAYID, gender ? info->displayId_f : info->displayId_m);
|
||||||
|
SetUInt32ValueInArray(tokens, UNIT_FIELD_NATIVEDISPLAYID, gender ? info->displayId_f : info->displayId_m);
|
||||||
|
|
||||||
|
SetUInt32ValueInArray(tokens, PLAYER_BYTES, (skin | (face << 8) | (hairStyle << 16) | (hairColor << 24)));
|
||||||
|
|
||||||
|
uint32 player_bytes2 = GetUInt32ValueFromArray(tokens, PLAYER_BYTES_2);
|
||||||
|
player_bytes2 &= ~0xFF;
|
||||||
|
player_bytes2 |= facialHair;
|
||||||
|
SetUInt32ValueInArray(tokens, PLAYER_BYTES_2, player_bytes2);
|
||||||
|
|
||||||
|
uint32 player_bytes3 = GetUInt32ValueFromArray(tokens, PLAYER_BYTES_3);
|
||||||
|
player_bytes3 &= ~0xFF;
|
||||||
|
player_bytes3 |= gender;
|
||||||
|
SetUInt32ValueInArray(tokens, PLAYER_BYTES_3, player_bytes3);
|
||||||
|
|
||||||
SaveValuesArrayInDB(tokens, guid);
|
SaveValuesArrayInDB(tokens, guid);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -243,9 +243,9 @@ World::AddSession_ (WorldSession* s)
|
||||||
|
|
||||||
WorldPacket packet(SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1);
|
WorldPacket packet(SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1);
|
||||||
packet << uint8 (AUTH_OK);
|
packet << uint8 (AUTH_OK);
|
||||||
packet << uint32 (0); // unknown random value...
|
packet << uint32 (0); // BillingTimeRemaining
|
||||||
packet << uint8 (0);
|
packet << uint8 (0); // BillingPlanFlags
|
||||||
packet << uint32 (0);
|
packet << uint32 (0); // BillingTimeRested
|
||||||
packet << uint8 (s->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
|
packet << uint8 (s->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
|
||||||
s->SendPacket (&packet);
|
s->SendPacket (&packet);
|
||||||
|
|
||||||
|
|
@ -281,9 +281,9 @@ void World::AddQueuedPlayer(WorldSession* sess)
|
||||||
// The 1st SMSG_AUTH_RESPONSE needs to contain other info too.
|
// The 1st SMSG_AUTH_RESPONSE needs to contain other info too.
|
||||||
WorldPacket packet (SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1);
|
WorldPacket packet (SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1);
|
||||||
packet << uint8 (AUTH_WAIT_QUEUE);
|
packet << uint8 (AUTH_WAIT_QUEUE);
|
||||||
packet << uint32 (0); // unknown random value...
|
packet << uint32 (0); // BillingTimeRemaining
|
||||||
packet << uint8 (0);
|
packet << uint8 (0); // BillingPlanFlags
|
||||||
packet << uint32 (0);
|
packet << uint32 (0); // BillingTimeRested
|
||||||
packet << uint8 (sess->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
|
packet << uint8 (sess->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
|
||||||
packet << uint32(GetQueuePos (sess));
|
packet << uint32(GetQueuePos (sess));
|
||||||
sess->SendPacket (&packet);
|
sess->SendPacket (&packet);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue