aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/ReputationMgr.cpp74
1 files changed, 64 insertions, 10 deletions
diff --git a/src/game/ReputationMgr.cpp b/src/game/ReputationMgr.cpp
index 8cd9ecc4a91..dbe14fb3350 100644
--- a/src/game/ReputationMgr.cpp
+++ b/src/game/ReputationMgr.cpp
@@ -232,20 +232,74 @@ void ReputationMgr::Initilize()
bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
{
- SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID);
- if (flist)
+ // Determines whether or not the faction is part of a team or the leader of a team.
+ bool isTeamMember = false;
+
+ // Return variable for the function
+ bool res = false;
+
+ SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID, isTeamMember);
+ // Determines whether reputation should be sent to team parent or other team members.
+ int8 extraTarget = (isTeamMember || !flist ? -1 : 0); // 0 = Give equal amount of reputation to anyone in the team (unhandled cases).
+
+ /* When gaining reputation with some factions, you receive a reputation increase
+ towards other reputations for that group.
+ */
+ uint32 team = factionEntry->team;
+
+ int32 sharedStanding = standing; // Here we decide what the amount is to send to the others of the group.
+ switch(team)
{
- bool res = false;
- for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr)
+ case HORDE: // When earning reputation with home city factions, 25% of the earned reputation
+ case ALLIANCE: // is added to others of your alliance. (http://www.wowwiki.com/Reputation)
+ sharedStanding *= 0.25f;
+ extraTarget = 1;
+ break;
+ case 1037: // Alliance Vanguard
+ case 1052: // Horde Expedition
+ sharedStanding *= 0.5f; // Half of the reputation earned by any of the four subfactions of this team will
+ extraTarget = 2; // be added to the main faction. (http://www.wowwiki.com/Alliance_Vanguard)
+ break;
+ }
+
+ FactionEntry const *targetFaction = NULL;
+ switch(extraTarget)
+ {
+ case 0: // To entire team
+ {
+ for (SimpleFactionsList::const_iterator itr = flist->begin(); itr != flist->end(); ++itr)
+ {
+ targetFaction = sFactionStore.LookupEntry(*itr);
+ ASSERT(targetFaction != NULL);
+ res = SetOneFactionReputation(targetFaction, sharedStanding, incremental);
+ }
+ return res;
+ }break;
+ case 1: // To other team members
{
- FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr);
- if(factionEntryCalc)
- res = SetOneFactionReputation(factionEntryCalc, standing, incremental);
+ for (SimpleFactionsList::const_iterator itr = flist->begin(); itr != flist->end(); ++itr)
+ {
+ if((*itr) == factionEntry->ID) // Not to self
+ continue;
+
+ targetFaction = sFactionStore.LookupEntry(*itr);
+ ASSERT(targetFaction != NULL);
+ res = SetOneFactionReputation(targetFaction, sharedStanding, incremental);
+ }
+ }break;
+ case 2: // Extra rep to team parent.
+ {
+ targetFaction = sFactionStore.LookupEntry(team);
+ ASSERT(targetFaction != NULL);
+ res = SetOneFactionReputation(targetFaction, sharedStanding, incremental);
}
- return res;
+ break;
+ default: // -1 Default case, 1 faction
+ return SetOneFactionReputation(factionEntry, standing, incremental);
+ break;
}
- else
- return SetOneFactionReputation(factionEntry, standing, incremental);
+
+ return (SetOneFactionReputation(factionEntry, standing, incremental) && res);
}
bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)