diff options
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 11 | ||||
-rw-r--r-- | src/server/game/Reputation/ReputationMgr.cpp | 79 | ||||
-rw-r--r-- | src/server/game/Reputation/ReputationMgr.h | 8 | ||||
-rw-r--r-- | src/server/game/Server/Packets/QuestPackets.cpp | 4 |
4 files changed, 56 insertions, 46 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 74ca416cc14..25bd2508571 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -6180,6 +6180,10 @@ void Player::RewardReputation(Quest const* quest) if (!quest->RewardFactionId[i]) continue; + FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i]); + if (!factionEntry) + continue; + int32 rep = 0; bool noQuestBonus = false; @@ -6201,6 +6205,9 @@ void Player::RewardReputation(Quest const* quest) if (!rep) continue; + if (quest->RewardFactionCapIn[i] && rep > 0 && GetReputationMgr().GetRank(factionEntry) >= quest->RewardFactionCapIn[i]) + continue; + if (quest->IsDaily()) rep = CalculateReputationGain(REPUTATION_SOURCE_DAILY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); else if (quest->IsWeekly()) @@ -6212,8 +6219,8 @@ void Player::RewardReputation(Quest const* quest) else rep = CalculateReputationGain(REPUTATION_SOURCE_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); - if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i])) - GetReputationMgr().ModifyReputation(factionEntry, rep); + bool noSpillover = quest->GetRewardReputationMask() & (1 << i); + GetReputationMgr().ModifyReputation(factionEntry, rep, noSpillover); } } 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); + } } } } diff --git a/src/server/game/Reputation/ReputationMgr.h b/src/server/game/Reputation/ReputationMgr.h index 301f8833cce..bdfd7046c75 100644 --- a/src/server/game/Reputation/ReputationMgr.h +++ b/src/server/game/Reputation/ReputationMgr.h @@ -119,11 +119,11 @@ class TC_GAME_API ReputationMgr public: // modifiers bool SetReputation(FactionEntry const* factionEntry, int32 standing) { - return SetReputation(factionEntry, standing, false); + return SetReputation(factionEntry, standing, false, false); } - bool ModifyReputation(FactionEntry const* factionEntry, int32 standing) + bool ModifyReputation(FactionEntry const* factionEntry, int32 standing, bool noSpillover = false) { - return SetReputation(factionEntry, standing, true); + return SetReputation(factionEntry, standing, true, noSpillover); } void SetVisible(FactionTemplateEntry const* factionTemplateEntry); @@ -145,7 +145,7 @@ class TC_GAME_API ReputationMgr private: // internal helper functions void Initialize(); uint32 GetDefaultStateFlags(FactionEntry const* factionEntry) const; - bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental); + bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool noSpillover); void SetVisible(FactionState* faction); void SetAtWar(FactionState* faction, bool atWar) const; void SetInactive(FactionState* faction, bool inactive) const; diff --git a/src/server/game/Server/Packets/QuestPackets.cpp b/src/server/game/Server/Packets/QuestPackets.cpp index 9d0d3376ca5..fdebdb91162 100644 --- a/src/server/game/Server/Packets/QuestPackets.cpp +++ b/src/server/game/Server/Packets/QuestPackets.cpp @@ -119,8 +119,8 @@ WorldPacket const* WorldPackets::Quest::QueryQuestInfoResponse::Write() for (uint32 i = 0; i < QUEST_REWARD_REPUTATIONS_COUNT; ++i) { _worldPacket << int32(Info.RewardFactionID[i]); - _worldPacket << int32(Info.RewardFactionOverride[i]); _worldPacket << int32(Info.RewardFactionValue[i]); + _worldPacket << int32(Info.RewardFactionOverride[i]); _worldPacket << int32(Info.RewardFactionCapIn[i]); } @@ -237,8 +237,8 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Quest::QuestRewards const for (uint32 i = 0; i < QUEST_REWARD_REPUTATIONS_COUNT; ++i) { data << int32(questRewards.FactionID[i]); - data << int32(questRewards.FactionOverride[i]); data << int32(questRewards.FactionValue[i]); + data << int32(questRewards.FactionOverride[i]); data << int32(questRewards.FactionCapIn[i]); } |