diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index e0ab13ee4..917867993 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -1482,9 +1482,9 @@ void WorldSession::HandleChooseTitleOpcode( WorldPacket & recv_data ) recv_data >> title; // -1 at none - if(title > 0 && title < 64) + if(title > 0 && title < 128) { - if(!GetPlayer()->HasFlag64(PLAYER__FIELD_KNOWN_TITLES,uint64(1) << title)) + if(!GetPlayer()->HasTitle(title)) return; } else diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 90219e524..90d96ec28 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -12382,7 +12382,7 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver if(pQuest->GetCharTitleId()) { if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId())) - SetFlag64(PLAYER__FIELD_KNOWN_TITLES, (uint64(1) << titleEntry->bit_index)); + SetTitle(titleEntry); } // Send reward mail @@ -14003,7 +14003,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // note: PLAYER__FIELD_KNOWN_TITLES updated at quest status loaded if(uint32 curTitle = GetUInt32Value(PLAYER_CHOSEN_TITLE)) { - if(!HasFlag64(PLAYER__FIELD_KNOWN_TITLES,uint64(1) << curTitle)) + if(!HasTitle(curTitle)) SetUInt32Value(PLAYER_CHOSEN_TITLE,0); } @@ -14615,7 +14615,7 @@ void Player::_LoadQuestStatus(QueryResult *result) if(pQuest->GetCharTitleId()) { if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId())) - SetFlag64(PLAYER__FIELD_KNOWN_TITLES, (uint64(1) << titleEntry->bit_index)); + SetTitle(titleEntry); } } @@ -18734,3 +18734,21 @@ void Player::ExitVehicle(Vehicle *vehicle) // only for flyable vehicles? CastSpell(this, 45472, true); // Parachute } + +bool Player::HasTitle(uint32 bitIndex) +{ + if (bitIndex > 128) + return false; + + uint32 fieldIndexOffset = bitIndex/32; + uint32 flag = 1 << (bitIndex%32); + return HasFlag(PLAYER__FIELD_KNOWN_TITLES+fieldIndexOffset, flag); +} + +void Player::SetTitle(CharTitlesEntry const* title) +{ + uint32 fieldIndexOffset = title->bit_index/32; + uint32 flag = 1 << (title->bit_index%32); + SetFlag(PLAYER__FIELD_KNOWN_TITLES+fieldIndexOffset, flag); +} + diff --git a/src/game/Player.h b/src/game/Player.h index 7354ffe56..9bb7d7f3d 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -2068,6 +2068,10 @@ class MANGOS_DLL_SPEC Player : public Unit DeclinedName const* GetDeclinedNames() const { return m_declinedname; } AchievementMgr& GetAchievementMgr() { return m_achievementMgr; } + bool HasTitle(uint32 bitIndex); + bool HasTitle(CharTitlesEntry const* title) { return HasTitle(title->bit_index); } + void SetTitle(CharTitlesEntry const* title); + protected: /*********************************************************/