Advertisement
blackmanos

Untitled

Oct 16th, 2014
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. void ReputationMgr::LoadFromDB(PreparedQueryResult result)
  2. {
  3. // Set initial reputations (so everything is nifty before DB data load)
  4. Initialize();
  5.  
  6. //QueryResult* result = CharacterDatabase.PQuery("SELECT faction, standing, flags FROM character_reputation WHERE guid = '%u'", GetGUIDLow());
  7.  
  8. if (result)
  9. {
  10. do
  11. {
  12. Field* fields = result->Fetch();
  13.  
  14. FactionEntry const* factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt16());
  15. if (factionEntry && (factionEntry->reputationListID >= 0))
  16. {
  17. FactionState* faction = &_factions[factionEntry->reputationListID];
  18.  
  19. // update standing to current
  20. faction->Standing = fields[1].GetInt32();
  21.  
  22. // update counters
  23. int32 BaseRep = GetBaseReputation(factionEntry);
  24. ReputationRank old_rank = ReputationToRank(BaseRep);
  25. ReputationRank new_rank = ReputationToRank(BaseRep + faction->Standing);
  26. UpdateRankCounters(old_rank, new_rank);
  27.  
  28. uint32 dbFactionFlags = fields[2].GetUInt16();
  29.  
  30. if (dbFactionFlags & FACTION_FLAG_VISIBLE)
  31. SetVisible(faction); // have internal checks for forced invisibility
  32.  
  33. if (dbFactionFlags & FACTION_FLAG_INACTIVE)
  34. SetInactive(faction, true); // have internal checks for visibility requirement
  35.  
  36. if (dbFactionFlags & FACTION_FLAG_AT_WAR) // DB at war
  37. SetAtWar(faction, true); // have internal checks for FACTION_FLAG_PEACE_FORCED
  38. else // DB not at war
  39. {
  40. // allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN)
  41. if (faction->Flags & FACTION_FLAG_VISIBLE)
  42. SetAtWar(faction, false); // have internal checks for FACTION_FLAG_PEACE_FORCED
  43. }
  44.  
  45. // set atWar for hostile
  46. if (GetRank(factionEntry) <= REP_HOSTILE)
  47. SetAtWar(faction, true);
  48.  
  49. // reset changed flag if values similar to saved in DB
  50. if (faction->Flags == dbFactionFlags)
  51. {
  52. faction->needSend = false;
  53. faction->needSave = false;
  54. }
  55. }
  56. }
  57. while (result->NextRow());
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement