mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 11:25:42 +00:00
refactor(Core/Game): restyle game lib with astyle (#3466)
This commit is contained in:
@@ -19,7 +19,7 @@ const int32 ReputationMgr::PointsInRank[MAX_REPUTATION_RANK] = {36000, 3000, 300
|
||||
ReputationRank ReputationMgr::ReputationToRank(int32 standing)
|
||||
{
|
||||
int32 limit = Reputation_Cap + 1;
|
||||
for (int i = MAX_REPUTATION_RANK-1; i >= MIN_REPUTATION_RANK; --i)
|
||||
for (int i = MAX_REPUTATION_RANK - 1; i >= MIN_REPUTATION_RANK; --i)
|
||||
{
|
||||
limit -= PointsInRank[i];
|
||||
if (standing >= limit)
|
||||
@@ -71,13 +71,13 @@ int32 ReputationMgr::GetBaseReputation(FactionEntry const* factionEntry) const
|
||||
|
||||
uint32 raceMask = _player->getRaceMask();
|
||||
uint32 classMask = _player->getClassMask();
|
||||
for (int i=0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if ((factionEntry->BaseRepRaceMask[i] & raceMask ||
|
||||
(factionEntry->BaseRepRaceMask[i] == 0 &&
|
||||
factionEntry->BaseRepClassMask[i] != 0)) &&
|
||||
(factionEntry->BaseRepClassMask[i] & classMask ||
|
||||
factionEntry->BaseRepClassMask[i] == 0))
|
||||
(factionEntry->BaseRepRaceMask[i] == 0 &&
|
||||
factionEntry->BaseRepClassMask[i] != 0)) &&
|
||||
(factionEntry->BaseRepClassMask[i] & classMask ||
|
||||
factionEntry->BaseRepClassMask[i] == 0))
|
||||
|
||||
return factionEntry->BaseRepValue[i];
|
||||
}
|
||||
@@ -125,13 +125,13 @@ uint32 ReputationMgr::GetDefaultStateFlags(FactionEntry const* factionEntry) con
|
||||
|
||||
uint32 raceMask = _player->getRaceMask();
|
||||
uint32 classMask = _player->getClassMask();
|
||||
for (int i=0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if ((factionEntry->BaseRepRaceMask[i] & raceMask ||
|
||||
(factionEntry->BaseRepRaceMask[i] == 0 &&
|
||||
factionEntry->BaseRepClassMask[i] != 0)) &&
|
||||
(factionEntry->BaseRepClassMask[i] & classMask ||
|
||||
factionEntry->BaseRepClassMask[i] == 0))
|
||||
(factionEntry->BaseRepRaceMask[i] == 0 &&
|
||||
factionEntry->BaseRepClassMask[i] != 0)) &&
|
||||
(factionEntry->BaseRepClassMask[i] & classMask ||
|
||||
factionEntry->BaseRepClassMask[i] == 0))
|
||||
|
||||
return factionEntry->ReputationFlags[i];
|
||||
}
|
||||
@@ -141,7 +141,7 @@ uint32 ReputationMgr::GetDefaultStateFlags(FactionEntry const* factionEntry) con
|
||||
void ReputationMgr::SendForceReactions()
|
||||
{
|
||||
WorldPacket data;
|
||||
data.Initialize(SMSG_SET_FORCED_REACTIONS, 4+_forcedReactions.size()*(4+4));
|
||||
data.Initialize(SMSG_SET_FORCED_REACTIONS, 4 + _forcedReactions.size() * (4 + 4));
|
||||
data << uint32(_forcedReactions.size());
|
||||
for (ForcedReactions::const_iterator itr = _forcedReactions.begin(); itr != _forcedReactions.end(); ++itr)
|
||||
{
|
||||
@@ -186,7 +186,7 @@ void ReputationMgr::SendState(FactionState const* faction)
|
||||
|
||||
void ReputationMgr::SendInitialReputations()
|
||||
{
|
||||
WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4+128*5));
|
||||
WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4 + 128 * 5));
|
||||
data << uint32 (0x00000080);
|
||||
|
||||
RepListID a = 0;
|
||||
@@ -394,7 +394,7 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in
|
||||
return false;
|
||||
}
|
||||
|
||||
void ReputationMgr::SetVisible(FactionTemplateEntry const*factionTemplateEntry)
|
||||
void ReputationMgr::SetVisible(FactionTemplateEntry const* factionTemplateEntry)
|
||||
{
|
||||
if (!factionTemplateEntry->faction)
|
||||
return;
|
||||
@@ -421,7 +421,7 @@ 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 & (FACTION_FLAG_INVISIBLE_FORCED | FACTION_FLAG_HIDDEN) && !(faction->Flags & FACTION_FLAG_SPECIAL))
|
||||
return;
|
||||
|
||||
// already set
|
||||
@@ -444,7 +444,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 & (FACTION_FLAG_INVISIBLE_FORCED | FACTION_FLAG_HIDDEN))
|
||||
return;
|
||||
|
||||
SetAtWar(&itr->second, on);
|
||||
@@ -481,7 +481,7 @@ 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 (inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED | FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE)))
|
||||
return;
|
||||
|
||||
// already set
|
||||
@@ -555,8 +555,7 @@ void ReputationMgr::LoadFromDB(PreparedQueryResult result)
|
||||
faction->needSave = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (result->NextRow());
|
||||
} while (result->NextRow());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,102 +51,102 @@ class Player;
|
||||
|
||||
class ReputationMgr
|
||||
{
|
||||
public: // constructors and global modifiers
|
||||
explicit ReputationMgr(Player* owner) : _player(owner),
|
||||
_visibleFactionCount(0), _honoredFactionCount(0), _reveredFactionCount(0), _exaltedFactionCount(0), _sendFactionIncreased(false) {}
|
||||
~ReputationMgr() {}
|
||||
public: // constructors and global modifiers
|
||||
explicit ReputationMgr(Player* owner) : _player(owner),
|
||||
_visibleFactionCount(0), _honoredFactionCount(0), _reveredFactionCount(0), _exaltedFactionCount(0), _sendFactionIncreased(false) {}
|
||||
~ReputationMgr() {}
|
||||
|
||||
void SaveToDB(SQLTransaction& trans);
|
||||
void LoadFromDB(PreparedQueryResult result);
|
||||
public: // statics
|
||||
static const int32 PointsInRank[MAX_REPUTATION_RANK];
|
||||
static const int32 Reputation_Cap = 42999;
|
||||
static const int32 Reputation_Bottom = -42000;
|
||||
void SaveToDB(SQLTransaction& trans);
|
||||
void LoadFromDB(PreparedQueryResult result);
|
||||
public: // statics
|
||||
static const int32 PointsInRank[MAX_REPUTATION_RANK];
|
||||
static const int32 Reputation_Cap = 42999;
|
||||
static const int32 Reputation_Bottom = -42000;
|
||||
|
||||
static ReputationRank ReputationToRank(int32 standing);
|
||||
public: // accessors
|
||||
uint8 GetVisibleFactionCount() const { return _visibleFactionCount; }
|
||||
uint8 GetHonoredFactionCount() const { return _honoredFactionCount; }
|
||||
uint8 GetReveredFactionCount() const { return _reveredFactionCount; }
|
||||
uint8 GetExaltedFactionCount() const { return _exaltedFactionCount; }
|
||||
static ReputationRank ReputationToRank(int32 standing);
|
||||
public: // accessors
|
||||
uint8 GetVisibleFactionCount() const { return _visibleFactionCount; }
|
||||
uint8 GetHonoredFactionCount() const { return _honoredFactionCount; }
|
||||
uint8 GetReveredFactionCount() const { return _reveredFactionCount; }
|
||||
uint8 GetExaltedFactionCount() const { return _exaltedFactionCount; }
|
||||
|
||||
FactionStateList const& GetStateList() const { return _factions; }
|
||||
FactionStateList const& GetStateList() const { return _factions; }
|
||||
|
||||
FactionState const* GetState(FactionEntry const* factionEntry) const
|
||||
{
|
||||
return factionEntry->CanHaveReputation() ? GetState(factionEntry->reputationListID) : nullptr;
|
||||
}
|
||||
FactionState const* GetState(FactionEntry const* factionEntry) const
|
||||
{
|
||||
return factionEntry->CanHaveReputation() ? GetState(factionEntry->reputationListID) : nullptr;
|
||||
}
|
||||
|
||||
FactionState const* GetState(RepListID id) const
|
||||
{
|
||||
FactionStateList::const_iterator repItr = _factions.find (id);
|
||||
return repItr != _factions.end() ? &repItr->second : nullptr;
|
||||
}
|
||||
FactionState const* GetState(RepListID id) const
|
||||
{
|
||||
FactionStateList::const_iterator repItr = _factions.find (id);
|
||||
return repItr != _factions.end() ? &repItr->second : nullptr;
|
||||
}
|
||||
|
||||
bool IsAtWar(uint32 faction_id) const;
|
||||
bool IsAtWar(FactionEntry const* factionEntry) const;
|
||||
bool IsAtWar(uint32 faction_id) const;
|
||||
bool IsAtWar(FactionEntry const* factionEntry) const;
|
||||
|
||||
int32 GetReputation(uint32 faction_id) const;
|
||||
int32 GetReputation(FactionEntry const* factionEntry) const;
|
||||
int32 GetBaseReputation(FactionEntry const* factionEntry) const;
|
||||
int32 GetReputation(uint32 faction_id) const;
|
||||
int32 GetReputation(FactionEntry const* factionEntry) const;
|
||||
int32 GetBaseReputation(FactionEntry const* factionEntry) const;
|
||||
|
||||
ReputationRank GetRank(FactionEntry const* factionEntry) const;
|
||||
ReputationRank GetBaseRank(FactionEntry const* factionEntry) const;
|
||||
uint32 GetReputationRankStrIndex(FactionEntry const* factionEntry) const
|
||||
{
|
||||
return ReputationRankStrIndex[GetRank(factionEntry)];
|
||||
};
|
||||
ReputationRank GetRank(FactionEntry const* factionEntry) const;
|
||||
ReputationRank GetBaseRank(FactionEntry const* factionEntry) const;
|
||||
uint32 GetReputationRankStrIndex(FactionEntry const* factionEntry) const
|
||||
{
|
||||
return ReputationRankStrIndex[GetRank(factionEntry)];
|
||||
};
|
||||
|
||||
ReputationRank const* GetForcedRankIfAny(FactionTemplateEntry const* factionTemplateEntry) const
|
||||
{
|
||||
ForcedReactions::const_iterator forceItr = _forcedReactions.find(factionTemplateEntry->faction);
|
||||
return forceItr != _forcedReactions.end() ? &forceItr->second : nullptr;
|
||||
}
|
||||
ReputationRank const* GetForcedRankIfAny(FactionTemplateEntry const* factionTemplateEntry) const
|
||||
{
|
||||
ForcedReactions::const_iterator forceItr = _forcedReactions.find(factionTemplateEntry->faction);
|
||||
return forceItr != _forcedReactions.end() ? &forceItr->second : nullptr;
|
||||
}
|
||||
|
||||
public: // modifiers
|
||||
bool SetReputation(FactionEntry const* factionEntry, int32 standing)
|
||||
{
|
||||
return SetReputation(factionEntry, standing, false, false);
|
||||
}
|
||||
bool ModifyReputation(FactionEntry const* factionEntry, int32 standing, bool spillOverOnly = false)
|
||||
{
|
||||
return SetReputation(factionEntry, standing, true, spillOverOnly);
|
||||
}
|
||||
public: // modifiers
|
||||
bool SetReputation(FactionEntry const* factionEntry, int32 standing)
|
||||
{
|
||||
return SetReputation(factionEntry, standing, false, false);
|
||||
}
|
||||
bool ModifyReputation(FactionEntry const* factionEntry, int32 standing, bool spillOverOnly = false)
|
||||
{
|
||||
return SetReputation(factionEntry, standing, true, spillOverOnly);
|
||||
}
|
||||
|
||||
void SetVisible(FactionTemplateEntry const* factionTemplateEntry);
|
||||
void SetVisible(FactionEntry const* factionEntry);
|
||||
void SetAtWar(RepListID repListID, bool on);
|
||||
void SetInactive(RepListID repListID, bool on);
|
||||
void SetVisible(FactionTemplateEntry const* factionTemplateEntry);
|
||||
void SetVisible(FactionEntry const* factionEntry);
|
||||
void SetAtWar(RepListID repListID, bool on);
|
||||
void SetInactive(RepListID repListID, bool on);
|
||||
|
||||
void ApplyForceReaction(uint32 faction_id, ReputationRank rank, bool apply);
|
||||
void ApplyForceReaction(uint32 faction_id, ReputationRank rank, bool apply);
|
||||
|
||||
//! Public for chat command needs
|
||||
bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing, bool incremental);
|
||||
//! Public for chat command needs
|
||||
bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing, bool incremental);
|
||||
|
||||
public: // senders
|
||||
void SendInitialReputations();
|
||||
void SendForceReactions();
|
||||
void SendState(FactionState const* faction);
|
||||
void SendStates();
|
||||
public: // senders
|
||||
void SendInitialReputations();
|
||||
void SendForceReactions();
|
||||
void SendState(FactionState const* faction);
|
||||
void SendStates();
|
||||
|
||||
private: // internal helper functions
|
||||
void Initialize();
|
||||
uint32 GetDefaultStateFlags(FactionEntry const* factionEntry) const;
|
||||
bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool spillOverOnly);
|
||||
void SetVisible(FactionState* faction);
|
||||
void SetAtWar(FactionState* faction, bool atWar) const;
|
||||
void SetInactive(FactionState* faction, bool inactive) const;
|
||||
void SendVisible(FactionState const* faction) const;
|
||||
void UpdateRankCounters(ReputationRank old_rank, ReputationRank new_rank);
|
||||
private:
|
||||
Player* _player;
|
||||
FactionStateList _factions;
|
||||
ForcedReactions _forcedReactions;
|
||||
uint8 _visibleFactionCount :8;
|
||||
uint8 _honoredFactionCount :8;
|
||||
uint8 _reveredFactionCount :8;
|
||||
uint8 _exaltedFactionCount :8;
|
||||
bool _sendFactionIncreased; //! Play visual effect on next SMSG_SET_FACTION_STANDING sent
|
||||
private: // internal helper functions
|
||||
void Initialize();
|
||||
uint32 GetDefaultStateFlags(FactionEntry const* factionEntry) const;
|
||||
bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool spillOverOnly);
|
||||
void SetVisible(FactionState* faction);
|
||||
void SetAtWar(FactionState* faction, bool atWar) const;
|
||||
void SetInactive(FactionState* faction, bool inactive) const;
|
||||
void SendVisible(FactionState const* faction) const;
|
||||
void UpdateRankCounters(ReputationRank old_rank, ReputationRank new_rank);
|
||||
private:
|
||||
Player* _player;
|
||||
FactionStateList _factions;
|
||||
ForcedReactions _forcedReactions;
|
||||
uint8 _visibleFactionCount : 8;
|
||||
uint8 _honoredFactionCount : 8;
|
||||
uint8 _reveredFactionCount : 8;
|
||||
uint8 _exaltedFactionCount : 8;
|
||||
bool _sendFactionIncreased; //! Play visual effect on next SMSG_SET_FACTION_STANDING sent
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user