aboutsummaryrefslogtreecommitdiff
path: root/src/game/Player.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r--src/game/Player.cpp544
1 files changed, 21 insertions, 523 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 3539d1f2df0..ee6b136f888 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -267,11 +267,9 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi)
//== Player ====================================================
-const int32 Player::ReputationRank_Length[MAX_REPUTATION_RANK] = {36000, 3000, 3000, 3000, 6000, 12000, 21000, 1000};
-
UpdateMask Player::updateVisualBits;
-Player::Player (WorldSession *session): Unit(), m_achievementMgr(this)
+Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputationMgr(this)
{
m_transport = 0;
@@ -5697,442 +5695,10 @@ void Player::setFactionForRace(uint8 race)
setFaction( getFactionForRace(race) );
}
-void Player::UpdateReputation() const
-{
- sLog.outDetail( "WORLD: Player::UpdateReputation" );
-
- for(FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
- {
- SendFactionState(&(itr->second));
- }
-}
-
-void Player::SendFactionState(FactionState const* faction) const
-{
- if(faction->Flags & FACTION_FLAG_VISIBLE) //If faction is visible then update it
- {
- WorldPacket data(SMSG_SET_FACTION_STANDING, (16)); // last check 2.4.0
- data << (float) 0; // unk 2.4.0
- data << (uint8) 0; // wotlk 8634
- data << (uint32) 1; // count
- // for
- data << (uint32) faction->ReputationListID;
- data << (uint32) faction->Standing;
- // end for
- GetSession()->SendPacket(&data);
- }
-}
-
-void Player::SendFactionStates() const
-{
- for(FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
- SendFactionState(&(itr->second));
-}
-
-void Player::SendInitialReputations()
-{
- WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4+128*5));
- data << uint32 (0x00000080);
-
- RepListID a = 0;
-
- for (FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
- {
- // fill in absent fields
- for (; a != itr->first; a++)
- {
- data << uint8 (0x00);
- data << uint32 (0x00000000);
- }
-
- // fill in encountered data
- data << uint8 (itr->second.Flags);
- data << uint32 (itr->second.Standing);
-
- ++a;
- }
-
- // fill in absent fields
- for (; a != 128; a++)
- {
- data << uint8 (0x00);
- data << uint32 (0x00000000);
- }
-
- GetSession()->SendPacket(&data);
-}
-
-void Player::SetFactionAtWar( RepListID repListID, bool on )
-{
- FactionStateList::iterator itr = m_factions.find(repListID);
- if (itr == m_factions.end())
- return;
-
- // always invisible or hidden faction can't change war state
- if(itr->second.Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN) )
- return;
-
- SetFactionAtWar(&itr->second,on);
-}
-
-void Player::SetFactionAtWar(FactionState* faction, bool atWar)
-{
- // not allow declare war to own faction
- if(atWar && (faction->Flags & FACTION_FLAG_PEACE_FORCED) )
- return;
-
- // already set
- if(((faction->Flags & FACTION_FLAG_AT_WAR) != 0) == atWar)
- return;
-
- if( atWar )
- faction->Flags |= FACTION_FLAG_AT_WAR;
- else
- faction->Flags &= ~FACTION_FLAG_AT_WAR;
-
- faction->Changed = true;
-}
-
-void Player::SetFactionInactive( RepListID repListID, bool on )
-{
- FactionStateList::iterator itr = m_factions.find(repListID);
- if (itr == m_factions.end())
- return;
-
- SetFactionInactive(&itr->second,on);
-}
-
-void Player::SetFactionInactive(FactionState* faction, bool inactive)
-{
- // always invisible or hidden faction can't be inactive
- if(inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE) ) )
- return;
-
- // already set
- if(((faction->Flags & FACTION_FLAG_INACTIVE) != 0) == inactive)
- return;
-
- if(inactive)
- faction->Flags |= FACTION_FLAG_INACTIVE;
- else
- faction->Flags &= ~FACTION_FLAG_INACTIVE;
-
- faction->Changed = true;
-}
-
-void Player::SetFactionVisible(FactionTemplateEntry const*factionTemplateEntry)
-{
- if(!factionTemplateEntry->faction)
- return;
-
- if(FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction))
- SetFactionVisible(factionEntry);
-}
-
-void Player::SetFactionVisible(FactionEntry const *factionEntry)
-{
- if(factionEntry->reputationListID < 0)
- return;
-
- FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
- if (itr == m_factions.end())
- return;
-
- SetFactionVisible(&itr->second);
-}
-
-void Player::SetFactionVisible(FactionState* faction)
-{
- // always invisible or hidden faction can't be make visible
- if(faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN))
- return;
-
- // already set
- if(faction->Flags & FACTION_FLAG_VISIBLE)
- return;
-
- faction->Flags |= FACTION_FLAG_VISIBLE;
- faction->Changed = true;
-
- if(!m_session->PlayerLoading())
- {
- // make faction visible in reputation list at client
- WorldPacket data(SMSG_SET_FACTION_VISIBLE, 4);
- data << faction->ReputationListID;
- GetSession()->SendPacket(&data);
- }
-}
-
-void Player::SetInitialFactions()
-{
- for(unsigned int i = 1; i < sFactionStore.GetNumRows(); i++)
- {
- FactionEntry const *factionEntry = sFactionStore.LookupEntry(i);
-
- if( factionEntry && (factionEntry->reputationListID >= 0))
- {
- FactionState newFaction;
- newFaction.ID = factionEntry->ID;
- newFaction.ReputationListID = factionEntry->reputationListID;
- newFaction.Standing = 0;
- newFaction.Flags = GetDefaultReputationFlags(factionEntry);
- newFaction.Changed = true;
-
- m_factions[newFaction.ReputationListID] = newFaction;
- }
- }
-}
-
-uint32 Player::GetDefaultReputationFlags(const FactionEntry *factionEntry) const
-{
- if (!factionEntry)
- return 0;
-
- uint32 raceMask = getRaceMask();
- uint32 classMask = getClassMask();
- for (int i=0; i < 4; i++)
- {
- if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
- (factionEntry->BaseRepClassMask[i]==0 ||
- (factionEntry->BaseRepClassMask[i] & classMask) ) )
- return factionEntry->ReputationFlags[i];
- }
- return 0;
-}
-
-int32 Player::GetBaseReputation(const FactionEntry *factionEntry) const
-{
- if (!factionEntry)
- return 0;
-
- uint32 raceMask = getRaceMask();
- uint32 classMask = getClassMask();
- for (int i=0; i < 4; i++)
- {
- if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
- (factionEntry->BaseRepClassMask[i]==0 ||
- (factionEntry->BaseRepClassMask[i] & classMask) ) )
- return factionEntry->BaseRepValue[i];
- }
-
- // in faction.dbc exist factions with (RepListId >=0, listed in character reputation list) with all BaseRepRaceMask[i]==0
- return 0;
-}
-
-int32 Player::GetReputation(uint32 faction_id) const
-{
- FactionEntry const *factionEntry = sFactionStore.LookupEntry(faction_id);
-
- if (!factionEntry)
- {
- sLog.outError("Player::GetReputation: Can't get reputation of %s for unknown faction (faction template id) #%u.",GetName(), faction_id);
- return 0;
- }
-
- return GetReputation(factionEntry);
-}
-
-int32 Player::GetReputation(const FactionEntry *factionEntry) const
-{
- // Faction without recorded reputation. Just ignore.
- if(!factionEntry)
- return 0;
-
- FactionStateList::const_iterator itr = m_factions.find(factionEntry->reputationListID);
- if (itr != m_factions.end())
- return GetBaseReputation(factionEntry) + itr->second.Standing;
-
- return 0;
-}
-
ReputationRank Player::GetReputationRank(uint32 faction) const
{
- FactionEntry const*factionEntry = sFactionStore.LookupEntry(faction);
- if(!factionEntry)
- return MIN_REPUTATION_RANK;
-
- return GetReputationRank(factionEntry);
-}
-
-ReputationRank Player::ReputationToRank(int32 standing) const
-{
- int32 Limit = Reputation_Cap + 1;
- for (int i = MAX_REPUTATION_RANK-1; i >= MIN_REPUTATION_RANK; --i)
- {
- Limit -= ReputationRank_Length[i];
- if (standing >= Limit )
- return ReputationRank(i);
- }
- return MIN_REPUTATION_RANK;
-}
-
-ReputationRank Player::GetReputationRank(const FactionEntry *factionEntry) const
-{
- int32 Reputation = GetReputation(factionEntry);
- return ReputationToRank(Reputation);
-}
-
-ReputationRank Player::GetBaseReputationRank(const FactionEntry *factionEntry) const
-{
- int32 Reputation = GetBaseReputation(factionEntry);
- return ReputationToRank(Reputation);
-}
-
-bool Player::ModifyFactionReputation(uint32 FactionTemplateId, int32 DeltaReputation)
-{
- FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId);
-
- if(!factionTemplateEntry)
- {
- sLog.outError("Player::ModifyFactionReputation: Can't update reputation of %s for unknown faction (faction template id) #%u.", GetName(), FactionTemplateId);
- return false;
- }
-
- FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction);
-
- // Faction without recorded reputation. Just ignore.
- if(!factionEntry)
- return false;
-
- return ModifyFactionReputation(factionEntry, DeltaReputation);
-}
-
-bool Player::ModifyFactionReputation(FactionEntry const* factionEntry, int32 standing)
-{
- SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID);
- if (flist)
- {
- bool res = false;
- for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr)
- {
- FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr);
- if(factionEntryCalc)
- res = ModifyOneFactionReputation(factionEntryCalc, standing);
- }
- return res;
- }
- else
- return ModifyOneFactionReputation(factionEntry, standing);
-}
-
-bool Player::ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing)
-{
- FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
- if (itr != m_factions.end())
- {
- int32 BaseRep = GetBaseReputation(factionEntry);
- int32 new_rep = BaseRep + itr->second.Standing + standing;
-
- if (new_rep > Reputation_Cap)
- new_rep = Reputation_Cap;
- else
- if (new_rep < Reputation_Bottom)
- new_rep = Reputation_Bottom;
-
- if(ReputationToRank(new_rep) <= REP_HOSTILE)
- SetFactionAtWar(&itr->second,true);
-
- itr->second.Standing = new_rep - BaseRep;
- itr->second.Changed = true;
-
- SetFactionVisible(&itr->second);
-
- ReputationChanged(factionEntry);
-
- GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION,factionEntry->ID);
- GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION,factionEntry->ID);
-
- SendFactionState(&(itr->second));
-
- return true;
- }
- return false;
-}
-
-bool Player::SetFactionReputation(uint32 FactionTemplateId, int32 standing)
-{
- FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId);
-
- if(!factionTemplateEntry)
- {
- sLog.outError("Player::SetFactionReputation: Can't set reputation of %s for unknown faction (faction template id) #%u.", GetName(), FactionTemplateId);
- return false;
- }
-
- FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction);
-
- // Faction without recorded reputation. Just ignore.
- if(!factionEntry)
- return false;
-
- return SetFactionReputation(factionEntry, standing);
-}
-
-bool Player::SetFactionReputation(FactionEntry const* factionEntry, int32 standing)
-{
- SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID);
- if (flist)
- {
- bool res = false;
- for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr)
- {
- FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr);
- if(factionEntryCalc)
- res = SetOneFactionReputation(factionEntryCalc, standing);
- }
- return res;
- }
- else
- return SetOneFactionReputation(factionEntry, standing);
-}
-
-bool Player::SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing)
-{
- FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
- if (itr != m_factions.end())
- {
- if (standing > Reputation_Cap)
- standing = Reputation_Cap;
- else
- if (standing < Reputation_Bottom)
- standing = Reputation_Bottom;
-
- int32 BaseRep = GetBaseReputation(factionEntry);
- itr->second.Standing = standing - BaseRep;
- itr->second.Changed = true;
-
- SetFactionVisible(&itr->second);
-
- if(ReputationToRank(standing) <= REP_HOSTILE)
- SetFactionAtWar(&itr->second,true);
-
- SendFactionState(&(itr->second));
- GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION,factionEntry->ID);
- GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION,factionEntry->ID);
- return true;
- }
- return false;
-}
-
-void Player::ApplyForceReaction( uint32 faction_id,ReputationRank rank,bool apply )
-{
- if(apply)
- m_forcedReactions[faction_id] = rank;
- else
- m_forcedReactions.erase(faction_id);
-}
-
-void Player::SendForceReactions()
-{
- WorldPacket data;
- data.Initialize(SMSG_SET_FORCED_REACTIONS, 4+m_forcedReactions.size()*(4+4));
- data << uint32(m_forcedReactions.size());
- for(ForcedReactions::const_iterator itr = m_forcedReactions.begin(); itr != m_forcedReactions.end(); ++itr)
- {
- data << uint32(itr->first); // faction_id (Faction.dbc)
- data << uint32(itr->second); // reputation rank
- }
- SendDirectMessage(&data);
+ FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction);
+ return GetReputationMgr().GetRank(factionEntry);
}
//Calculate total reputation percent player gain with quest/creature level
@@ -6171,16 +5737,16 @@ void Player::RewardReputation(Unit *pVictim, float rate)
int32 donerep1 = CalculateReputationGain(pVictim->getLevel(),Rep->repvalue1,false);
donerep1 = int32(donerep1*rate);
FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1);
- uint32 current_reputation_rank1 = GetReputationRank(factionEntry1);
+ uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1);
if(factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1)
- ModifyFactionReputation(factionEntry1, donerep1);
+ GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
// Wiki: Team factions value divided by 2
if(Rep->is_teamaward1)
{
FactionEntry const *team1_factionEntry = sFactionStore.LookupEntry(factionEntry1->team);
if(team1_factionEntry)
- ModifyFactionReputation(team1_factionEntry, donerep1 / 2);
+ GetReputationMgr().ModifyReputation(team1_factionEntry, donerep1 / 2);
}
}
@@ -6189,16 +5755,16 @@ void Player::RewardReputation(Unit *pVictim, float rate)
int32 donerep2 = CalculateReputationGain(pVictim->getLevel(),Rep->repvalue2,false);
donerep2 = int32(donerep2*rate);
FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2);
- uint32 current_reputation_rank2 = GetReputationRank(factionEntry2);
+ uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
if(factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2)
- ModifyFactionReputation(factionEntry2, donerep2);
+ GetReputationMgr().ModifyReputation(factionEntry2, donerep2);
// Wiki: Team factions value divided by 2
if(Rep->is_teamaward2)
{
FactionEntry const *team2_factionEntry = sFactionStore.LookupEntry(factionEntry2->team);
if(team2_factionEntry)
- ModifyFactionReputation(team2_factionEntry, donerep2 / 2);
+ GetReputationMgr().ModifyReputation(team2_factionEntry, donerep2 / 2);
}
}
}
@@ -6214,7 +5780,7 @@ void Player::RewardReputation(Quest const *pQuest)
int32 rep = CalculateReputationGain(GetQuestLevel(pQuest),pQuest->RewRepValue[i],true);
FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i]);
if(factionEntry)
- ModifyFactionReputation(factionEntry, rep);
+ GetReputationMgr().ModifyReputation(factionEntry, rep);
}
}
@@ -10633,7 +10199,7 @@ uint8 Player::CanUseAmmo( uint32 item ) const
}
if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) )
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
- /*if( GetReputation() < pProto->RequiredReputation )
+ /*if( GetReputationMgr().GetReputation() < pProto->RequiredReputation )
return EQUIP_ERR_CANT_EQUIP_REPUTATION;
*/
if( getLevel() < pProto->RequiredLevel )
@@ -12822,7 +12388,7 @@ bool Player::CanCompleteQuest( uint32 quest_id )
}
uint32 repFacId = qInfo->GetRepObjectiveFaction();
- if ( repFacId && GetReputation(repFacId) < qInfo->GetRepObjectiveValue() )
+ if ( repFacId && GetReputationMgr().GetReputation(repFacId) < qInfo->GetRepObjectiveValue() )
return false;
return true;
@@ -12957,7 +12523,7 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver )
if( pQuest->GetRepObjectiveFaction() )
if(FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->GetRepObjectiveFaction()))
- SetFactionVisible(factionEntry);
+ GetReputationMgr().SetVisible(factionEntry);
uint32 qtime = 0;
if( pQuest->HasFlag( QUEST_TRINITY_FLAGS_TIMED ) )
@@ -13450,7 +13016,7 @@ bool Player::SatisfyQuestRace( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg )
{
uint32 fIdMin = qInfo->GetRequiredMinRepFaction(); //Min required rep
- if(fIdMin && GetReputation(fIdMin) < qInfo->GetRequiredMinRepValue())
+ if(fIdMin && GetReputationMgr().GetReputation(fIdMin) < qInfo->GetRequiredMinRepValue())
{
if( msg )
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
@@ -13458,7 +13024,7 @@ bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg )
}
uint32 fIdMax = qInfo->GetRequiredMaxRepFaction(); //Max required rep
- if(fIdMax && GetReputation(fIdMax) >= qInfo->GetRequiredMaxRepValue())
+ if(fIdMax && GetReputationMgr().GetReputation(fIdMax) >= qInfo->GetRequiredMaxRepValue())
{
if( msg )
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
@@ -14115,13 +13681,13 @@ void Player::ReputationChanged(FactionEntry const* factionEntry )
QuestStatusData& q_status = mQuestStatus[questid];
if( q_status.m_status == QUEST_STATUS_INCOMPLETE )
{
- if(GetReputation(factionEntry) >= qInfo->GetRepObjectiveValue())
+ if(GetReputationMgr().GetReputation(factionEntry) >= qInfo->GetRepObjectiveValue())
if ( CanCompleteQuest( questid ) )
CompleteQuest( questid );
}
else if( q_status.m_status == QUEST_STATUS_COMPLETE )
{
- if(GetReputation(factionEntry) < qInfo->GetRepObjectiveValue())
+ if(GetReputationMgr().GetReputation(factionEntry) < qInfo->GetRepObjectiveValue())
IncompleteQuest( questid );
}
}
@@ -14948,7 +14514,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
_LoadTutorials(holder->GetResult(PLAYER_LOGIN_QUERY_LOADTUTORIALS));
// must be before inventory (some items required reputation check)
- _LoadReputation(holder->GetResult(PLAYER_LOGIN_QUERY_LOADREPUTATION));
+ m_reputationMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADREPUTATION));
_LoadInventory(holder->GetResult(PLAYER_LOGIN_QUERY_LOADINVENTORY), time_diff);
@@ -15692,61 +15258,6 @@ void Player::_LoadDailyQuestStatus(QueryResult *result)
m_DailyQuestChanged = false;
}
-void Player::_LoadReputation(QueryResult *result)
-{
- m_factions.clear();
-
- // Set initial reputations (so everything is nifty before DB data load)
- SetInitialFactions();
-
- //QueryResult *result = CharacterDatabase.PQuery("SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'",GetGUIDLow());
-
- if(result)
- {
- do
- {
- Field *fields = result->Fetch();
-
- FactionEntry const *factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt32());
- if( factionEntry && (factionEntry->reputationListID >= 0))
- {
- FactionState* faction = &m_factions[factionEntry->reputationListID];
-
- // update standing to current
- faction->Standing = int32(fields[1].GetUInt32());
-
- uint32 dbFactionFlags = fields[2].GetUInt32();
-
- if( dbFactionFlags & FACTION_FLAG_VISIBLE )
- SetFactionVisible(faction); // have internal checks for forced invisibility
-
- if( dbFactionFlags & FACTION_FLAG_INACTIVE)
- SetFactionInactive(faction,true); // have internal checks for visibility requirement
-
- if( dbFactionFlags & FACTION_FLAG_AT_WAR ) // DB at war
- SetFactionAtWar(faction,true); // have internal checks for FACTION_FLAG_PEACE_FORCED
- else // DB not at war
- {
- // allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN)
- if( faction->Flags & FACTION_FLAG_VISIBLE )
- SetFactionAtWar(faction,false); // have internal checks for FACTION_FLAG_PEACE_FORCED
- }
-
- // set atWar for hostile
- if(GetReputationRank(factionEntry) <= REP_HOSTILE)
- SetFactionAtWar(faction,true);
-
- // reset changed flag if values similar to saved in DB
- if(faction->Flags==dbFactionFlags)
- faction->Changed = false;
- }
- }
- while( result->NextRow() );
-
- delete result;
- }
-}
-
void Player::_LoadSpells(QueryResult *result)
{
//QueryResult *result = CharacterDatabase.PQuery("SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'",GetGUIDLow());
@@ -16297,7 +15808,8 @@ void Player::SaveToDB()
_SaveSpellCooldowns();
_SaveActions();
_SaveAuras();
- _SaveReputation();
+ m_achievementMgr.SaveToDB();
+ m_reputationMgr.SaveToDB();
CharacterDatabase.CommitTransaction();
@@ -16311,7 +15823,6 @@ void Player::SaveToDB()
// save pet (hunter pet level and experience and all type pets health/mana).
if(Pet* pet = GetPet())
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
- m_achievementMgr.SaveToDB();
}
// fast save function for item/money cheating preventing - save only inventory and money state
@@ -16576,19 +16087,6 @@ void Player::_SaveDailyQuestStatus()
GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx),uint64(m_lastDailyQuestTime));
}
-void Player::_SaveReputation()
-{
- for(FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
- {
- if (itr->second.Changed)
- {
- CharacterDatabase.PExecute("DELETE FROM character_reputation WHERE guid = '%u' AND faction='%u'", GetGUIDLow(), itr->second.ID);
- CharacterDatabase.PExecute("INSERT INTO character_reputation (guid,faction,standing,flags) VALUES ('%u', '%u', '%i', '%u')", GetGUIDLow(), itr->second.ID, itr->second.Standing, itr->second.Flags);
- itr->second.Changed = false;
- }
- }
-}
-
void Player::_SaveSpells()
{
for (PlayerSpellMap::iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end();)
@@ -18921,7 +18419,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
GetSession()->SendPacket(&data);
SendInitialActionButtons();
- SendInitialReputations();
+ m_reputationMgr.SendInitialReputations();
m_achievementMgr.SendAllAchievementData();
// update zone