mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 00:18:43 +01:00
Codestyle: Renamed some variables to fit codestyle, corrected order in structure/class fields to match alignment (they use slightly less memory now)
Signed-off-by: Subv <s.v.h21@hotmail.com>
This commit is contained in:
@@ -45,7 +45,7 @@ bool ReputationMgr::IsAtWar(uint32 faction_id) const
|
||||
|
||||
if (!factionEntry)
|
||||
{
|
||||
sLog->outError("ReputationMgr::IsAtWar: Can't get AtWar flag of %s for unknown faction (faction id) #%u.", m_player->GetName(), faction_id);
|
||||
sLog->outError("ReputationMgr::IsAtWar: Can't get AtWar flag of %s for unknown faction (faction id) #%u.", _player->GetName(), faction_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ int32 ReputationMgr::GetReputation(uint32 faction_id) const
|
||||
|
||||
if (!factionEntry)
|
||||
{
|
||||
sLog->outError("ReputationMgr::GetReputation: Can't get reputation of %s for unknown faction (faction id) #%u.", m_player->GetName(), faction_id);
|
||||
sLog->outError("ReputationMgr::GetReputation: Can't get reputation of %s for unknown faction (faction id) #%u.", _player->GetName(), faction_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ int32 ReputationMgr::GetBaseReputation(FactionEntry const* factionEntry) const
|
||||
if (!factionEntry)
|
||||
return 0;
|
||||
|
||||
uint32 raceMask = m_player->getRaceMask();
|
||||
uint32 classMask = m_player->getClassMask();
|
||||
uint32 raceMask = _player->getRaceMask();
|
||||
uint32 classMask = _player->getClassMask();
|
||||
for (int i=0; i < 4; i++)
|
||||
{
|
||||
if ((factionEntry->BaseRepRaceMask[i] & raceMask ||
|
||||
@@ -124,9 +124,9 @@ ReputationRank ReputationMgr::GetBaseRank(FactionEntry const* factionEntry) cons
|
||||
void ReputationMgr::ApplyForceReaction(uint32 faction_id, ReputationRank rank, bool apply)
|
||||
{
|
||||
if (apply)
|
||||
m_forcedReactions[faction_id] = rank;
|
||||
_forcedReactions[faction_id] = rank;
|
||||
else
|
||||
m_forcedReactions.erase(faction_id);
|
||||
_forcedReactions.erase(faction_id);
|
||||
}
|
||||
|
||||
uint32 ReputationMgr::GetDefaultStateFlags(FactionEntry const* factionEntry) const
|
||||
@@ -134,8 +134,8 @@ uint32 ReputationMgr::GetDefaultStateFlags(FactionEntry const* factionEntry) con
|
||||
if (!factionEntry)
|
||||
return 0;
|
||||
|
||||
uint32 raceMask = m_player->getRaceMask();
|
||||
uint32 classMask = m_player->getClassMask();
|
||||
uint32 raceMask = _player->getRaceMask();
|
||||
uint32 classMask = _player->getClassMask();
|
||||
for (int i=0; i < 4; i++)
|
||||
{
|
||||
if ((factionEntry->BaseRepRaceMask[i] & raceMask ||
|
||||
@@ -152,14 +152,14 @@ uint32 ReputationMgr::GetDefaultStateFlags(FactionEntry const* factionEntry) con
|
||||
void ReputationMgr::SendForceReactions()
|
||||
{
|
||||
WorldPacket data;
|
||||
data.Initialize(SMSG_SET_FORCED_REACTIONS, 4+m_forcedReactions.size()*(4+4));
|
||||
data << uint32(m_forcedReactions.size());
|
||||
for (ForcedReactions::const_iterator itr = m_forcedReactions.begin(); itr != m_forcedReactions.end(); ++itr)
|
||||
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)
|
||||
{
|
||||
data << uint32(itr->first); // faction_id (Faction.dbc)
|
||||
data << uint32(itr->second); // reputation rank
|
||||
}
|
||||
m_player->SendDirectMessage(&data);
|
||||
_player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
void ReputationMgr::SendState(FactionState const* faction)
|
||||
@@ -176,7 +176,7 @@ void ReputationMgr::SendState(FactionState const* faction)
|
||||
data << (uint32) faction->ReputationListID;
|
||||
data << (uint32) faction->Standing;
|
||||
|
||||
for (FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
|
||||
for (FactionStateList::iterator itr = _factions.begin(); itr != _factions.end(); ++itr)
|
||||
{
|
||||
if (itr->second.needSend)
|
||||
{
|
||||
@@ -191,7 +191,7 @@ void ReputationMgr::SendState(FactionState const* faction)
|
||||
}
|
||||
|
||||
data.put<uint32>(p_count, count);
|
||||
m_player->SendDirectMessage(&data);
|
||||
_player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
void ReputationMgr::SendInitialReputations()
|
||||
@@ -201,7 +201,7 @@ void ReputationMgr::SendInitialReputations()
|
||||
|
||||
RepListID a = 0;
|
||||
|
||||
for (FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
|
||||
for (FactionStateList::iterator itr = _factions.begin(); itr != _factions.end(); ++itr)
|
||||
{
|
||||
// fill in absent fields
|
||||
for (; a != itr->first; a++)
|
||||
@@ -226,33 +226,33 @@ void ReputationMgr::SendInitialReputations()
|
||||
data << uint32 (0x00000000);
|
||||
}
|
||||
|
||||
m_player->SendDirectMessage(&data);
|
||||
_player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
void ReputationMgr::SendStates()
|
||||
{
|
||||
for (FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
|
||||
for (FactionStateList::iterator itr = _factions.begin(); itr != _factions.end(); ++itr)
|
||||
SendState(&(itr->second));
|
||||
}
|
||||
|
||||
void ReputationMgr::SendVisible(FactionState const* faction) const
|
||||
{
|
||||
if (m_player->GetSession()->PlayerLoading())
|
||||
if (_player->GetSession()->PlayerLoading())
|
||||
return;
|
||||
|
||||
// make faction visible in reputation list at client
|
||||
WorldPacket data(SMSG_SET_FACTION_VISIBLE, 4);
|
||||
data << faction->ReputationListID;
|
||||
m_player->SendDirectMessage(&data);
|
||||
_player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
void ReputationMgr::Initialize()
|
||||
{
|
||||
m_factions.clear();
|
||||
m_visibleFactionCount = 0;
|
||||
m_honoredFactionCount = 0;
|
||||
m_reveredFactionCount = 0;
|
||||
m_exaltedFactionCount = 0;
|
||||
_factions.clear();
|
||||
_visibleFactionCount = 0;
|
||||
_honoredFactionCount = 0;
|
||||
_reveredFactionCount = 0;
|
||||
_exaltedFactionCount = 0;
|
||||
|
||||
for (unsigned int i = 1; i < sFactionStore.GetNumRows(); i++)
|
||||
{
|
||||
@@ -269,18 +269,18 @@ void ReputationMgr::Initialize()
|
||||
newFaction.needSave = true;
|
||||
|
||||
if (newFaction.Flags & FACTION_FLAG_VISIBLE)
|
||||
++m_visibleFactionCount;
|
||||
++_visibleFactionCount;
|
||||
|
||||
UpdateRankCounters(REP_HOSTILE, GetBaseRank(factionEntry));
|
||||
|
||||
m_factions[newFaction.ReputationListID] = newFaction;
|
||||
_factions[newFaction.ReputationListID] = newFaction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
|
||||
{
|
||||
sScriptMgr->OnPlayerReputationChange(m_player, factionEntry->ID, standing, incremental);
|
||||
sScriptMgr->OnPlayerReputationChange(_player, factionEntry->ID, standing, incremental);
|
||||
bool res = false;
|
||||
// if spillover definition exists in DB, override DBC
|
||||
if (const RepSpilloverTemplate* repTemplate = sObjectMgr->GetRepSpilloverTemplate(factionEntry->ID))
|
||||
@@ -289,7 +289,7 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
|
||||
{
|
||||
if (repTemplate->faction[i])
|
||||
{
|
||||
if (m_player->GetReputationRank(repTemplate->faction[i]) <= ReputationRank(repTemplate->faction_rank[i]))
|
||||
if (_player->GetReputationRank(repTemplate->faction[i]) <= ReputationRank(repTemplate->faction_rank[i]))
|
||||
{
|
||||
// bonuses are already given, so just modify standing by rate
|
||||
int32 spilloverRep = int32(standing * repTemplate->faction_rate[i]);
|
||||
@@ -309,9 +309,9 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
|
||||
spillOverRepOut *= factionEntry->spilloverRateOut;
|
||||
if (FactionEntry const* parent = sFactionStore.LookupEntry(factionEntry->team))
|
||||
{
|
||||
FactionStateList::iterator parentState = m_factions.find(parent->reputationListID);
|
||||
FactionStateList::iterator parentState = _factions.find(parent->reputationListID);
|
||||
// some team factions have own reputation standing, in this case do not spill to other sub-factions
|
||||
if (parentState != m_factions.end() && (parentState->second.Flags & FACTION_FLAG_SPECIAL))
|
||||
if (parentState != _factions.end() && (parentState->second.Flags & FACTION_FLAG_SPECIAL))
|
||||
{
|
||||
SetOneFactionReputation(parent, int32(spillOverRepOut), incremental);
|
||||
}
|
||||
@@ -338,8 +338,8 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
|
||||
}
|
||||
}
|
||||
// spillover done, update faction itself
|
||||
FactionStateList::iterator faction = m_factions.find(factionEntry->reputationListID);
|
||||
if (faction != m_factions.end())
|
||||
FactionStateList::iterator faction = _factions.find(factionEntry->reputationListID);
|
||||
if (faction != _factions.end())
|
||||
{
|
||||
res = SetOneFactionReputation(factionEntry, standing, incremental);
|
||||
// only this faction gets reported to client, even if it has no own visible standing
|
||||
@@ -350,8 +350,8 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
|
||||
|
||||
bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
|
||||
{
|
||||
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
|
||||
if (itr != m_factions.end())
|
||||
FactionStateList::iterator itr = _factions.find(factionEntry->reputationListID);
|
||||
if (itr != _factions.end())
|
||||
{
|
||||
int32 BaseRep = GetBaseReputation(factionEntry);
|
||||
|
||||
@@ -381,12 +381,12 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in
|
||||
|
||||
UpdateRankCounters(old_rank, new_rank);
|
||||
|
||||
m_player->ReputationChanged(factionEntry);
|
||||
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS, factionEntry->ID);
|
||||
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, factionEntry->ID);
|
||||
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, factionEntry->ID);
|
||||
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION, factionEntry->ID);
|
||||
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION, factionEntry->ID);
|
||||
_player->ReputationChanged(factionEntry);
|
||||
_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS, factionEntry->ID);
|
||||
_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, factionEntry->ID);
|
||||
_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, factionEntry->ID);
|
||||
_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION, factionEntry->ID);
|
||||
_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION, factionEntry->ID);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -400,7 +400,7 @@ void ReputationMgr::SetVisible(FactionTemplateEntry const*factionTemplateEntry)
|
||||
|
||||
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction))
|
||||
// Never show factions of the opposing team
|
||||
if (!(factionEntry->BaseRepRaceMask[1] & m_player->getRaceMask() && factionEntry->BaseRepValue[1] == Reputation_Bottom))
|
||||
if (!(factionEntry->BaseRepRaceMask[1] & _player->getRaceMask() && factionEntry->BaseRepValue[1] == Reputation_Bottom))
|
||||
SetVisible(factionEntry);
|
||||
}
|
||||
|
||||
@@ -409,8 +409,8 @@ void ReputationMgr::SetVisible(FactionEntry const* factionEntry)
|
||||
if (factionEntry->reputationListID < 0)
|
||||
return;
|
||||
|
||||
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
|
||||
if (itr == m_factions.end())
|
||||
FactionStateList::iterator itr = _factions.find(factionEntry->reputationListID);
|
||||
if (itr == _factions.end())
|
||||
return;
|
||||
|
||||
SetVisible(&itr->second);
|
||||
@@ -431,15 +431,15 @@ void ReputationMgr::SetVisible(FactionState* faction)
|
||||
faction->needSend = true;
|
||||
faction->needSave = true;
|
||||
|
||||
++m_visibleFactionCount;
|
||||
++_visibleFactionCount;
|
||||
|
||||
SendVisible(faction);
|
||||
}
|
||||
|
||||
void ReputationMgr::SetAtWar(RepListID repListID, bool on)
|
||||
{
|
||||
FactionStateList::iterator itr = m_factions.find(repListID);
|
||||
if (itr == m_factions.end())
|
||||
FactionStateList::iterator itr = _factions.find(repListID);
|
||||
if (itr == _factions.end())
|
||||
return;
|
||||
|
||||
// always invisible or hidden faction can't change war state
|
||||
@@ -470,8 +470,8 @@ void ReputationMgr::SetAtWar(FactionState* faction, bool atWar) const
|
||||
|
||||
void ReputationMgr::SetInactive(RepListID repListID, bool on)
|
||||
{
|
||||
FactionStateList::iterator itr = m_factions.find(repListID);
|
||||
if (itr == m_factions.end())
|
||||
FactionStateList::iterator itr = _factions.find(repListID);
|
||||
if (itr == _factions.end())
|
||||
return;
|
||||
|
||||
SetInactive(&itr->second, on);
|
||||
@@ -512,7 +512,7 @@ void ReputationMgr::LoadFromDB(PreparedQueryResult result)
|
||||
FactionEntry const* factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt16());
|
||||
if (factionEntry && (factionEntry->reputationListID >= 0))
|
||||
{
|
||||
FactionState* faction = &m_factions[factionEntry->reputationListID];
|
||||
FactionState* faction = &_factions[factionEntry->reputationListID];
|
||||
|
||||
// update standing to current
|
||||
faction->Standing = int32(fields[1].GetUInt32());
|
||||
@@ -558,12 +558,12 @@ void ReputationMgr::LoadFromDB(PreparedQueryResult result)
|
||||
|
||||
void ReputationMgr::SaveToDB(SQLTransaction& trans)
|
||||
{
|
||||
for (FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
|
||||
for (FactionStateList::iterator itr = _factions.begin(); itr != _factions.end(); ++itr)
|
||||
{
|
||||
if (itr->second.needSave)
|
||||
{
|
||||
trans->PAppend("DELETE FROM character_reputation WHERE guid = '%u' AND faction='%u'", m_player->GetGUIDLow(), itr->second.ID);
|
||||
trans->PAppend("INSERT INTO character_reputation (guid, faction, standing, flags) VALUES ('%u', '%u', '%i', '%u')", m_player->GetGUIDLow(), itr->second.ID, itr->second.Standing, itr->second.Flags);
|
||||
trans->PAppend("DELETE FROM character_reputation WHERE guid = '%u' AND faction='%u'", _player->GetGUIDLow(), itr->second.ID);
|
||||
trans->PAppend("INSERT INTO character_reputation (guid, faction, standing, flags) VALUES ('%u', '%u', '%i', '%u')", _player->GetGUIDLow(), itr->second.ID, itr->second.Standing, itr->second.Flags);
|
||||
itr->second.needSave = false;
|
||||
}
|
||||
}
|
||||
@@ -572,16 +572,16 @@ void ReputationMgr::SaveToDB(SQLTransaction& trans)
|
||||
void ReputationMgr::UpdateRankCounters(ReputationRank old_rank, ReputationRank new_rank)
|
||||
{
|
||||
if (old_rank >= REP_EXALTED)
|
||||
--m_exaltedFactionCount;
|
||||
--_exaltedFactionCount;
|
||||
if (old_rank >= REP_REVERED)
|
||||
--m_reveredFactionCount;
|
||||
--_reveredFactionCount;
|
||||
if (old_rank >= REP_HONORED)
|
||||
--m_honoredFactionCount;
|
||||
--_honoredFactionCount;
|
||||
|
||||
if (new_rank >= REP_EXALTED)
|
||||
++m_exaltedFactionCount;
|
||||
++_exaltedFactionCount;
|
||||
if (new_rank >= REP_REVERED)
|
||||
++m_reveredFactionCount;
|
||||
++_reveredFactionCount;
|
||||
if (new_rank >= REP_HONORED)
|
||||
++m_honoredFactionCount;
|
||||
++_honoredFactionCount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user