diff --git a/Source/Framework/Constants/SharedConst.cs b/Source/Framework/Constants/SharedConst.cs index 8299b9689..38a8587ca 100644 --- a/Source/Framework/Constants/SharedConst.cs +++ b/Source/Framework/Constants/SharedConst.cs @@ -474,12 +474,14 @@ namespace Framework.Constants Monster = 8 // aggressive creature from monster team // if none flags set then non-aggressive creature } + public enum FactionTemplateFlags { PVP = 0x800, // flagged for PvP ContestedGuard = 0x1000, // faction will attack players that were involved in PvP combats HostileByDefault = 0x2000 } + public enum ReputationRank { None = -1, @@ -494,6 +496,7 @@ namespace Framework.Constants Max = 8, Min = Hated } + public enum ReputationSource { Kill, @@ -504,17 +507,22 @@ namespace Framework.Constants RepeatableQuest, Spell } - public enum FactionFlags + + [Flags] + public enum ReputationFlags : ushort { - None = 0x00, // no faction flag - Visible = 0x01, // makes visible in client (set or can be set at interaction with target of this faction) - AtWar = 0x02, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation - Hidden = 0x04, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client) - InvisibleForced = 0x08, // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions - PeaceForced = 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions - Inactive = 0x20, // player controlled, state stored in characters.data (CMSG_SET_FACTION_INACTIVE) - Rival = 0x40, // flag for the two competing outland factions - Special = 0x80 // horde and alliance home cities and their northrend allies have this flag + None = 0x0000, + Visible = 0x0001, // makes visible in client (set or can be set at interaction with target of this faction) + AtWar = 0x0002, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation + Hidden = 0x0004, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client) + Header = 0x0008, // Display as header in UI + Peaceful = 0x0010, + Inactive = 0x0020, // player controlled (CMSG_SET_FACTION_INACTIVE) + ShowPropagated = 0x0040, + HeaderShowsBar = 0x0080, // Header has its own reputation bar + CapitalCityForRaceChange = 0x0100, + Guild = 0x0200, + GarrisonInvasion = 0x0400 } public enum Gender : sbyte diff --git a/Source/Game/Chat/Commands/CharacterCommands.cs b/Source/Game/Chat/Commands/CharacterCommands.cs index 3c52fe53f..c6028dd4c 100644 --- a/Source/Game/Chat/Commands/CharacterCommands.cs +++ b/Source/Game/Chat/Commands/CharacterCommands.cs @@ -423,17 +423,17 @@ namespace Game.Chat ss.AppendFormat(" {0} ({1})", rankName, target.GetReputationMgr().GetReputation(factionEntry)); - if (faction.Flags.HasAnyFlag(FactionFlags.Visible)) + if (faction.Flags.HasFlag(ReputationFlags.Visible)) ss.Append(handler.GetCypherString(CypherStrings.FactionVisible)); - if (faction.Flags.HasAnyFlag(FactionFlags.AtWar)) + if (faction.Flags.HasFlag(ReputationFlags.AtWar)) ss.Append(handler.GetCypherString(CypherStrings.FactionAtwar)); - if (faction.Flags.HasAnyFlag(FactionFlags.PeaceForced)) + if (faction.Flags.HasFlag(ReputationFlags.Peaceful)) ss.Append(handler.GetCypherString(CypherStrings.FactionPeaceForced)); - if (faction.Flags.HasAnyFlag(FactionFlags.Hidden)) + if (faction.Flags.HasFlag(ReputationFlags.Hidden)) ss.Append(handler.GetCypherString(CypherStrings.FactionHidden)); - if (faction.Flags.HasAnyFlag(FactionFlags.InvisibleForced)) + if (faction.Flags.HasFlag(ReputationFlags.Header)) ss.Append(handler.GetCypherString(CypherStrings.FactionInvisibleForced)); - if (faction.Flags.HasAnyFlag(FactionFlags.Inactive)) + if (faction.Flags.HasFlag(ReputationFlags.Inactive)) ss.Append(handler.GetCypherString(CypherStrings.FactionInactive)); handler.SendSysMessage(ss.ToString()); diff --git a/Source/Game/Chat/Commands/LookupCommands.cs b/Source/Game/Chat/Commands/LookupCommands.cs index 59e9c420f..f0d2c9361 100644 --- a/Source/Game/Chat/Commands/LookupCommands.cs +++ b/Source/Game/Chat/Commands/LookupCommands.cs @@ -280,17 +280,17 @@ namespace Game.Chat ss.AppendFormat(" {0}|h|r ({1})", rankName, target.GetReputationMgr().GetReputation(factionEntry)); - if (factionState.Flags.HasAnyFlag(FactionFlags.Visible)) + if (factionState.Flags.HasFlag(ReputationFlags.Visible)) ss.Append(handler.GetCypherString(CypherStrings.FactionVisible)); - if (factionState.Flags.HasAnyFlag(FactionFlags.AtWar)) + if (factionState.Flags.HasFlag(ReputationFlags.AtWar)) ss.Append(handler.GetCypherString(CypherStrings.FactionAtwar)); - if (factionState.Flags.HasAnyFlag(FactionFlags.PeaceForced)) + if (factionState.Flags.HasFlag(ReputationFlags.Peaceful)) ss.Append(handler.GetCypherString(CypherStrings.FactionPeaceForced)); - if (factionState.Flags.HasAnyFlag(FactionFlags.Hidden)) + if (factionState.Flags.HasFlag(ReputationFlags.Hidden)) ss.Append(handler.GetCypherString(CypherStrings.FactionHidden)); - if (factionState.Flags.HasAnyFlag(FactionFlags.InvisibleForced)) + if (factionState.Flags.HasFlag(ReputationFlags.Header)) ss.Append(handler.GetCypherString(CypherStrings.FactionInvisibleForced)); - if (factionState.Flags.HasAnyFlag(FactionFlags.Inactive)) + if (factionState.Flags.HasFlag(ReputationFlags.Inactive)) ss.Append(handler.GetCypherString(CypherStrings.FactionInactive)); } else diff --git a/Source/Game/Entities/Unit/Unit.Combat.cs b/Source/Game/Entities/Unit/Unit.Combat.cs index 49bfaa0ac..1f8cb4bff 100644 --- a/Source/Game/Entities/Unit/Unit.Combat.cs +++ b/Source/Game/Entities/Unit/Unit.Combat.cs @@ -1704,7 +1704,7 @@ namespace Game.Entities { var repState = player.GetReputationMgr().GetState(factionEntry); if (repState != null) - if (!Convert.ToBoolean(repState.Flags & FactionFlags.AtWar)) + if (!repState.Flags.HasFlag(ReputationFlags.AtWar)) return false; } } diff --git a/Source/Game/Networking/Packets/ReputationPackets.cs b/Source/Game/Networking/Packets/ReputationPackets.cs index 7f697b8ed..5c9906b59 100644 --- a/Source/Game/Networking/Packets/ReputationPackets.cs +++ b/Source/Game/Networking/Packets/ReputationPackets.cs @@ -30,7 +30,7 @@ namespace Game.Networking.Packets { for (ushort i = 0; i < FactionCount; ++i) { - _worldPacket.WriteUInt8((byte)FactionFlags[i]); + _worldPacket.WriteUInt8((byte)((ushort)FactionFlags[i] & 0xFF)); _worldPacket.WriteInt32(FactionStandings[i]); } @@ -42,7 +42,7 @@ namespace Game.Networking.Packets public int[] FactionStandings = new int[FactionCount]; public bool[] FactionHasBonus = new bool[FactionCount]; //@todo: implement faction bonus - public FactionFlags[] FactionFlags = new FactionFlags[FactionCount]; + public ReputationFlags[] FactionFlags = new ReputationFlags[FactionCount]; } class RequestForcedReactions : ClientPacket diff --git a/Source/Game/Reputation/ReputationManager.cs b/Source/Game/Reputation/ReputationManager.cs index c3953ca7f..49b2d430d 100644 --- a/Source/Game/Reputation/ReputationManager.cs +++ b/Source/Game/Reputation/ReputationManager.cs @@ -85,7 +85,7 @@ namespace Game FactionState factionState = GetState(factionEntry); if (factionState != null) - return (factionState.Flags.HasAnyFlag(FactionFlags.AtWar)); + return factionState.Flags.HasFlag(ReputationFlags.AtWar); return false; } @@ -170,13 +170,13 @@ namespace Game _forcedReactions.Remove(faction_id); } - uint GetDefaultStateFlags(FactionRecord factionEntry) + ReputationFlags GetDefaultStateFlags(FactionRecord factionEntry) { int dataIndex = GetFactionDataIndexForRaceAndClass(factionEntry); if (dataIndex < 0) - return 0; + return ReputationFlags.None; - return factionEntry.ReputationFlags[dataIndex]; + return (ReputationFlags)factionEntry.ReputationFlags[dataIndex]; } public void SendForceReactions() @@ -261,11 +261,11 @@ namespace Game newFaction.Id = factionEntry.Id; newFaction.ReputationListID = (uint)factionEntry.ReputationIndex; newFaction.Standing = 0; - newFaction.Flags = (FactionFlags)(GetDefaultStateFlags(factionEntry) & 0xFF);//todo fixme for higher value then byte????? + newFaction.Flags = GetDefaultStateFlags(factionEntry); newFaction.needSend = true; newFaction.needSave = true; - if (Convert.ToBoolean(newFaction.Flags & FactionFlags.Visible)) + if (newFaction.Flags.HasFlag(ReputationFlags.Visible)) ++_visibleFactionCount; if (factionEntry.FriendshipRepID == 0) @@ -323,7 +323,7 @@ namespace Game { var parentState = _factions.LookupByKey(parent.ReputationIndex); // some team factions have own reputation standing, in this case do not spill to other sub-factions - if (parentState != null && parentState.Flags.HasAnyFlag(FactionFlags.Special)) + if (parentState != null && parentState.Flags.HasFlag(ReputationFlags.HeaderShowsBar)) { SetOneFactionReputation(parent, (int)spillOverRepOut, incremental); } @@ -445,15 +445,17 @@ namespace Game void SetVisible(FactionState faction) { // always invisible or hidden faction can't be make visible - // except if faction has FACTION_FLAG_SPECIAL - if (Convert.ToBoolean(faction.Flags & (FactionFlags.InvisibleForced | FactionFlags.Hidden)) && !Convert.ToBoolean(faction.Flags & FactionFlags.Special)) + if (faction.Flags.HasFlag(ReputationFlags.Hidden)) + return; + + if (faction.Flags.HasFlag(ReputationFlags.Header) && !faction.Flags.HasFlag(ReputationFlags.HeaderShowsBar)) return; // already set - if (Convert.ToBoolean(faction.Flags & FactionFlags.Visible)) + if (faction.Flags.HasFlag(ReputationFlags.Visible)) return; - faction.Flags |= FactionFlags.Visible; + faction.Flags |= ReputationFlags.Visible; faction.needSend = true; faction.needSave = true; @@ -469,7 +471,7 @@ namespace Game return; // always invisible or hidden faction can't change war state - if (Convert.ToBoolean(factionState.Flags & (FactionFlags.InvisibleForced | FactionFlags.Hidden))) + if (factionState.Flags.HasFlag(ReputationFlags.Hidden | ReputationFlags.Header)) return; SetAtWar(factionState, on); @@ -478,17 +480,17 @@ namespace Game void SetAtWar(FactionState faction, bool atWar) { // Do not allow to declare war to our own faction. But allow for rival factions (eg Aldor vs Scryer). - if (atWar && faction.Flags.HasAnyFlag(FactionFlags.PeaceForced) && !faction.Flags.HasAnyFlag(FactionFlags.Rival)) + if (atWar && faction.Flags.HasFlag(ReputationFlags.Peaceful)) return; // already set - if (((faction.Flags & FactionFlags.AtWar) != 0) == atWar) + if (faction.Flags.HasFlag(ReputationFlags.AtWar) == atWar) return; if (atWar) - faction.Flags |= FactionFlags.AtWar; + faction.Flags |= ReputationFlags.AtWar; else - faction.Flags &= ~FactionFlags.AtWar; + faction.Flags &= ~ReputationFlags.AtWar; faction.needSend = true; faction.needSave = true; @@ -506,17 +508,17 @@ namespace Game void SetInactive(FactionState faction, bool inactive) { // always invisible or hidden faction can't be inactive - if (inactive && Convert.ToBoolean(faction.Flags & (FactionFlags.InvisibleForced | FactionFlags.Hidden)) || !Convert.ToBoolean(faction.Flags & FactionFlags.Visible)) + if (faction.Flags.HasFlag(ReputationFlags.Hidden | ReputationFlags.Header) || !faction.Flags.HasFlag(ReputationFlags.Visible)) return; // already set - if (((faction.Flags & FactionFlags.Inactive) != 0) == inactive) + if (faction.Flags.HasFlag(ReputationFlags.Inactive) == inactive) return; if (inactive) - faction.Flags |= FactionFlags.Inactive; + faction.Flags |= ReputationFlags.Inactive; else - faction.Flags &= ~FactionFlags.Inactive; + faction.Flags &= ~ReputationFlags.Inactive; faction.needSend = true; faction.needSave = true; @@ -549,20 +551,20 @@ namespace Game UpdateRankCounters(old_rank, new_rank); } - FactionFlags dbFactionFlags = (FactionFlags)result.Read(2); + ReputationFlags dbFactionFlags = (ReputationFlags)result.Read(2); - if (Convert.ToBoolean(dbFactionFlags & FactionFlags.Visible)) + if (dbFactionFlags.HasFlag(ReputationFlags.Visible)) SetVisible(faction); // have internal checks for forced invisibility - if (Convert.ToBoolean(dbFactionFlags & FactionFlags.Inactive)) + if (dbFactionFlags.HasFlag(ReputationFlags.Inactive)) SetInactive(faction, true); // have internal checks for visibility requirement - if (Convert.ToBoolean(dbFactionFlags & FactionFlags.AtWar)) // DB at war + 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 (Convert.ToBoolean(faction.Flags & FactionFlags.Visible)) + if (faction.Flags.HasFlag(ReputationFlags.Visible)) SetAtWar(faction, false); // have internal checks for FACTION_FLAG_PEACE_FORCED } @@ -730,7 +732,7 @@ namespace Game public uint Id; public uint ReputationListID; public int Standing; - public FactionFlags Flags; + public ReputationFlags Flags; public bool needSend; public bool needSave; }