diff options
-rw-r--r-- | src/game/Level3.cpp | 22 | ||||
-rw-r--r-- | src/game/Mail.cpp | 2 | ||||
-rw-r--r-- | src/game/Player.cpp | 70 | ||||
-rw-r--r-- | src/game/Player.h | 2 | ||||
-rw-r--r-- | src/game/SpellEffects.cpp | 4 |
5 files changed, 42 insertions, 58 deletions
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 4fb765fa8a9..8e3102fd4e4 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -5362,9 +5362,6 @@ bool ChatHandler::HandleResetHonorCommand (const char * args) 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()); if(!cEntry) { @@ -5387,21 +5384,7 @@ static bool HandleResetStatsOrLevelHelper(Player* player) // reset only if player not in some form; if(player->m_form==FORM_NONE) - { - 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->InitDisplayIds(); player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP ); player->SetByteValue(UNIT_FIELD_BYTES_2, 3, player->m_form); @@ -7449,8 +7432,7 @@ bool ChatHandler::HandleModifyGenderCommand(const char *args) player->SetByteValue(PLAYER_BYTES_3, 0, gender); // Change display ID - player->SetDisplayId(gender ? info->displayId_f : info->displayId_m); - player->SetNativeDisplayId(gender ? info->displayId_f : info->displayId_m); + player->InitDisplayIds(); char const* gender_full = gender ? "female" : "male"; diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 64ff1c8e0cb..87eb875d829 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -779,7 +779,7 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recv_data*/ ) { Mail *m = (*itr); // must be not checked yet - if(m->checked & MAIL_CHECK_MASK_RED) + if(m->checked & MAIL_CHECK_MASK_READ) continue; // and already delivered diff --git a/src/game/Player.cpp b/src/game/Player.cpp index da43402c1a0..b64bf13ffa1 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -559,27 +559,12 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE); 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); uint32 RaceClassGender = ( race ) | ( class_ << 8 ) | ( gender << 16 ); SetUInt32Value(UNIT_FIELD_BYTES_0, ( RaceClassGender | ( powertype << 24 ) ) ); + InitDisplayIds(); SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP ); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE ); SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER); @@ -1466,7 +1451,7 @@ bool Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) PlayerInfo const *info = objmgr.GetPlayerInfo(pRace, pClass); 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; } @@ -3549,7 +3534,7 @@ void Player::_LoadSpellCooldowns(QueryResult *result) 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; } @@ -14519,6 +14504,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) SetUInt32Value(PLAYER_BYTES_3, (GetUInt32Value(PLAYER_BYTES_3) & ~1) | fields[6].GetUInt8()); SetUInt32Value(PLAYER_FLAGS, fields[12].GetUInt32()); + InitDisplayIds(); + // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory) for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) { @@ -15420,7 +15407,7 @@ void Player::_LoadMailedItems(Mail *mail) 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 item_instance WHERE guid = '%u'", item_guid_low); continue; @@ -16094,7 +16081,6 @@ void Player::SaveToDB() SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_STAND); SetByteValue(UNIT_FIELD_BYTES_2, 3, 0); // shapeshift RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); - SetDisplayId(GetNativeDisplayId()); bool inworld = IsInWorld(); @@ -16244,7 +16230,6 @@ void Player::SaveToDB() CharacterDatabase.CommitTransaction(); // 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_2, tmp_bytes2); SetUInt32Value(UNIT_FIELD_FLAGS, tmp_flags); @@ -16668,28 +16653,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) { - // 0 1 2 3 4 - QueryResult* result = CharacterDatabase.PQuery("SELECT data, race, class, playerBytes, playerBytes2 FROM characters WHERE guid = '%u'", GUID_LOPART(guid)); + // 0 + QueryResult* result = CharacterDatabase.PQuery("SELECT playerBytes2 FROM characters WHERE guid = '%u'", GUID_LOPART(guid)); if(!result) return; Field* fields = result->Fetch(); - Tokens tokens = StrSplit(fields[0].GetString(), " "); - - 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(); + uint32 player_bytes2 = fields[0].GetUInt32(); player_bytes2 &= ~0xFF; 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)); delete result; @@ -17873,6 +17847,32 @@ void Player::InitDataForForm(bool reapplyMods) 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 bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint8 bag, uint8 slot) { diff --git a/src/game/Player.h b/src/game/Player.h index 17563688da6..101405fade5 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1737,6 +1737,8 @@ class TRINITY_DLL_SPEC Player : public Unit static uint32 getFactionForRace(uint8 race); void setFactionForRace(uint8 race); + void InitDisplayIds(); + bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const; bool RewardPlayerAndGroupAtKill(Unit* pVictim); void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 961e479a276..750d6c09788 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -2488,7 +2488,7 @@ void Spell::EffectUnlearnSpecialization( uint32 i ) _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) @@ -3525,7 +3525,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]; 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) |