mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[8137] Init player display id + native display id on login.
* Temporary reset of display id on save no longer needed. * Players always have the right model for their gender. Signed-off-by: hunuza <hunuza@gmail.com>
This commit is contained in:
parent
a295979484
commit
38197b539f
6 changed files with 43 additions and 59 deletions
|
|
@ -4504,9 +4504,6 @@ bool ChatHandler::HandleResetHonorCommand (const char * args)
|
||||||
|
|
||||||
static bool HandleResetStatsOrLevelHelper(Player* player)
|
static bool HandleResetStatsOrLevelHelper(Player* player)
|
||||||
{
|
{
|
||||||
PlayerInfo const *info = objmgr.GetPlayerInfo(player->getRace(), player->getClass());
|
|
||||||
if(!info) return false;
|
|
||||||
|
|
||||||
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(player->getClass());
|
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(player->getClass());
|
||||||
if(!cEntry)
|
if(!cEntry)
|
||||||
{
|
{
|
||||||
|
|
@ -4529,21 +4526,7 @@ static bool HandleResetStatsOrLevelHelper(Player* player)
|
||||||
|
|
||||||
// reset only if player not in some form;
|
// reset only if player not in some form;
|
||||||
if(player->m_form==FORM_NONE)
|
if(player->m_form==FORM_NONE)
|
||||||
{
|
player->InitDisplayIds();
|
||||||
switch(player->getGender())
|
|
||||||
{
|
|
||||||
case GENDER_FEMALE:
|
|
||||||
player->SetDisplayId(info->displayId_f);
|
|
||||||
player->SetNativeDisplayId(info->displayId_f);
|
|
||||||
break;
|
|
||||||
case GENDER_MALE:
|
|
||||||
player->SetDisplayId(info->displayId_m);
|
|
||||||
player->SetNativeDisplayId(info->displayId_m);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP );
|
player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP );
|
||||||
player->SetByteValue(UNIT_FIELD_BYTES_2, 3, player->m_form);
|
player->SetByteValue(UNIT_FIELD_BYTES_2, 3, player->m_form);
|
||||||
|
|
@ -6562,8 +6545,7 @@ bool ChatHandler::HandleModifyGenderCommand(const char *args)
|
||||||
player->SetByteValue(PLAYER_BYTES_3, 0, gender);
|
player->SetByteValue(PLAYER_BYTES_3, 0, gender);
|
||||||
|
|
||||||
// Change display ID
|
// Change display ID
|
||||||
player->SetDisplayId(gender ? info->displayId_f : info->displayId_m);
|
player->InitDisplayIds();
|
||||||
player->SetNativeDisplayId(gender ? info->displayId_f : info->displayId_m);
|
|
||||||
|
|
||||||
char const* gender_full = gender ? "female" : "male";
|
char const* gender_full = gender ? "female" : "male";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -769,7 +769,7 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recv_data*/ )
|
||||||
{
|
{
|
||||||
Mail *m = (*itr);
|
Mail *m = (*itr);
|
||||||
// must be not checked yet
|
// must be not checked yet
|
||||||
if(m->checked & MAIL_CHECK_MASK_RED)
|
if(m->checked & MAIL_CHECK_MASK_READ)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// and already delivered
|
// and already delivered
|
||||||
|
|
|
||||||
|
|
@ -555,27 +555,12 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
||||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
|
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
|
||||||
SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f);
|
SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f);
|
||||||
|
|
||||||
switch(gender)
|
|
||||||
{
|
|
||||||
case GENDER_FEMALE:
|
|
||||||
SetDisplayId(info->displayId_f );
|
|
||||||
SetNativeDisplayId(info->displayId_f );
|
|
||||||
break;
|
|
||||||
case GENDER_MALE:
|
|
||||||
SetDisplayId(info->displayId_m );
|
|
||||||
SetNativeDisplayId(info->displayId_m );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sLog.outError("Invalid gender %u for player",gender);
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
setFactionForRace(race);
|
setFactionForRace(race);
|
||||||
|
|
||||||
uint32 RaceClassGender = ( race ) | ( class_ << 8 ) | ( gender << 16 );
|
uint32 RaceClassGender = ( race ) | ( class_ << 8 ) | ( gender << 16 );
|
||||||
|
|
||||||
SetUInt32Value(UNIT_FIELD_BYTES_0, ( RaceClassGender | ( powertype << 24 ) ) );
|
SetUInt32Value(UNIT_FIELD_BYTES_0, ( RaceClassGender | ( powertype << 24 ) ) );
|
||||||
|
InitDisplayIds();
|
||||||
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP );
|
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP );
|
||||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE );
|
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE );
|
||||||
SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);
|
SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);
|
||||||
|
|
@ -1411,7 +1396,7 @@ bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
|
||||||
PlayerInfo const *info = objmgr.GetPlayerInfo(pRace, pClass);
|
PlayerInfo const *info = objmgr.GetPlayerInfo(pRace, pClass);
|
||||||
if(!info)
|
if(!info)
|
||||||
{
|
{
|
||||||
sLog.outError("Player %u have incorrect race/class pair. Don't build enum.", guid);
|
sLog.outError("Player %u has incorrect race/class pair. Don't build enum.", guid);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3420,7 +3405,7 @@ void Player::_LoadSpellCooldowns(QueryResult *result)
|
||||||
|
|
||||||
if(!sSpellStore.LookupEntry(spell_id))
|
if(!sSpellStore.LookupEntry(spell_id))
|
||||||
{
|
{
|
||||||
sLog.outError("Player %u have unknown spell %u in `character_spell_cooldown`, skipping.",GetGUIDLow(),spell_id);
|
sLog.outError("Player %u has unknown spell %u in `character_spell_cooldown`, skipping.",GetGUIDLow(),spell_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -14078,6 +14063,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||||
SetUInt32Value(PLAYER_BYTES_3, (GetUInt32Value(PLAYER_BYTES_3) & ~1) | fields[6].GetUInt8());
|
SetUInt32Value(PLAYER_BYTES_3, (GetUInt32Value(PLAYER_BYTES_3) & ~1) | fields[6].GetUInt8());
|
||||||
SetUInt32Value(PLAYER_FLAGS, fields[12].GetUInt32());
|
SetUInt32Value(PLAYER_FLAGS, fields[12].GetUInt32());
|
||||||
|
|
||||||
|
InitDisplayIds();
|
||||||
|
|
||||||
// cleanup inventory related item value fields (its will be filled correctly in _LoadInventory)
|
// cleanup inventory related item value fields (its will be filled correctly in _LoadInventory)
|
||||||
for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
|
for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
|
||||||
{
|
{
|
||||||
|
|
@ -14939,7 +14926,7 @@ void Player::_LoadMailedItems(Mail *mail)
|
||||||
|
|
||||||
if(!proto)
|
if(!proto)
|
||||||
{
|
{
|
||||||
sLog.outError( "Player %u have unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template,mail->messageID);
|
sLog.outError( "Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template,mail->messageID);
|
||||||
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
|
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
|
||||||
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid_low);
|
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid_low);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -15530,7 +15517,6 @@ void Player::SaveToDB()
|
||||||
SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_STAND);
|
SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_STAND);
|
||||||
SetByteValue(UNIT_FIELD_BYTES_2, 3, 0); // shapeshift
|
SetByteValue(UNIT_FIELD_BYTES_2, 3, 0); // shapeshift
|
||||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||||
SetDisplayId(GetNativeDisplayId());
|
|
||||||
|
|
||||||
bool inworld = IsInWorld();
|
bool inworld = IsInWorld();
|
||||||
|
|
||||||
|
|
@ -15675,7 +15661,6 @@ void Player::SaveToDB()
|
||||||
CharacterDatabase.CommitTransaction();
|
CharacterDatabase.CommitTransaction();
|
||||||
|
|
||||||
// restore state (before aura apply, if aura remove flag then aura must set it ack by self)
|
// restore state (before aura apply, if aura remove flag then aura must set it ack by self)
|
||||||
SetDisplayId(tmp_displayid);
|
|
||||||
SetUInt32Value(UNIT_FIELD_BYTES_1, tmp_bytes);
|
SetUInt32Value(UNIT_FIELD_BYTES_1, tmp_bytes);
|
||||||
SetUInt32Value(UNIT_FIELD_BYTES_2, tmp_bytes2);
|
SetUInt32Value(UNIT_FIELD_BYTES_2, tmp_bytes2);
|
||||||
SetUInt32Value(UNIT_FIELD_FLAGS, tmp_flags);
|
SetUInt32Value(UNIT_FIELD_FLAGS, tmp_flags);
|
||||||
|
|
@ -16119,28 +16104,17 @@ 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)
|
void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair)
|
||||||
{
|
{
|
||||||
// 0 1 2 3 4
|
// 0
|
||||||
QueryResult* result = CharacterDatabase.PQuery("SELECT data, race, class, playerBytes, playerBytes2 FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
|
QueryResult* result = CharacterDatabase.PQuery("SELECT playerBytes2 FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
|
||||||
if(!result)
|
if(!result)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Field* fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
|
|
||||||
Tokens tokens = StrSplit(fields[0].GetString(), " ");
|
uint32 player_bytes2 = fields[0].GetUInt32();
|
||||||
|
|
||||||
PlayerInfo const* info = objmgr.GetPlayerInfo(fields[1].GetUInt8(), fields[2].GetUInt8());
|
|
||||||
if(!info)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// TODO: do not access data field here
|
|
||||||
SetUInt32ValueInArray(tokens, UNIT_FIELD_DISPLAYID, gender ? info->displayId_f : info->displayId_m);
|
|
||||||
SetUInt32ValueInArray(tokens, UNIT_FIELD_NATIVEDISPLAYID, gender ? info->displayId_f : info->displayId_m);
|
|
||||||
|
|
||||||
uint32 player_bytes2 = fields[4].GetUInt32();
|
|
||||||
player_bytes2 &= ~0xFF;
|
player_bytes2 &= ~0xFF;
|
||||||
player_bytes2 |= facialHair;
|
player_bytes2 |= facialHair;
|
||||||
|
|
||||||
SaveValuesArrayInDB(tokens, guid);
|
|
||||||
CharacterDatabase.PExecute("UPDATE characters SET gender = '%u', playerBytes = '%u', playerBytes2 = '%u' WHERE guid = '%u'", gender, skin | (face << 8) | (hairStyle << 16) | (hairColor << 24), player_bytes2, GUID_LOPART(guid));
|
CharacterDatabase.PExecute("UPDATE characters SET gender = '%u', playerBytes = '%u', playerBytes2 = '%u' WHERE guid = '%u'", gender, skin | (face << 8) | (hairStyle << 16) | (hairColor << 24), player_bytes2, GUID_LOPART(guid));
|
||||||
|
|
||||||
delete result;
|
delete result;
|
||||||
|
|
@ -17162,6 +17136,32 @@ void Player::InitDataForForm(bool reapplyMods)
|
||||||
UpdateAttackPowerAndDamage(true);
|
UpdateAttackPowerAndDamage(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::InitDisplayIds()
|
||||||
|
{
|
||||||
|
PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(), getClass());
|
||||||
|
if(!info)
|
||||||
|
{
|
||||||
|
sLog.outError("Player %u has incorrect race/class pair. Can't init display ids.", GetGUIDLow());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 gender = getGender();
|
||||||
|
switch(gender)
|
||||||
|
{
|
||||||
|
case GENDER_FEMALE:
|
||||||
|
SetDisplayId(info->displayId_f );
|
||||||
|
SetNativeDisplayId(info->displayId_f );
|
||||||
|
break;
|
||||||
|
case GENDER_MALE:
|
||||||
|
SetDisplayId(info->displayId_m );
|
||||||
|
SetNativeDisplayId(info->displayId_m );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sLog.outError("Invalid gender %u for player",gender);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return true is the bought item has a max count to force refresh of window by caller
|
// Return true is the bought item has a max count to force refresh of window by caller
|
||||||
bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint8 bag, uint8 slot)
|
bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint8 bag, uint8 slot)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1777,6 +1777,8 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
static uint32 getFactionForRace(uint8 race);
|
static uint32 getFactionForRace(uint8 race);
|
||||||
void setFactionForRace(uint8 race);
|
void setFactionForRace(uint8 race);
|
||||||
|
|
||||||
|
void InitDisplayIds();
|
||||||
|
|
||||||
bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
|
bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
|
||||||
bool RewardPlayerAndGroupAtKill(Unit* pVictim);
|
bool RewardPlayerAndGroupAtKill(Unit* pVictim);
|
||||||
void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource);
|
void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource);
|
||||||
|
|
|
||||||
|
|
@ -2321,7 +2321,7 @@ void Spell::EffectUnlearnSpecialization( uint32 i )
|
||||||
|
|
||||||
_player->removeSpell(spellToUnlearn);
|
_player->removeSpell(spellToUnlearn);
|
||||||
|
|
||||||
sLog.outDebug( "Spell: Player %u have unlearned spell %u from NpcGUID: %u", _player->GetGUIDLow(), spellToUnlearn, m_caster->GetGUIDLow() );
|
sLog.outDebug( "Spell: Player %u has unlearned spell %u from NpcGUID: %u", _player->GetGUIDLow(), spellToUnlearn, m_caster->GetGUIDLow() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spell::EffectPowerDrain(uint32 i)
|
void Spell::EffectPowerDrain(uint32 i)
|
||||||
|
|
@ -3324,7 +3324,7 @@ void Spell::EffectLearnSpell(uint32 i)
|
||||||
uint32 spellToLearn = ((m_spellInfo->Id==SPELL_ID_GENERIC_LEARN) || (m_spellInfo->Id==SPELL_ID_GENERIC_LEARN_PET)) ? damage : m_spellInfo->EffectTriggerSpell[i];
|
uint32 spellToLearn = ((m_spellInfo->Id==SPELL_ID_GENERIC_LEARN) || (m_spellInfo->Id==SPELL_ID_GENERIC_LEARN_PET)) ? damage : m_spellInfo->EffectTriggerSpell[i];
|
||||||
player->learnSpell(spellToLearn,false);
|
player->learnSpell(spellToLearn,false);
|
||||||
|
|
||||||
sLog.outDebug( "Spell: Player %u have learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow() );
|
sLog.outDebug( "Spell: Player %u has learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spell::EffectDispel(uint32 i)
|
void Spell::EffectDispel(uint32 i)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8136"
|
#define REVISION_NR "8137"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue