From 10a1573c8eb453c55b9cc0898e1dcca2e897bce2 Mon Sep 17 00:00:00 2001 From: Lynx3d Date: Sun, 21 Nov 2010 23:46:01 +0100 Subject: [PATCH] [10775] Use separate vars to indicate whether reputation needs to be sent or needs to be saved. --- src/game/ReputationMgr.cpp | 39 ++++++++++++++++++++++++-------------- src/game/ReputationMgr.h | 5 +++-- src/shared/revision_nr.h | 2 +- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/game/ReputationMgr.cpp b/src/game/ReputationMgr.cpp index ad77c520c..ad5292aa3 100644 --- a/src/game/ReputationMgr.cpp +++ b/src/game/ReputationMgr.cpp @@ -120,7 +120,7 @@ void ReputationMgr::SendForceReactions() m_player->SendDirectMessage(&data); } -void ReputationMgr::SendState(FactionState const* faction) const +void ReputationMgr::SendState(FactionState const* faction) { uint32 count = 1; @@ -134,13 +134,18 @@ void ReputationMgr::SendState(FactionState const* faction) const data << (uint32) faction->ReputationListID; data << (uint32) faction->Standing; - for(FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr) + for(FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr) { - if (itr->second.Changed && itr->second.ReputationListID != faction->ReputationListID) + if (itr->second.needSend) { - data << (uint32) itr->second.ReputationListID; - data << (uint32) itr->second.Standing; - ++count; + itr->second.needSend = false; + if (itr->second.ReputationListID != faction->ReputationListID) + { + data << (uint32) itr->second.ReputationListID; + data << (uint32) itr->second.Standing; + + ++count; + } } } @@ -211,7 +216,8 @@ void ReputationMgr::Initialize() newFaction.ReputationListID = factionEntry->reputationListID; newFaction.Standing = 0; newFaction.Flags = GetDefaultStateFlags(factionEntry); - newFaction.Changed = true; + newFaction.needSend = true; + newFaction.needSave = true; if( newFaction.Flags & FACTION_FLAG_VISIBLE ) ++m_visibleFactionCount; @@ -311,7 +317,8 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in ReputationRank new_rank = ReputationToRank(standing); itr->second.Standing = standing - BaseRep; - itr->second.Changed = true; + itr->second.needSend = true; + itr->second.needSave = true; SetVisible(&itr->second); @@ -364,7 +371,8 @@ void ReputationMgr::SetVisible(FactionState* faction) return; faction->Flags |= FACTION_FLAG_VISIBLE; - faction->Changed = true; + faction->needSend = true; + faction->needSave = true; ++m_visibleFactionCount; @@ -399,7 +407,8 @@ void ReputationMgr::SetAtWar(FactionState* faction, bool atWar) else faction->Flags &= ~FACTION_FLAG_AT_WAR; - faction->Changed = true; + faction->needSend = true; + faction->needSave = true; } void ReputationMgr::SetInactive( RepListID repListID, bool on ) @@ -426,7 +435,8 @@ void ReputationMgr::SetInactive(FactionState* faction, bool inactive) else faction->Flags &= ~FACTION_FLAG_INACTIVE; - faction->Changed = true; + faction->needSend = true; + faction->needSave = true; } void ReputationMgr::LoadFromDB(QueryResult *result) @@ -479,7 +489,8 @@ void ReputationMgr::LoadFromDB(QueryResult *result) // reset changed flag if values similar to saved in DB if(faction->Flags==dbFactionFlags) - faction->Changed = false; + faction->needSend = false; + faction->needSave = false; } } while( result->NextRow() ); @@ -492,11 +503,11 @@ void ReputationMgr::SaveToDB() { for(FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr) { - if (itr->second.Changed) + if (itr->second.needSave) { CharacterDatabase.PExecute("DELETE FROM character_reputation WHERE guid = '%u' AND faction='%u'", m_player->GetGUIDLow(), itr->second.ID); CharacterDatabase.PExecute("INSERT INTO character_reputation (guid,faction,standing,flags) VALUES ('%u', '%u', '%i', '%u')", m_player->GetGUIDLow(), itr->second.ID, itr->second.Standing, itr->second.Flags); - itr->second.Changed = false; + itr->second.needSave = false; } } } diff --git a/src/game/ReputationMgr.h b/src/game/ReputationMgr.h index 6efcf67b4..4ffac61c9 100644 --- a/src/game/ReputationMgr.h +++ b/src/game/ReputationMgr.h @@ -43,7 +43,8 @@ struct FactionState RepListID ReputationListID; uint32 Flags; int32 Standing; - bool Changed; + bool needSend; + bool needSave; }; typedef std::map FactionStateList; @@ -121,7 +122,7 @@ class ReputationMgr public: // senders void SendInitialReputations(); void SendForceReactions(); - void SendState(FactionState const* faction) const; + void SendState(FactionState const* faction); private: // internal helper functions void Initialize(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c999ca4f8..050fe6996 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10774" + #define REVISION_NR "10775" #endif // __REVISION_NR_H__