/// <summary> /// Creates a Reputation object that represents the relation to the given faction, or null /// </summary> /// <param name="faction">The Faction which the Reputation should be with</param> private Reputation Create(Faction faction) { int defaultReputationValue = this.GetDefaultReputationValue(faction); ReputationFlags defaultReputationFlags = this.GetDefaultReputationFlags(faction); Reputation rep = new Reputation(this.m_owner.Record.CreateReputationRecord(), faction, defaultReputationValue, defaultReputationFlags); this.m_byIndex.Add(faction.ReputationIndex, rep); FactionHandler.SendReputationStandingUpdate((IPacketReceiver)this.m_owner.Client, rep); return(rep); }
public Reputation(ReputationRecord record, Faction faction, int defaultValue, ReputationFlags defaultFlags) { m_record = record; m_record.ReputationIndex = faction.ReputationIndex; m_record.Value = defaultValue; m_record.Flags = defaultFlags; Faction = faction; m_standing = GetStanding(defaultValue); m_record.Save(); }
public Reputation(ReputationRecord record, Faction faction, int defaultValue, ReputationFlags defaultFlags) { m_record = record; m_record.ReputationIndex = faction.ReputationIndex; m_record.Value = defaultValue; m_record.Flags = defaultFlags; Faction = faction; m_standing = GetStanding(defaultValue); RealmWorldDBMgr.DatabaseProvider.SaveOrUpdate(m_record); }
ReputationFlags GetDefaultStateFlags(FactionRecord factionEntry) { ReputationFlags flags = ReputationFlags.None; int dataIndex = GetFactionDataIndexForRaceAndClass(factionEntry); if (dataIndex > 0) { flags = (ReputationFlags)factionEntry.ReputationFlags[dataIndex]; } if (Global.DB2Mgr.GetParagonReputation(factionEntry.Id) != null) { flags |= ReputationFlags.ShowPropagated; } return(flags); }
public Reputation(ReputationRecord record, Faction faction, int defaultValue, ReputationFlags defaultFlags) { this.m_record = record; this.m_record.ReputationIndex = faction.ReputationIndex; this.m_record.Value = defaultValue; this.m_record.Flags = defaultFlags; this.Faction = faction; this.m_standing = Reputation.GetStanding(defaultValue); this.m_record.Save(); }
public void LoadFromDB(SQLResult result) { // Set initial reputations (so everything is nifty before DB data load) Initialize(); if (!result.IsEmpty()) { do { var factionEntry = CliDB.FactionStorage.LookupByKey(result.Read <uint>(0)); if (factionEntry != null && factionEntry.CanHaveReputation()) { var faction = _factions.LookupByKey((uint)factionEntry.ReputationIndex); if (faction == null) { continue; } // update standing to current faction.Standing = result.Read <int>(1); // update counters if (factionEntry.FriendshipRepID == 0) { int BaseRep = GetBaseReputation(factionEntry); ReputationRank old_rank = ReputationToRank(factionEntry, BaseRep); ReputationRank new_rank = ReputationToRank(factionEntry, BaseRep + faction.Standing); UpdateRankCounters(old_rank, new_rank); } ReputationFlags dbFactionFlags = (ReputationFlags)result.Read <uint>(2); if (dbFactionFlags.HasFlag(ReputationFlags.Visible)) { SetVisible(faction); // have internal checks for forced invisibility } if (dbFactionFlags.HasFlag(ReputationFlags.Inactive)) { SetInactive(faction, true); // have internal checks for visibility requirement } if (dbFactionFlags.HasFlag(ReputationFlags.AtWar)) // 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.HasFlag(ReputationFlags.Visible)) { SetAtWar(faction, false); // have internal checks for FACTION_FLAG_PEACE_FORCED } } // set atWar for hostile if (GetRank(factionEntry) <= ReputationRank.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()); } }