Core/Reputation: Named all reputation flags
Port From (https://github.com/TrinityCore/TrinityCore/commit/f6b919fafe45aaeba0c5572925e47562158314b1)
This commit is contained in:
@@ -474,12 +474,14 @@ namespace Framework.Constants
|
|||||||
Monster = 8 // aggressive creature from monster team
|
Monster = 8 // aggressive creature from monster team
|
||||||
// if none flags set then non-aggressive creature
|
// if none flags set then non-aggressive creature
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FactionTemplateFlags
|
public enum FactionTemplateFlags
|
||||||
{
|
{
|
||||||
PVP = 0x800, // flagged for PvP
|
PVP = 0x800, // flagged for PvP
|
||||||
ContestedGuard = 0x1000, // faction will attack players that were involved in PvP combats
|
ContestedGuard = 0x1000, // faction will attack players that were involved in PvP combats
|
||||||
HostileByDefault = 0x2000
|
HostileByDefault = 0x2000
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ReputationRank
|
public enum ReputationRank
|
||||||
{
|
{
|
||||||
None = -1,
|
None = -1,
|
||||||
@@ -494,6 +496,7 @@ namespace Framework.Constants
|
|||||||
Max = 8,
|
Max = 8,
|
||||||
Min = Hated
|
Min = Hated
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ReputationSource
|
public enum ReputationSource
|
||||||
{
|
{
|
||||||
Kill,
|
Kill,
|
||||||
@@ -504,17 +507,22 @@ namespace Framework.Constants
|
|||||||
RepeatableQuest,
|
RepeatableQuest,
|
||||||
Spell
|
Spell
|
||||||
}
|
}
|
||||||
public enum FactionFlags
|
|
||||||
|
[Flags]
|
||||||
|
public enum ReputationFlags : ushort
|
||||||
{
|
{
|
||||||
None = 0x00, // no faction flag
|
None = 0x0000,
|
||||||
Visible = 0x01, // makes visible in client (set or can be set at interaction with target of this faction)
|
Visible = 0x0001, // 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
|
AtWar = 0x0002, // 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)
|
Hidden = 0x0004, // 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
|
Header = 0x0008, // Display as header in UI
|
||||||
PeaceForced = 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions
|
Peaceful = 0x0010,
|
||||||
Inactive = 0x20, // player controlled, state stored in characters.data (CMSG_SET_FACTION_INACTIVE)
|
Inactive = 0x0020, // player controlled (CMSG_SET_FACTION_INACTIVE)
|
||||||
Rival = 0x40, // flag for the two competing outland factions
|
ShowPropagated = 0x0040,
|
||||||
Special = 0x80 // horde and alliance home cities and their northrend allies have this flag
|
HeaderShowsBar = 0x0080, // Header has its own reputation bar
|
||||||
|
CapitalCityForRaceChange = 0x0100,
|
||||||
|
Guild = 0x0200,
|
||||||
|
GarrisonInvasion = 0x0400
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Gender : sbyte
|
public enum Gender : sbyte
|
||||||
|
|||||||
@@ -423,17 +423,17 @@ namespace Game.Chat
|
|||||||
|
|
||||||
ss.AppendFormat(" {0} ({1})", rankName, target.GetReputationMgr().GetReputation(factionEntry));
|
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));
|
ss.Append(handler.GetCypherString(CypherStrings.FactionVisible));
|
||||||
if (faction.Flags.HasAnyFlag(FactionFlags.AtWar))
|
if (faction.Flags.HasFlag(ReputationFlags.AtWar))
|
||||||
ss.Append(handler.GetCypherString(CypherStrings.FactionAtwar));
|
ss.Append(handler.GetCypherString(CypherStrings.FactionAtwar));
|
||||||
if (faction.Flags.HasAnyFlag(FactionFlags.PeaceForced))
|
if (faction.Flags.HasFlag(ReputationFlags.Peaceful))
|
||||||
ss.Append(handler.GetCypherString(CypherStrings.FactionPeaceForced));
|
ss.Append(handler.GetCypherString(CypherStrings.FactionPeaceForced));
|
||||||
if (faction.Flags.HasAnyFlag(FactionFlags.Hidden))
|
if (faction.Flags.HasFlag(ReputationFlags.Hidden))
|
||||||
ss.Append(handler.GetCypherString(CypherStrings.FactionHidden));
|
ss.Append(handler.GetCypherString(CypherStrings.FactionHidden));
|
||||||
if (faction.Flags.HasAnyFlag(FactionFlags.InvisibleForced))
|
if (faction.Flags.HasFlag(ReputationFlags.Header))
|
||||||
ss.Append(handler.GetCypherString(CypherStrings.FactionInvisibleForced));
|
ss.Append(handler.GetCypherString(CypherStrings.FactionInvisibleForced));
|
||||||
if (faction.Flags.HasAnyFlag(FactionFlags.Inactive))
|
if (faction.Flags.HasFlag(ReputationFlags.Inactive))
|
||||||
ss.Append(handler.GetCypherString(CypherStrings.FactionInactive));
|
ss.Append(handler.GetCypherString(CypherStrings.FactionInactive));
|
||||||
|
|
||||||
handler.SendSysMessage(ss.ToString());
|
handler.SendSysMessage(ss.ToString());
|
||||||
|
|||||||
@@ -280,17 +280,17 @@ namespace Game.Chat
|
|||||||
|
|
||||||
ss.AppendFormat(" {0}|h|r ({1})", rankName, target.GetReputationMgr().GetReputation(factionEntry));
|
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));
|
ss.Append(handler.GetCypherString(CypherStrings.FactionVisible));
|
||||||
if (factionState.Flags.HasAnyFlag(FactionFlags.AtWar))
|
if (factionState.Flags.HasFlag(ReputationFlags.AtWar))
|
||||||
ss.Append(handler.GetCypherString(CypherStrings.FactionAtwar));
|
ss.Append(handler.GetCypherString(CypherStrings.FactionAtwar));
|
||||||
if (factionState.Flags.HasAnyFlag(FactionFlags.PeaceForced))
|
if (factionState.Flags.HasFlag(ReputationFlags.Peaceful))
|
||||||
ss.Append(handler.GetCypherString(CypherStrings.FactionPeaceForced));
|
ss.Append(handler.GetCypherString(CypherStrings.FactionPeaceForced));
|
||||||
if (factionState.Flags.HasAnyFlag(FactionFlags.Hidden))
|
if (factionState.Flags.HasFlag(ReputationFlags.Hidden))
|
||||||
ss.Append(handler.GetCypherString(CypherStrings.FactionHidden));
|
ss.Append(handler.GetCypherString(CypherStrings.FactionHidden));
|
||||||
if (factionState.Flags.HasAnyFlag(FactionFlags.InvisibleForced))
|
if (factionState.Flags.HasFlag(ReputationFlags.Header))
|
||||||
ss.Append(handler.GetCypherString(CypherStrings.FactionInvisibleForced));
|
ss.Append(handler.GetCypherString(CypherStrings.FactionInvisibleForced));
|
||||||
if (factionState.Flags.HasAnyFlag(FactionFlags.Inactive))
|
if (factionState.Flags.HasFlag(ReputationFlags.Inactive))
|
||||||
ss.Append(handler.GetCypherString(CypherStrings.FactionInactive));
|
ss.Append(handler.GetCypherString(CypherStrings.FactionInactive));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1704,7 +1704,7 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
var repState = player.GetReputationMgr().GetState(factionEntry);
|
var repState = player.GetReputationMgr().GetState(factionEntry);
|
||||||
if (repState != null)
|
if (repState != null)
|
||||||
if (!Convert.ToBoolean(repState.Flags & FactionFlags.AtWar))
|
if (!repState.Flags.HasFlag(ReputationFlags.AtWar))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace Game.Networking.Packets
|
|||||||
{
|
{
|
||||||
for (ushort i = 0; i < FactionCount; ++i)
|
for (ushort i = 0; i < FactionCount; ++i)
|
||||||
{
|
{
|
||||||
_worldPacket.WriteUInt8((byte)FactionFlags[i]);
|
_worldPacket.WriteUInt8((byte)((ushort)FactionFlags[i] & 0xFF));
|
||||||
_worldPacket.WriteInt32(FactionStandings[i]);
|
_worldPacket.WriteInt32(FactionStandings[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ namespace Game.Networking.Packets
|
|||||||
|
|
||||||
public int[] FactionStandings = new int[FactionCount];
|
public int[] FactionStandings = new int[FactionCount];
|
||||||
public bool[] FactionHasBonus = new bool[FactionCount]; //@todo: implement faction bonus
|
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
|
class RequestForcedReactions : ClientPacket
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace Game
|
|||||||
|
|
||||||
FactionState factionState = GetState(factionEntry);
|
FactionState factionState = GetState(factionEntry);
|
||||||
if (factionState != null)
|
if (factionState != null)
|
||||||
return (factionState.Flags.HasAnyFlag(FactionFlags.AtWar));
|
return factionState.Flags.HasFlag(ReputationFlags.AtWar);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,13 +170,13 @@ namespace Game
|
|||||||
_forcedReactions.Remove(faction_id);
|
_forcedReactions.Remove(faction_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint GetDefaultStateFlags(FactionRecord factionEntry)
|
ReputationFlags GetDefaultStateFlags(FactionRecord factionEntry)
|
||||||
{
|
{
|
||||||
int dataIndex = GetFactionDataIndexForRaceAndClass(factionEntry);
|
int dataIndex = GetFactionDataIndexForRaceAndClass(factionEntry);
|
||||||
if (dataIndex < 0)
|
if (dataIndex < 0)
|
||||||
return 0;
|
return ReputationFlags.None;
|
||||||
|
|
||||||
return factionEntry.ReputationFlags[dataIndex];
|
return (ReputationFlags)factionEntry.ReputationFlags[dataIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendForceReactions()
|
public void SendForceReactions()
|
||||||
@@ -261,11 +261,11 @@ namespace Game
|
|||||||
newFaction.Id = factionEntry.Id;
|
newFaction.Id = factionEntry.Id;
|
||||||
newFaction.ReputationListID = (uint)factionEntry.ReputationIndex;
|
newFaction.ReputationListID = (uint)factionEntry.ReputationIndex;
|
||||||
newFaction.Standing = 0;
|
newFaction.Standing = 0;
|
||||||
newFaction.Flags = (FactionFlags)(GetDefaultStateFlags(factionEntry) & 0xFF);//todo fixme for higher value then byte?????
|
newFaction.Flags = GetDefaultStateFlags(factionEntry);
|
||||||
newFaction.needSend = true;
|
newFaction.needSend = true;
|
||||||
newFaction.needSave = true;
|
newFaction.needSave = true;
|
||||||
|
|
||||||
if (Convert.ToBoolean(newFaction.Flags & FactionFlags.Visible))
|
if (newFaction.Flags.HasFlag(ReputationFlags.Visible))
|
||||||
++_visibleFactionCount;
|
++_visibleFactionCount;
|
||||||
|
|
||||||
if (factionEntry.FriendshipRepID == 0)
|
if (factionEntry.FriendshipRepID == 0)
|
||||||
@@ -323,7 +323,7 @@ namespace Game
|
|||||||
{
|
{
|
||||||
var parentState = _factions.LookupByKey(parent.ReputationIndex);
|
var parentState = _factions.LookupByKey(parent.ReputationIndex);
|
||||||
// some team factions have own reputation standing, in this case do not spill to other sub-factions
|
// 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);
|
SetOneFactionReputation(parent, (int)spillOverRepOut, incremental);
|
||||||
}
|
}
|
||||||
@@ -445,15 +445,17 @@ namespace Game
|
|||||||
void SetVisible(FactionState faction)
|
void SetVisible(FactionState faction)
|
||||||
{
|
{
|
||||||
// always invisible or hidden faction can't be make visible
|
// always invisible or hidden faction can't be make visible
|
||||||
// except if faction has FACTION_FLAG_SPECIAL
|
if (faction.Flags.HasFlag(ReputationFlags.Hidden))
|
||||||
if (Convert.ToBoolean(faction.Flags & (FactionFlags.InvisibleForced | FactionFlags.Hidden)) && !Convert.ToBoolean(faction.Flags & FactionFlags.Special))
|
return;
|
||||||
|
|
||||||
|
if (faction.Flags.HasFlag(ReputationFlags.Header) && !faction.Flags.HasFlag(ReputationFlags.HeaderShowsBar))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// already set
|
// already set
|
||||||
if (Convert.ToBoolean(faction.Flags & FactionFlags.Visible))
|
if (faction.Flags.HasFlag(ReputationFlags.Visible))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
faction.Flags |= FactionFlags.Visible;
|
faction.Flags |= ReputationFlags.Visible;
|
||||||
faction.needSend = true;
|
faction.needSend = true;
|
||||||
faction.needSave = true;
|
faction.needSave = true;
|
||||||
|
|
||||||
@@ -469,7 +471,7 @@ namespace Game
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// always invisible or hidden faction can't change war state
|
// 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;
|
return;
|
||||||
|
|
||||||
SetAtWar(factionState, on);
|
SetAtWar(factionState, on);
|
||||||
@@ -478,17 +480,17 @@ namespace Game
|
|||||||
void SetAtWar(FactionState faction, bool atWar)
|
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).
|
// 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;
|
return;
|
||||||
|
|
||||||
// already set
|
// already set
|
||||||
if (((faction.Flags & FactionFlags.AtWar) != 0) == atWar)
|
if (faction.Flags.HasFlag(ReputationFlags.AtWar) == atWar)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (atWar)
|
if (atWar)
|
||||||
faction.Flags |= FactionFlags.AtWar;
|
faction.Flags |= ReputationFlags.AtWar;
|
||||||
else
|
else
|
||||||
faction.Flags &= ~FactionFlags.AtWar;
|
faction.Flags &= ~ReputationFlags.AtWar;
|
||||||
|
|
||||||
faction.needSend = true;
|
faction.needSend = true;
|
||||||
faction.needSave = true;
|
faction.needSave = true;
|
||||||
@@ -506,17 +508,17 @@ namespace Game
|
|||||||
void SetInactive(FactionState faction, bool inactive)
|
void SetInactive(FactionState faction, bool inactive)
|
||||||
{
|
{
|
||||||
// always invisible or hidden faction can't be 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;
|
return;
|
||||||
|
|
||||||
// already set
|
// already set
|
||||||
if (((faction.Flags & FactionFlags.Inactive) != 0) == inactive)
|
if (faction.Flags.HasFlag(ReputationFlags.Inactive) == inactive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (inactive)
|
if (inactive)
|
||||||
faction.Flags |= FactionFlags.Inactive;
|
faction.Flags |= ReputationFlags.Inactive;
|
||||||
else
|
else
|
||||||
faction.Flags &= ~FactionFlags.Inactive;
|
faction.Flags &= ~ReputationFlags.Inactive;
|
||||||
|
|
||||||
faction.needSend = true;
|
faction.needSend = true;
|
||||||
faction.needSave = true;
|
faction.needSave = true;
|
||||||
@@ -549,20 +551,20 @@ namespace Game
|
|||||||
UpdateRankCounters(old_rank, new_rank);
|
UpdateRankCounters(old_rank, new_rank);
|
||||||
}
|
}
|
||||||
|
|
||||||
FactionFlags dbFactionFlags = (FactionFlags)result.Read<uint>(2);
|
ReputationFlags dbFactionFlags = (ReputationFlags)result.Read<uint>(2);
|
||||||
|
|
||||||
if (Convert.ToBoolean(dbFactionFlags & FactionFlags.Visible))
|
if (dbFactionFlags.HasFlag(ReputationFlags.Visible))
|
||||||
SetVisible(faction); // have internal checks for forced invisibility
|
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
|
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
|
SetAtWar(faction, true); // have internal checks for FACTION_FLAG_PEACE_FORCED
|
||||||
else // DB not at war
|
else // DB not at war
|
||||||
{
|
{
|
||||||
// allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN)
|
// 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
|
SetAtWar(faction, false); // have internal checks for FACTION_FLAG_PEACE_FORCED
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -730,7 +732,7 @@ namespace Game
|
|||||||
public uint Id;
|
public uint Id;
|
||||||
public uint ReputationListID;
|
public uint ReputationListID;
|
||||||
public int Standing;
|
public int Standing;
|
||||||
public FactionFlags Flags;
|
public ReputationFlags Flags;
|
||||||
public bool needSend;
|
public bool needSend;
|
||||||
public bool needSave;
|
public bool needSave;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user