Fixed titles, PLAYER__FIELD_KNOWN_TITLES is now 128 bits long

This commit is contained in:
arrai 2008-11-21 20:09:11 +01:00
parent 8e32c8ca76
commit 600a596796
3 changed files with 27 additions and 5 deletions

View file

@ -1482,9 +1482,9 @@ void WorldSession::HandleChooseTitleOpcode( WorldPacket & recv_data )
recv_data >> title; recv_data >> title;
// -1 at none // -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; return;
} }
else else

View file

@ -12382,7 +12382,7 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
if(pQuest->GetCharTitleId()) if(pQuest->GetCharTitleId())
{ {
if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(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 // Send reward mail
@ -14003,7 +14003,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
// note: PLAYER__FIELD_KNOWN_TITLES updated at quest status loaded // note: PLAYER__FIELD_KNOWN_TITLES updated at quest status loaded
if(uint32 curTitle = GetUInt32Value(PLAYER_CHOSEN_TITLE)) if(uint32 curTitle = GetUInt32Value(PLAYER_CHOSEN_TITLE))
{ {
if(!HasFlag64(PLAYER__FIELD_KNOWN_TITLES,uint64(1) << curTitle)) if(!HasTitle(curTitle))
SetUInt32Value(PLAYER_CHOSEN_TITLE,0); SetUInt32Value(PLAYER_CHOSEN_TITLE,0);
} }
@ -14615,7 +14615,7 @@ void Player::_LoadQuestStatus(QueryResult *result)
if(pQuest->GetCharTitleId()) if(pQuest->GetCharTitleId())
{ {
if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(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? // only for flyable vehicles?
CastSpell(this, 45472, true); // Parachute 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);
}

View file

@ -2068,6 +2068,10 @@ class MANGOS_DLL_SPEC Player : public Unit
DeclinedName const* GetDeclinedNames() const { return m_declinedname; } DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
AchievementMgr& GetAchievementMgr() { return m_achievementMgr; } 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: protected:
/*********************************************************/ /*********************************************************/