From 2f8e411ac7d357fdd861da2f3cfc9cc2542c2a40 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 6 Jun 2021 19:22:47 +0200 Subject: [PATCH] Core/Reputation: Corrected sorting of friendship rep reactions --- src/server/game/DataStores/DB2Stores.cpp | 4 ++-- src/server/game/DataStores/DB2Stores.h | 3 ++- src/server/game/Reputation/ReputationMgr.cpp | 12 ++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp index 872762d0900..f9bc873bba5 100644 --- a/src/server/game/DataStores/DB2Stores.cpp +++ b/src/server/game/DataStores/DB2Stores.cpp @@ -417,7 +417,7 @@ namespace std::unordered_map, ExpectedStatEntry const*> _expectedStatsByLevel; std::unordered_map> _expectedStatModsByContentTuning; FactionTeamContainer _factionTeams; - std::unordered_map> _friendshipRepReactions; + std::unordered_map> _friendshipRepReactions; HeirloomItemsContainer _heirlooms; GlyphBindableSpellsContainer _glyphBindableSpells; GlyphRequiredSpecsContainer _glyphRequiredSpecs; @@ -2240,7 +2240,7 @@ std::vector const* DB2Manager::GetFactionTeamList(uint32 faction) const return Trinity::Containers::MapGetValuePtr(_factionTeams, faction); } -std::set const* DB2Manager::GetFriendshipRepReactions(uint32 friendshipRepID) const +DB2Manager::FriendshipRepReactionSet const* DB2Manager::GetFriendshipRepReactions(uint32 friendshipRepID) const { return Trinity::Containers::MapGetValuePtr(_friendshipRepReactions, friendshipRepID); } diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h index 08cb150e66e..c0d90be4719 100644 --- a/src/server/game/DataStores/DB2Stores.h +++ b/src/server/game/DataStores/DB2Stores.h @@ -315,6 +315,7 @@ public: using HotfixContainer = std::unordered_map>; + using FriendshipRepReactionSet = std::set; using ItemBonusList = std::vector; using MapDifficultyContainer = std::unordered_map>; using MapDifficultyConditionsContainer = std::vector>; @@ -364,7 +365,7 @@ public: EmotesTextSoundEntry const* GetTextSoundEmoteFor(uint32 emote, uint8 race, uint8 gender, uint8 class_) const; float EvaluateExpectedStat(ExpectedStatType stat, uint32 level, int32 expansion, uint32 contentTuningId, Classes unitClass) const; std::vector const* GetFactionTeamList(uint32 faction) const; - std::set const* GetFriendshipRepReactions(uint32 friendshipRepID) const; + FriendshipRepReactionSet const* GetFriendshipRepReactions(uint32 friendshipRepID) const; uint32 GetGlobalCurveId(GlobalCurve globalCurveType) const; std::vector const* GetGlyphBindableSpells(uint32 glyphPropertiesId) const; std::vector const* GetGlyphRequiredSpecs(uint32 glyphPropertiesId) const; diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp index e662daf4a97..64ac0ba5544 100644 --- a/src/server/game/Reputation/ReputationMgr.cpp +++ b/src/server/game/Reputation/ReputationMgr.cpp @@ -50,8 +50,8 @@ std::set const ReputationMgr::ReputationRankThresholds = const int32 ReputationMgr::Reputation_Cap = 42000; const int32 ReputationMgr::Reputation_Bottom = -42000; -template -static int32 ReputationToRankHelper(std::set const& thresholds, int32 standing, F thresholdExtractor) +template +static int32 ReputationToRankHelper(std::set const& thresholds, int32 standing, F thresholdExtractor) { auto itr = thresholds.begin(); auto end = thresholds.end(); @@ -68,7 +68,7 @@ static int32 ReputationToRankHelper(std::set const& thresholds, int32 standin ReputationRank ReputationMgr::ReputationToRank(FactionEntry const* factionEntry, int32 standing) { int32 rank = MIN_REPUTATION_RANK; - if (std::set const* friendshipReactions = sDB2Manager.GetFriendshipRepReactions(factionEntry->FriendshipRepID)) + if (DB2Manager::FriendshipRepReactionSet const* friendshipReactions = sDB2Manager.GetFriendshipRepReactions(factionEntry->FriendshipRepID)) rank = ReputationToRankHelper(*friendshipReactions, standing, [](FriendshipRepReactionEntry const* frr) { return frr->ReactionThreshold; }); else rank = ReputationToRankHelper(ReputationRankThresholds, standing, [](int32 threshold) { return threshold; }); @@ -128,7 +128,7 @@ int32 ReputationMgr::GetBaseReputation(FactionEntry const* factionEntry) const int32 ReputationMgr::GetMinReputation(FactionEntry const* factionEntry) const { - if (std::set const* friendshipReactions = sDB2Manager.GetFriendshipRepReactions(factionEntry->FriendshipRepID)) + if (DB2Manager::FriendshipRepReactionSet const* friendshipReactions = sDB2Manager.GetFriendshipRepReactions(factionEntry->FriendshipRepID)) return (*friendshipReactions->begin())->ReactionThreshold; return *ReputationRankThresholds.begin(); @@ -155,7 +155,7 @@ int32 ReputationMgr::GetMaxReputation(FactionEntry const* factionEntry) const return cap; } - if (std::set const* friendshipReactions = sDB2Manager.GetFriendshipRepReactions(factionEntry->FriendshipRepID)) + if (DB2Manager::FriendshipRepReactionSet const* friendshipReactions = sDB2Manager.GetFriendshipRepReactions(factionEntry->FriendshipRepID)) return (*friendshipReactions->rbegin())->ReactionThreshold; int32 dataIndex = GetFactionDataIndexForRaceAndClass(factionEntry); @@ -195,7 +195,7 @@ std::string ReputationMgr::GetReputationRankName(FactionEntry const* factionEntr if (!factionEntry->FriendshipRepID) return sObjectMgr->GetTrinityString(ReputationRankStrIndex[GetRank(factionEntry)], _player->GetSession()->GetSessionDbcLocale()); - if (std::set const* friendshipReactions = sDB2Manager.GetFriendshipRepReactions(factionEntry->FriendshipRepID)) + if (DB2Manager::FriendshipRepReactionSet const* friendshipReactions = sDB2Manager.GetFriendshipRepReactions(factionEntry->FriendshipRepID)) { auto itr = friendshipReactions->begin(); std::advance(itr, uint32(rank));