diff options
author | Machiavelli <none@none> | 2009-10-10 22:59:25 +0200 |
---|---|---|
committer | Machiavelli <none@none> | 2009-10-10 22:59:25 +0200 |
commit | 5fcf3b3d8919374a326da97b69edb95c2949a787 (patch) | |
tree | 8a51bbb4b53793a6601f2625c08a5ddcd51ddd99 /src/game/ReputationMgr.cpp | |
parent | dfc2945961ac0e6e848170c181134fb554077559 (diff) |
Changes to ReputationMgr::SetReputation that makes grouped reputation gains possible. Fixes ie. Alliance Vanguard/Horde Expedition rep, and correctly gives 25% of the earned rep to your home city to the other major cities of your faction.
Note: there will need to be some DB changes to creature_onkill_reputation to cover the grouped rep gains in some cases.
--HG--
branch : trunk
Diffstat (limited to 'src/game/ReputationMgr.cpp')
-rw-r--r-- | src/game/ReputationMgr.cpp | 74 |
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) |