Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ReputationMgr::LoadFromDB(PreparedQueryResult result)
- {
- // Set initial reputations (so everything is nifty before DB data load)
- Initialize();
- //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].GetUInt16());
- if (factionEntry && (factionEntry->reputationListID >= 0))
- {
- FactionState* faction = &_factions[factionEntry->reputationListID];
- // update standing to current
- faction->Standing = fields[1].GetInt32();
- // update counters
- int32 BaseRep = GetBaseReputation(factionEntry);
- ReputationRank old_rank = ReputationToRank(BaseRep);
- ReputationRank new_rank = ReputationToRank(BaseRep + faction->Standing);
- UpdateRankCounters(old_rank, new_rank);
- uint32 dbFactionFlags = fields[2].GetUInt16();
- if (dbFactionFlags & FACTION_FLAG_VISIBLE)
- SetVisible(faction); // have internal checks for forced invisibility
- if (dbFactionFlags & FACTION_FLAG_INACTIVE)
- SetInactive(faction, true); // have internal checks for visibility requirement
- if (dbFactionFlags & FACTION_FLAG_AT_WAR) // DB at war
- SetAtWar(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)
- SetAtWar(faction, false); // have internal checks for FACTION_FLAG_PEACE_FORCED
- }
- // set atWar for hostile
- if (GetRank(factionEntry) <= REP_HOSTILE)
- SetAtWar(faction, true);
- // reset changed flag if values similar to saved in DB
- if (faction->Flags == dbFactionFlags)
- {
- faction->needSend = false;
- faction->needSave = false;
- }
- }
- }
- while (result->NextRow());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement