diff options
author | Shauren <shauren.trinity@gmail.com> | 2016-11-14 16:35:01 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2016-11-14 16:35:01 +0100 |
commit | 0f7b9c67f35f2d61446aebbcef48497afb321651 (patch) | |
tree | 3caf05f45d8a048ce93082e9096393f490a526a9 /src/server/game/Reputation/ReputationMgr.cpp | |
parent | 780d1019f217263ff96e7e51d412eb952983b761 (diff) |
Core/Quests: Fixed quest reputation rewards in packets and implemented new fields - RewardFactionCapIn and RewardReputationMask
Diffstat (limited to 'src/server/game/Reputation/ReputationMgr.cpp')
-rw-r--r-- | src/server/game/Reputation/ReputationMgr.cpp | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp index 0a191b5f3f1..956bee07440 100644 --- a/src/server/game/Reputation/ReputationMgr.cpp +++ b/src/server/game/Reputation/ReputationMgr.cpp @@ -266,61 +266,64 @@ void ReputationMgr::Initialize() } } -bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental) +bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool noSpillover) { 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)) + if (!noSpillover) { - for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i) + // if spillover definition exists in DB, override DBC + if (const RepSpilloverTemplate* repTemplate = sObjectMgr->GetRepSpilloverTemplate(factionEntry->ID)) { - if (repTemplate->faction[i]) + for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i) { - if (_player->GetReputationRank(repTemplate->faction[i]) <= ReputationRank(repTemplate->faction_rank[i])) + if (repTemplate->faction[i]) { - // bonuses are already given, so just modify standing by rate - int32 spilloverRep = int32(standing * repTemplate->faction_rate[i]); - SetOneFactionReputation(sFactionStore.AssertEntry(repTemplate->faction[i]), spilloverRep, incremental); + 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]); + SetOneFactionReputation(sFactionStore.AssertEntry(repTemplate->faction[i]), spilloverRep, incremental); + } } } } - } - else - { - float spillOverRepOut = float(standing); - // check for sub-factions that receive spillover - std::vector<uint32> const* flist = sDB2Manager.GetFactionTeamList(factionEntry->ID); - // if has no sub-factions, check for factions with same parent - if (!flist && factionEntry->ParentFactionID && factionEntry->ParentFactionModOut != 0.0f) + else { - spillOverRepOut *= factionEntry->ParentFactionModOut; - if (FactionEntry const* parent = sFactionStore.LookupEntry(factionEntry->ParentFactionID)) + float spillOverRepOut = float(standing); + // check for sub-factions that receive spillover + std::vector<uint32> const* flist = sDB2Manager.GetFactionTeamList(factionEntry->ID); + // if has no sub-factions, check for factions with same parent + if (!flist && factionEntry->ParentFactionID && factionEntry->ParentFactionModOut != 0.0f) { - FactionStateList::iterator parentState = _factions.find(parent->ReputationIndex); - // some team factions have own reputation standing, in this case do not spill to other sub-factions - if (parentState != _factions.end() && (parentState->second.Flags & FACTION_FLAG_SPECIAL)) + spillOverRepOut *= factionEntry->ParentFactionModOut; + if (FactionEntry const* parent = sFactionStore.LookupEntry(factionEntry->ParentFactionID)) { - SetOneFactionReputation(parent, int32(spillOverRepOut), incremental); - } - else // spill to "sister" factions - { - flist = sDB2Manager.GetFactionTeamList(factionEntry->ParentFactionID); + FactionStateList::iterator parentState = _factions.find(parent->ReputationIndex); + // some team factions have own reputation standing, in this case do not spill to other sub-factions + if (parentState != _factions.end() && (parentState->second.Flags & FACTION_FLAG_SPECIAL)) + { + SetOneFactionReputation(parent, int32(spillOverRepOut), incremental); + } + else // spill to "sister" factions + { + flist = sDB2Manager.GetFactionTeamList(factionEntry->ParentFactionID); + } } } - } - if (flist) - { - // Spillover to affiliated factions - for (std::vector<uint32>::const_iterator itr = flist->begin(); itr != flist->end(); ++itr) + if (flist) { - if (FactionEntry const* factionEntryCalc = sFactionStore.LookupEntry(*itr)) + // Spillover to affiliated factions + for (std::vector<uint32>::const_iterator itr = flist->begin(); itr != flist->end(); ++itr) { - if (factionEntryCalc == factionEntry || GetRank(factionEntryCalc) > ReputationRank(factionEntryCalc->ParentFactionCapIn)) - continue; - int32 spilloverRep = int32(spillOverRepOut * factionEntryCalc->ParentFactionModIn); - if (spilloverRep != 0 || !incremental) - res = SetOneFactionReputation(factionEntryCalc, spilloverRep, incremental); + if (FactionEntry const* factionEntryCalc = sFactionStore.LookupEntry(*itr)) + { + if (factionEntryCalc == factionEntry || GetRank(factionEntryCalc) > ReputationRank(factionEntryCalc->ParentFactionCapIn)) + continue; + int32 spilloverRep = int32(spillOverRepOut * factionEntryCalc->ParentFactionModIn); + if (spilloverRep != 0 || !incremental) + res = SetOneFactionReputation(factionEntryCalc, spilloverRep, incremental); + } } } } |