mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Reputation: Named all reputation flags
This commit is contained in:
@@ -8362,7 +8362,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
|
||||
if (!(player->GetReputationMgr().GetForcedRankIfAny(factionTemplate)))
|
||||
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->Faction))
|
||||
if (FactionState const* repState = player->GetReputationMgr().GetState(factionEntry))
|
||||
if (!(repState->Flags & FACTION_FLAG_AT_WAR))
|
||||
if (!repState->Flags.HasFlag(ReputationFlags::AtWar))
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ bool ReputationMgr::IsAtWar(FactionEntry const* factionEntry) const
|
||||
return false;
|
||||
|
||||
if (FactionState const* factionState = GetState(factionEntry))
|
||||
return (factionState->Flags & FACTION_FLAG_AT_WAR) != 0;
|
||||
return factionState->Flags.HasFlag(ReputationFlags::AtWar);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -199,13 +199,13 @@ void ReputationMgr::ApplyForceReaction(uint32 faction_id, ReputationRank rank, b
|
||||
_forcedReactions.erase(faction_id);
|
||||
}
|
||||
|
||||
uint32 ReputationMgr::GetDefaultStateFlags(FactionEntry const* factionEntry) const
|
||||
ReputationFlags ReputationMgr::GetDefaultStateFlags(FactionEntry const* factionEntry) const
|
||||
{
|
||||
int32 dataIndex = GetFactionDataIndexForRaceAndClass(factionEntry);
|
||||
if (dataIndex < 0)
|
||||
return 0;
|
||||
return ReputationFlags::None;
|
||||
|
||||
return factionEntry->ReputationFlags[dataIndex];
|
||||
return static_cast<ReputationFlags>(factionEntry->ReputationFlags[dataIndex]);
|
||||
}
|
||||
|
||||
void ReputationMgr::SendForceReactions()
|
||||
@@ -255,7 +255,7 @@ void ReputationMgr::SendInitialReputations()
|
||||
|
||||
for (FactionStateList::iterator itr = _factions.begin(); itr != _factions.end(); ++itr)
|
||||
{
|
||||
initFactions.FactionFlags[itr->first] = itr->second.Flags;
|
||||
initFactions.FactionFlags[itr->first] = itr->second.Flags.AsUnderlyingType();
|
||||
initFactions.FactionStandings[itr->first] = itr->second.Standing;
|
||||
/// @todo faction bonus
|
||||
itr->second.needSend = false;
|
||||
@@ -296,7 +296,7 @@ void ReputationMgr::Initialize()
|
||||
newFaction.needSend = true;
|
||||
newFaction.needSave = true;
|
||||
|
||||
if (newFaction.Flags & FACTION_FLAG_VISIBLE)
|
||||
if (newFaction.Flags.HasFlag(ReputationFlags::Visible))
|
||||
++_visibleFactionCount;
|
||||
|
||||
if (!factionEntry->FriendshipRepID)
|
||||
@@ -342,7 +342,7 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
|
||||
{
|
||||
FactionStateList::iterator parentState = _factions.find(parent->ReputationIndex);
|
||||
// some team factions have own reputation standing, in this case do not spill to other sub-factions
|
||||
if (parentState != _factions.end() && (parentState->second.Flags & FACTION_FLAG_SPECIAL))
|
||||
if (parentState != _factions.end() && parentState->second.Flags.HasFlag(ReputationFlags::HeaderShowsBar))
|
||||
{
|
||||
SetOneFactionReputation(parent, int32(spillOverRepOut), incremental);
|
||||
}
|
||||
@@ -462,15 +462,17 @@ void ReputationMgr::SetVisible(FactionEntry const* factionEntry)
|
||||
void ReputationMgr::SetVisible(FactionState* faction)
|
||||
{
|
||||
// always invisible or hidden faction can't be make visible
|
||||
// except if faction has FACTION_FLAG_SPECIAL
|
||||
if (faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN) && !(faction->Flags & FACTION_FLAG_SPECIAL))
|
||||
if (faction->Flags.HasFlag(ReputationFlags::Hidden))
|
||||
return;
|
||||
|
||||
if (faction->Flags.HasFlag(ReputationFlags::Header) && !faction->Flags.HasFlag(ReputationFlags::HeaderShowsBar))
|
||||
return;
|
||||
|
||||
// already set
|
||||
if (faction->Flags & FACTION_FLAG_VISIBLE)
|
||||
if (faction->Flags.HasFlag(ReputationFlags::Visible))
|
||||
return;
|
||||
|
||||
faction->Flags |= FACTION_FLAG_VISIBLE;
|
||||
faction->Flags |= ReputationFlags::Visible;
|
||||
faction->needSend = true;
|
||||
faction->needSave = true;
|
||||
|
||||
@@ -486,7 +488,7 @@ void ReputationMgr::SetAtWar(RepListID repListID, bool on)
|
||||
return;
|
||||
|
||||
// always invisible or hidden faction can't change war state
|
||||
if (itr->second.Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN))
|
||||
if (itr->second.Flags.HasFlag(ReputationFlags::Hidden | ReputationFlags::Header))
|
||||
return;
|
||||
|
||||
SetAtWar(&itr->second, on);
|
||||
@@ -495,17 +497,17 @@ void ReputationMgr::SetAtWar(RepListID repListID, bool on)
|
||||
void ReputationMgr::SetAtWar(FactionState* faction, bool atWar) const
|
||||
{
|
||||
// Do not allow to declare war to our own faction. But allow for rival factions (eg Aldor vs Scryer).
|
||||
if (atWar && (faction->Flags & FACTION_FLAG_PEACE_FORCED) && !(faction->Flags & FACTION_FLAG_RIVAL))
|
||||
if (atWar && faction->Flags.HasFlag(ReputationFlags::Peaceful))
|
||||
return;
|
||||
|
||||
// already set
|
||||
if (((faction->Flags & FACTION_FLAG_AT_WAR) != 0) == atWar)
|
||||
if (faction->Flags.HasFlag(ReputationFlags::AtWar) == atWar)
|
||||
return;
|
||||
|
||||
if (atWar)
|
||||
faction->Flags |= FACTION_FLAG_AT_WAR;
|
||||
faction->Flags |= ReputationFlags::AtWar;
|
||||
else
|
||||
faction->Flags &= ~FACTION_FLAG_AT_WAR;
|
||||
faction->Flags &= ~ReputationFlags::AtWar;
|
||||
|
||||
faction->needSend = true;
|
||||
faction->needSave = true;
|
||||
@@ -523,17 +525,17 @@ void ReputationMgr::SetInactive(RepListID repListID, bool on)
|
||||
void ReputationMgr::SetInactive(FactionState* faction, bool inactive) const
|
||||
{
|
||||
// always invisible or hidden faction can't be inactive
|
||||
if (inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE)))
|
||||
if (faction->Flags.HasFlag(ReputationFlags::Hidden | ReputationFlags::Header) || !faction->Flags.HasFlag(ReputationFlags::Visible))
|
||||
return;
|
||||
|
||||
// already set
|
||||
if (((faction->Flags & FACTION_FLAG_INACTIVE) != 0) == inactive)
|
||||
if (faction->Flags.HasFlag(ReputationFlags::Inactive) == inactive)
|
||||
return;
|
||||
|
||||
if (inactive)
|
||||
faction->Flags |= FACTION_FLAG_INACTIVE;
|
||||
faction->Flags |= ReputationFlags::Inactive;
|
||||
else
|
||||
faction->Flags &= ~FACTION_FLAG_INACTIVE;
|
||||
faction->Flags &= ~ReputationFlags::Inactive;
|
||||
|
||||
faction->needSend = true;
|
||||
faction->needSave = true;
|
||||
@@ -569,21 +571,21 @@ void ReputationMgr::LoadFromDB(PreparedQueryResult result)
|
||||
UpdateRankCounters(old_rank, new_rank);
|
||||
}
|
||||
|
||||
uint32 dbFactionFlags = fields[2].GetUInt16();
|
||||
EnumFlag<ReputationFlags> dbFactionFlags = static_cast<ReputationFlags>(fields[2].GetUInt16());
|
||||
|
||||
if (dbFactionFlags & FACTION_FLAG_VISIBLE)
|
||||
SetVisible(faction); // have internal checks for forced invisibility
|
||||
if (dbFactionFlags.HasFlag(ReputationFlags::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.HasFlag(ReputationFlags::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
|
||||
if (dbFactionFlags.HasFlag(ReputationFlags::AtWar)) // DB at war
|
||||
SetAtWar(faction, true); // have internal checks for ReputationFlags::Peaceful
|
||||
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
|
||||
if (faction->Flags.HasFlag(ReputationFlags::Visible))
|
||||
SetAtWar(faction, false); // have internal checks for ReputationFlags::Peaceful
|
||||
}
|
||||
|
||||
// set atWar for hostile
|
||||
@@ -617,7 +619,7 @@ void ReputationMgr::SaveToDB(CharacterDatabaseTransaction& trans)
|
||||
stmt->setUInt64(0, _player->GetGUID().GetCounter());
|
||||
stmt->setUInt16(1, uint16(itr->second.ID));
|
||||
stmt->setInt32(2, itr->second.Standing);
|
||||
stmt->setUInt16(3, uint16(itr->second.Flags));
|
||||
stmt->setUInt16(3, itr->second.Flags.AsUnderlyingType());
|
||||
trans->Append(stmt);
|
||||
|
||||
itr->second.needSave = false;
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
#define __TRINITY_REPUTATION_MGR_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "EnumFlag.h"
|
||||
#include "Language.h"
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include "SharedDefines.h"
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
@@ -34,26 +35,31 @@ static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK] =
|
||||
LANG_REP_FRIENDLY, LANG_REP_HONORED, LANG_REP_REVERED, LANG_REP_EXALTED
|
||||
};
|
||||
|
||||
enum FactionFlags
|
||||
enum class ReputationFlags : uint16
|
||||
{
|
||||
FACTION_FLAG_NONE = 0x00, // no faction flag
|
||||
FACTION_FLAG_VISIBLE = 0x01, // makes visible in client (set or can be set at interaction with target of this faction)
|
||||
FACTION_FLAG_AT_WAR = 0x02, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation
|
||||
FACTION_FLAG_HIDDEN = 0x04, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client)
|
||||
FACTION_FLAG_INVISIBLE_FORCED = 0x08, // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions
|
||||
FACTION_FLAG_PEACE_FORCED = 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions
|
||||
FACTION_FLAG_INACTIVE = 0x20, // player controlled, state stored in characters.data (CMSG_SET_FACTION_INACTIVE)
|
||||
FACTION_FLAG_RIVAL = 0x40, // flag for the two competing outland factions
|
||||
FACTION_FLAG_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
|
||||
};
|
||||
|
||||
DEFINE_ENUM_FLAG(ReputationFlags);
|
||||
|
||||
typedef uint32 RepListID;
|
||||
struct FactionState
|
||||
{
|
||||
uint32 ID;
|
||||
RepListID ReputationListID;
|
||||
int32 Standing;
|
||||
uint8 Flags;
|
||||
int32 Standing;
|
||||
EnumFlag<ReputationFlags> Flags = ReputationFlags::None;
|
||||
bool needSend;
|
||||
bool needSave;
|
||||
};
|
||||
@@ -142,7 +148,7 @@ class TC_GAME_API ReputationMgr
|
||||
|
||||
private: // internal helper functions
|
||||
void Initialize();
|
||||
uint32 GetDefaultStateFlags(FactionEntry const* factionEntry) const;
|
||||
ReputationFlags GetDefaultStateFlags(FactionEntry const* factionEntry) const;
|
||||
bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool spillOverOnly, bool noSpillover);
|
||||
void SetVisible(FactionState* faction);
|
||||
void SetAtWar(FactionState* faction, bool atWar) const;
|
||||
|
||||
@@ -657,17 +657,17 @@ public:
|
||||
|
||||
ss << ' ' << rankName << " (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
|
||||
|
||||
if (faction.Flags & FACTION_FLAG_VISIBLE)
|
||||
if (faction.Flags.HasFlag(ReputationFlags::Visible))
|
||||
ss << handler->GetTrinityString(LANG_FACTION_VISIBLE);
|
||||
if (faction.Flags & FACTION_FLAG_AT_WAR)
|
||||
if (faction.Flags.HasFlag(ReputationFlags::AtWar))
|
||||
ss << handler->GetTrinityString(LANG_FACTION_ATWAR);
|
||||
if (faction.Flags & FACTION_FLAG_PEACE_FORCED)
|
||||
if (faction.Flags.HasFlag(ReputationFlags::Peaceful))
|
||||
ss << handler->GetTrinityString(LANG_FACTION_PEACE_FORCED);
|
||||
if (faction.Flags & FACTION_FLAG_HIDDEN)
|
||||
if (faction.Flags.HasFlag(ReputationFlags::Hidden))
|
||||
ss << handler->GetTrinityString(LANG_FACTION_HIDDEN);
|
||||
if (faction.Flags & FACTION_FLAG_INVISIBLE_FORCED)
|
||||
if (faction.Flags.HasFlag(ReputationFlags::Header))
|
||||
ss << handler->GetTrinityString(LANG_FACTION_INVISIBLE_FORCED);
|
||||
if (faction.Flags & FACTION_FLAG_INACTIVE)
|
||||
if (faction.Flags.HasFlag(ReputationFlags::Inactive))
|
||||
ss << handler->GetTrinityString(LANG_FACTION_INACTIVE);
|
||||
|
||||
handler->SendSysMessage(ss.str().c_str());
|
||||
|
||||
@@ -364,17 +364,17 @@ public:
|
||||
|
||||
ss << ' ' << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
|
||||
|
||||
if (factionState->Flags & FACTION_FLAG_VISIBLE)
|
||||
if (factionState->Flags.HasFlag(ReputationFlags::Visible))
|
||||
ss << handler->GetTrinityString(LANG_FACTION_VISIBLE);
|
||||
if (factionState->Flags & FACTION_FLAG_AT_WAR)
|
||||
if (factionState->Flags.HasFlag(ReputationFlags::AtWar))
|
||||
ss << handler->GetTrinityString(LANG_FACTION_ATWAR);
|
||||
if (factionState->Flags & FACTION_FLAG_PEACE_FORCED)
|
||||
if (factionState->Flags.HasFlag(ReputationFlags::Peaceful))
|
||||
ss << handler->GetTrinityString(LANG_FACTION_PEACE_FORCED);
|
||||
if (factionState->Flags & FACTION_FLAG_HIDDEN)
|
||||
if (factionState->Flags.HasFlag(ReputationFlags::Hidden))
|
||||
ss << handler->GetTrinityString(LANG_FACTION_HIDDEN);
|
||||
if (factionState->Flags & FACTION_FLAG_INVISIBLE_FORCED)
|
||||
if (factionState->Flags.HasFlag(ReputationFlags::Header))
|
||||
ss << handler->GetTrinityString(LANG_FACTION_INVISIBLE_FORCED);
|
||||
if (factionState->Flags & FACTION_FLAG_INACTIVE)
|
||||
if (factionState->Flags.HasFlag(ReputationFlags::Inactive))
|
||||
ss << handler->GetTrinityString(LANG_FACTION_INACTIVE);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user