Various Cleanups (game Q-R)

This commit is contained in:
Schmoozerd 2012-07-19 21:51:54 +02:00
parent 98e1efd435
commit 865f7d7428
10 changed files with 246 additions and 246 deletions

View file

@ -30,7 +30,7 @@ ReputationRank ReputationMgr::ReputationToRank(int32 standing)
for (int i = MAX_REPUTATION_RANK-1; i >= MIN_REPUTATION_RANK; --i)
{
limit -= PointsInRank[i];
if (standing >= limit )
if (standing >= limit)
return ReputationRank(i);
}
return MIN_REPUTATION_RANK;
@ -38,7 +38,7 @@ ReputationRank ReputationMgr::ReputationToRank(int32 standing)
int32 ReputationMgr::GetReputation(uint32 faction_id) const
{
FactionEntry const *factionEntry = sFactionStore.LookupEntry(faction_id);
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id);
if (!factionEntry)
{
@ -65,10 +65,10 @@ int32 ReputationMgr::GetBaseReputation(FactionEntry const* factionEntry) const
int32 ReputationMgr::GetReputation(FactionEntry const* factionEntry) const
{
// Faction without recorded reputation. Just ignore.
if(!factionEntry)
if (!factionEntry)
return 0;
if(FactionState const* state = GetState(factionEntry))
if (FactionState const* state = GetState(factionEntry))
return GetBaseReputation(factionEntry) + state->Standing;
return 0;
@ -86,9 +86,9 @@ ReputationRank ReputationMgr::GetBaseRank(FactionEntry const* factionEntry) cons
return ReputationToRank(reputation);
}
void ReputationMgr::ApplyForceReaction( uint32 faction_id,ReputationRank rank,bool apply )
void ReputationMgr::ApplyForceReaction(uint32 faction_id,ReputationRank rank,bool apply)
{
if(apply)
if (apply)
m_forcedReactions[faction_id] = rank;
else
m_forcedReactions.erase(faction_id);
@ -112,7 +112,7 @@ 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)
for (ForcedReactions::const_iterator itr = m_forcedReactions.begin(); itr != m_forcedReactions.end(); ++itr)
{
data << uint32(itr->first); // faction_id (Faction.dbc)
data << uint32(itr->second); // reputation rank
@ -134,7 +134,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 = m_factions.begin(); itr != m_factions.end(); ++itr)
{
if (itr->second.needSend)
{
@ -156,7 +156,7 @@ void ReputationMgr::SendState(FactionState const* faction)
void ReputationMgr::SendInitialReputations()
{
WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4+128*5));
data << uint32 (0x00000080);
data << uint32(0x00000080);
RepListID a = 0;
@ -165,13 +165,13 @@ void ReputationMgr::SendInitialReputations()
// fill in absent fields
for (; a != itr->first; a++)
{
data << uint8 (0x00);
data << uint32 (0x00000000);
data << uint8(0x00);
data << uint32(0x00000000);
}
// fill in encountered data
data << uint8 (itr->second.Flags);
data << uint32 (itr->second.Standing);
data << uint8(itr->second.Flags);
data << uint32(itr->second.Standing);
itr->second.needSend = false;
@ -181,8 +181,8 @@ void ReputationMgr::SendInitialReputations()
// fill in absent fields
for (; a != 128; a++)
{
data << uint8 (0x00);
data << uint32 (0x00000000);
data << uint8(0x00);
data << uint32(0x00000000);
}
m_player->SendDirectMessage(&data);
@ -190,7 +190,7 @@ void ReputationMgr::SendInitialReputations()
void ReputationMgr::SendVisible(FactionState const* faction) const
{
if(m_player->GetSession()->PlayerLoading())
if (m_player->GetSession()->PlayerLoading())
return;
// make faction visible in reputation list at client
@ -207,11 +207,11 @@ void ReputationMgr::Initialize()
m_reveredFactionCount = 0;
m_exaltedFactionCount = 0;
for(unsigned int i = 1; i < sFactionStore.GetNumRows(); i++)
for (unsigned int i = 1; i < sFactionStore.GetNumRows(); i++)
{
FactionEntry const *factionEntry = sFactionStore.LookupEntry(i);
FactionEntry const* factionEntry = sFactionStore.LookupEntry(i);
if( factionEntry && (factionEntry->reputationListID >= 0))
if (factionEntry && (factionEntry->reputationListID >= 0))
{
FactionState newFaction;
newFaction.ID = factionEntry->ID;
@ -221,7 +221,7 @@ void ReputationMgr::Initialize()
newFaction.needSend = true;
newFaction.needSave = true;
if( newFaction.Flags & FACTION_FLAG_VISIBLE )
if (newFaction.Flags & FACTION_FLAG_VISIBLE)
++m_visibleFactionCount;
UpdateRankCounters(REP_HOSTILE,GetBaseRank(factionEntry));
@ -235,7 +235,7 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
{
bool res = false;
// if spillover definition exists in DB, override DBC
if (const RepSpilloverTemplate *repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID))
if (const RepSpilloverTemplate* repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID))
{
for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
{
@ -259,7 +259,7 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
if (!flist && factionEntry->team && factionEntry->spilloverRateOut != 0.0f)
{
spillOverRepOut *= factionEntry->spilloverRateOut;
if (FactionEntry const *parent = sFactionStore.LookupEntry(factionEntry->team))
if (FactionEntry const* parent = sFactionStore.LookupEntry(factionEntry->team))
{
FactionStateList::iterator parentState = m_factions.find(parent->reputationListID);
// some team factions have own reputation standing, in this case do not spill to other sub-factions
@ -278,7 +278,7 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
// Spillover to affiliated factions
for (SimpleFactionsList::const_iterator itr = flist->begin(); itr != flist->end(); ++itr)
{
if (FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr))
if (FactionEntry const* factionEntryCalc = sFactionStore.LookupEntry(*itr))
{
if (factionEntryCalc == factionEntry || GetRank(factionEntryCalc) > ReputationRank(factionEntryCalc->spilloverMaxRankIn))
continue;
@ -307,7 +307,7 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in
{
int32 BaseRep = GetBaseReputation(factionEntry);
if(incremental)
if (incremental)
standing += itr->second.Standing + BaseRep;
if (standing > Reputation_Cap)
@ -324,7 +324,7 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in
SetVisible(&itr->second);
if(new_rank <= REP_HOSTILE)
if (new_rank <= REP_HOSTILE)
SetAtWar(&itr->second,true);
UpdateRankCounters(old_rank, new_rank);
@ -341,18 +341,18 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in
return false;
}
void ReputationMgr::SetVisible(FactionTemplateEntry const*factionTemplateEntry)
void ReputationMgr::SetVisible(FactionTemplateEntry const* factionTemplateEntry)
{
if(!factionTemplateEntry->faction)
if (!factionTemplateEntry->faction)
return;
if(FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction))
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction))
SetVisible(factionEntry);
}
void ReputationMgr::SetVisible(FactionEntry const *factionEntry)
void ReputationMgr::SetVisible(FactionEntry const* factionEntry)
{
if(factionEntry->reputationListID < 0)
if (factionEntry->reputationListID < 0)
return;
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
@ -365,11 +365,11 @@ void ReputationMgr::SetVisible(FactionEntry const *factionEntry)
void ReputationMgr::SetVisible(FactionState* faction)
{
// always invisible or hidden faction can't be make visible
if(faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN))
if (faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN))
return;
// already set
if(faction->Flags & FACTION_FLAG_VISIBLE)
if (faction->Flags & FACTION_FLAG_VISIBLE)
return;
faction->Flags |= FACTION_FLAG_VISIBLE;
@ -381,14 +381,14 @@ void ReputationMgr::SetVisible(FactionState* faction)
SendVisible(faction);
}
void ReputationMgr::SetAtWar( RepListID repListID, bool on )
void ReputationMgr::SetAtWar(RepListID repListID, bool on)
{
FactionStateList::iterator itr = m_factions.find(repListID);
if (itr == m_factions.end())
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);
@ -401,10 +401,10 @@ void ReputationMgr::SetAtWar(FactionState* faction, bool atWar)
return;
// already set
if(((faction->Flags & FACTION_FLAG_AT_WAR) != 0) == atWar)
if (((faction->Flags & FACTION_FLAG_AT_WAR) != 0) == atWar)
return;
if( atWar )
if (atWar)
faction->Flags |= FACTION_FLAG_AT_WAR;
else
faction->Flags &= ~FACTION_FLAG_AT_WAR;
@ -413,7 +413,7 @@ void ReputationMgr::SetAtWar(FactionState* faction, bool atWar)
faction->needSave = true;
}
void ReputationMgr::SetInactive( RepListID repListID, bool on )
void ReputationMgr::SetInactive(RepListID repListID, bool on)
{
FactionStateList::iterator itr = m_factions.find(repListID);
if (itr == m_factions.end())
@ -425,14 +425,14 @@ void ReputationMgr::SetInactive( RepListID repListID, bool on )
void ReputationMgr::SetInactive(FactionState* faction, bool inactive)
{
// 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
if(((faction->Flags & FACTION_FLAG_INACTIVE) != 0) == inactive)
if (((faction->Flags & FACTION_FLAG_INACTIVE) != 0) == inactive)
return;
if(inactive)
if (inactive)
faction->Flags |= FACTION_FLAG_INACTIVE;
else
faction->Flags &= ~FACTION_FLAG_INACTIVE;
@ -441,21 +441,21 @@ void ReputationMgr::SetInactive(FactionState* faction, bool inactive)
faction->needSave = true;
}
void ReputationMgr::LoadFromDB(QueryResult *result)
void ReputationMgr::LoadFromDB(QueryResult* result)
{
// Set initial reputations (so everything is nifty before DB data load)
Initialize();
//QueryResult *result = CharacterDatabase.PQuery("SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'",GetGUIDLow());
if(result)
if (result)
{
do
{
Field *fields = result->Fetch();
Field* fields = result->Fetch();
FactionEntry const *factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt32());
if( factionEntry && (factionEntry->reputationListID >= 0))
FactionEntry const* factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt32());
if (factionEntry && (factionEntry->reputationListID >= 0))
{
FactionState* faction = &m_factions[factionEntry->reputationListID];
@ -470,18 +470,18 @@ void ReputationMgr::LoadFromDB(QueryResult *result)
uint32 dbFactionFlags = fields[2].GetUInt32();
if( dbFactionFlags & FACTION_FLAG_VISIBLE )
if (dbFactionFlags & FACTION_FLAG_VISIBLE)
SetVisible(faction); // have internal checks for forced invisibility
if( dbFactionFlags & FACTION_FLAG_INACTIVE)
if (dbFactionFlags & FACTION_FLAG_INACTIVE)
SetInactive(faction,true); // have internal checks for visibility requirement
if( dbFactionFlags & FACTION_FLAG_AT_WAR ) // DB at war
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
{
// allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN)
if( faction->Flags & FACTION_FLAG_VISIBLE )
if (faction->Flags & FACTION_FLAG_VISIBLE)
SetAtWar(faction,false); // have internal checks for FACTION_FLAG_PEACE_FORCED
}
@ -503,7 +503,7 @@ void ReputationMgr::LoadFromDB(QueryResult *result)
}
}
}
while( result->NextRow() );
while (result->NextRow());
delete result;
}
@ -517,7 +517,7 @@ void ReputationMgr::SaveToDB()
SqlStatement stmtDel = CharacterDatabase.CreateStatement(delRep, "DELETE FROM character_reputation WHERE guid = ? AND faction=?");
SqlStatement stmtIns = CharacterDatabase.CreateStatement(insRep, "INSERT INTO character_reputation (guid,faction,standing,flags) VALUES (?, ?, ?, ?)");
for(FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
for (FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
{
if (itr->second.needSave)
{
@ -528,19 +528,19 @@ void ReputationMgr::SaveToDB()
}
}
void ReputationMgr::UpdateRankCounters( ReputationRank old_rank, ReputationRank new_rank )
void ReputationMgr::UpdateRankCounters(ReputationRank old_rank, ReputationRank new_rank)
{
if(old_rank >= REP_EXALTED)
if (old_rank >= REP_EXALTED)
--m_exaltedFactionCount;
if(old_rank >= REP_REVERED)
if (old_rank >= REP_REVERED)
--m_reveredFactionCount;
if(old_rank >= REP_HONORED)
if (old_rank >= REP_HONORED)
--m_honoredFactionCount;
if(new_rank >= REP_EXALTED)
if (new_rank >= REP_EXALTED)
++m_exaltedFactionCount;
if(new_rank >= REP_REVERED)
if (new_rank >= REP_REVERED)
++m_reveredFactionCount;
if(new_rank >= REP_HONORED)
if (new_rank >= REP_HONORED)
++m_honoredFactionCount;
}