mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +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,30 +6504,27 @@ bool ChatHandler::HandleModifyGenderCommand(const char *args)
|
|||
return false;
|
||||
}
|
||||
|
||||
PlayerInfo const* info = objmgr.GetPlayerInfo(player->getRace(), player->getClass());
|
||||
if(!info)
|
||||
return false;
|
||||
|
||||
char const* gender_str = (char*)args;
|
||||
int gender_len = strlen(gender_str);
|
||||
|
||||
uint32 displayId = player->GetNativeDisplayId();
|
||||
char const* gender_full = NULL;
|
||||
uint32 new_displayId = displayId;
|
||||
Gender gender;
|
||||
|
||||
if(!strncmp(gender_str,"male",gender_len)) // MALE
|
||||
if(!strncmp(gender_str, "male", gender_len)) // MALE
|
||||
{
|
||||
if(player->getGender() == GENDER_MALE)
|
||||
return true;
|
||||
|
||||
gender_full = "male";
|
||||
new_displayId = player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1;
|
||||
gender = GENDER_MALE;
|
||||
}
|
||||
else if (!strncmp(gender_str,"female",gender_len)) // FEMALE
|
||||
else if (!strncmp(gender_str, "female", gender_len)) // FEMALE
|
||||
{
|
||||
if(player->getGender() == GENDER_FEMALE)
|
||||
return true;
|
||||
|
||||
gender_full = "female";
|
||||
new_displayId = player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1;
|
||||
gender = GENDER_FEMALE;
|
||||
}
|
||||
else
|
||||
|
|
@ -6539,13 +6536,18 @@ bool ChatHandler::HandleModifyGenderCommand(const char *args)
|
|||
|
||||
// Set gender
|
||||
player->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender);
|
||||
player->SetByteValue(PLAYER_BYTES_3, 0, gender);
|
||||
|
||||
// Change display ID
|
||||
player->SetDisplayId(new_displayId);
|
||||
player->SetNativeDisplayId(new_displayId);
|
||||
player->SetDisplayId(gender ? info->displayId_f : info->displayId_m);
|
||||
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))
|
||||
ChatHandler(player).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full,GetName());
|
||||
ChatHandler(player).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, GetName());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15772,31 +15772,37 @@ void Player::SetFloatValueInDB(uint16 index, float value, uint64 guid)
|
|||
void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair)
|
||||
{
|
||||
Tokens tokens;
|
||||
if(!LoadValuesArrayFromDB(tokens,guid))
|
||||
if(!LoadValuesArrayFromDB(tokens, guid))
|
||||
return;
|
||||
|
||||
uint32 player_bytes = atol(tokens[PLAYER_BYTES].c_str());
|
||||
((uint8*)player_bytes)[0] = skin;
|
||||
((uint8*)player_bytes)[1] = face;
|
||||
((uint8*)player_bytes)[2] = hairStyle;
|
||||
((uint8*)player_bytes)[3] = hairColor;
|
||||
char buf[11];
|
||||
snprintf(buf,11,"%u",player_bytes);
|
||||
tokens[PLAYER_BYTES] = buf;
|
||||
uint32 unit_bytes0 = GetUInt32ValueFromArray(tokens, UNIT_FIELD_BYTES_0);
|
||||
uint8 race = unit_bytes0 & 0xFF;
|
||||
uint8 class_ = (unit_bytes0 >> 8) & 0xFF;
|
||||
|
||||
uint32 player_bytes2 = atol(tokens[PLAYER_BYTES_2].c_str());
|
||||
((uint8*)player_bytes2)[0] = facialHair;
|
||||
char buf2[11];
|
||||
snprintf(buf2,11,"%u",player_bytes2);
|
||||
tokens[PLAYER_BYTES_2] = buf;
|
||||
PlayerInfo const* info = objmgr.GetPlayerInfo(race, class_);
|
||||
if(!info)
|
||||
return;
|
||||
|
||||
uint32 player_bytes3 = atol(tokens[PLAYER_BYTES_3].c_str());
|
||||
((uint8*)player_bytes3)[0] = gender;
|
||||
char buf3[11];
|
||||
snprintf(buf3,11,"%u",player_bytes3);
|
||||
tokens[PLAYER_BYTES_3] = buf;
|
||||
unit_bytes0 &= ~(0xFF << 16);
|
||||
unit_bytes0 |= (gender << 16);
|
||||
SetUInt32ValueInArray(tokens, UNIT_FIELD_BYTES_0, unit_bytes0);
|
||||
|
||||
SaveValuesArrayInDB(tokens,guid);
|
||||
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);
|
||||
}
|
||||
|
||||
void Player::SendAttackSwingNotStanding()
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ World::AddSession_ (WorldSession* s)
|
|||
|
||||
uint32 Sessions = GetActiveAndQueuedSessionCount ();
|
||||
uint32 pLimit = GetPlayerAmountLimit ();
|
||||
uint32 QueueSize = GetQueueSize (); //number of players in the queue
|
||||
uint32 QueueSize = GetQueueSize (); //number of players in the queue
|
||||
|
||||
//so we don't count the user trying to
|
||||
//login as a session and queue the socket that we are using
|
||||
|
|
@ -243,10 +243,10 @@ World::AddSession_ (WorldSession* s)
|
|||
|
||||
WorldPacket packet(SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1);
|
||||
packet << uint8 (AUTH_OK);
|
||||
packet << uint32 (0); // unknown random value...
|
||||
packet << uint8 (0);
|
||||
packet << uint32 (0);
|
||||
packet << uint8 (s->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
|
||||
packet << uint32 (0); // BillingTimeRemaining
|
||||
packet << uint8 (0); // BillingPlanFlags
|
||||
packet << uint32 (0); // BillingTimeRested
|
||||
packet << uint8 (s->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
|
||||
s->SendPacket (&packet);
|
||||
|
||||
UpdateMaxSessionCounters ();
|
||||
|
|
@ -254,7 +254,7 @@ World::AddSession_ (WorldSession* s)
|
|||
// Updates the population
|
||||
if (pLimit > 0)
|
||||
{
|
||||
float popu = GetActiveSessionCount (); //updated number of users on the server
|
||||
float popu = GetActiveSessionCount (); //updated number of users on the server
|
||||
popu /= pLimit;
|
||||
popu *= 2;
|
||||
loginDatabase.PExecute ("UPDATE realmlist SET population = '%f' WHERE id = '%d'", popu, realmID);
|
||||
|
|
@ -281,10 +281,10 @@ void World::AddQueuedPlayer(WorldSession* sess)
|
|||
// The 1st SMSG_AUTH_RESPONSE needs to contain other info too.
|
||||
WorldPacket packet (SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1);
|
||||
packet << uint8 (AUTH_WAIT_QUEUE);
|
||||
packet << uint32 (0); // unknown random value...
|
||||
packet << uint8 (0);
|
||||
packet << uint32 (0);
|
||||
packet << uint8 (sess->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
|
||||
packet << uint32 (0); // BillingTimeRemaining
|
||||
packet << uint8 (0); // BillingPlanFlags
|
||||
packet << uint32 (0); // BillingTimeRested
|
||||
packet << uint8 (sess->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
|
||||
packet << uint32(GetQueuePos (sess));
|
||||
sess->SendPacket (&packet);
|
||||
|
||||
|
|
@ -1048,7 +1048,7 @@ void World::SetInitialWorldSettings()
|
|||
|
||||
///- Clean up and pack instances
|
||||
sLog.outString( "Cleaning up instances..." );
|
||||
sInstanceSaveManager.CleanupInstances(); // must be called before `creature_respawn`/`gameobject_respawn` tables
|
||||
sInstanceSaveManager.CleanupInstances(); // must be called before `creature_respawn`/`gameobject_respawn` tables
|
||||
|
||||
sLog.outString( "Packing instances..." );
|
||||
sInstanceSaveManager.PackInstances();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue