From 03cb87482513445b06dcf31c678888c685698f31 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 6 May 2020 18:00:59 -0400 Subject: [PATCH] Core/Misc: Always reward all necessary reputations on creature kill Port From (https://github.com/TrinityCore/TrinityCore/commit/e36497aef57899f18e0d55c0640bfd96e2251a8e) --- Source/Game/Entities/Player/Player.cs | 12 ++++++------ Source/Game/Reputation/ReputationManager.cs | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index a7e8b4e1b..986fc835d 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -1244,7 +1244,7 @@ namespace Game.Entities { if (currency.Flags.HasAnyFlag((uint)CurrencyFlags.HighPrecision)) count /= 100; - GetReputationMgr().ModifyReputation(factionEntry, count, true); + GetReputationMgr().ModifyReputation(factionEntry, count, false, true); return; } @@ -1645,8 +1645,8 @@ namespace Game.Entities FactionRecord factionEntry1 = CliDB.FactionStorage.LookupByKey(ChampioningFaction != 0 ? ChampioningFaction : Rep.RepFaction1); ReputationRank current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1); - if (factionEntry1 != null && (uint)current_reputation_rank1 <= Rep.ReputationMaxCap1) - GetReputationMgr().ModifyReputation(factionEntry1, donerep1); + if (factionEntry1 != null) + GetReputationMgr().ModifyReputation(factionEntry1, donerep1, (uint)current_reputation_rank1 > Rep.ReputationMaxCap1); } if (Rep.RepFaction2 != 0 && (!Rep.TeamDependent || team == Team.Horde)) @@ -1656,8 +1656,8 @@ namespace Game.Entities FactionRecord factionEntry2 = CliDB.FactionStorage.LookupByKey(ChampioningFaction != 0 ? ChampioningFaction : Rep.RepFaction2); ReputationRank current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2); - if (factionEntry2 != null && (uint)current_reputation_rank2 <= Rep.ReputationMaxCap2) - GetReputationMgr().ModifyReputation(factionEntry2, donerep2); + if (factionEntry2 != null) + GetReputationMgr().ModifyReputation(factionEntry2, donerep2, (uint)current_reputation_rank2 > Rep.ReputationMaxCap2); } } // Calculate how many reputation points player gain with the quest @@ -1709,7 +1709,7 @@ namespace Game.Entities rep = CalculateReputationGain(ReputationSource.Quest, (uint)GetQuestLevel(quest), rep, (int)quest.RewardFactionId[i], noQuestBonus); bool noSpillover = Convert.ToBoolean(quest.RewardReputationMask & (1 << i)); - GetReputationMgr().ModifyReputation(factionEntry, rep, noSpillover); + GetReputationMgr().ModifyReputation(factionEntry, rep, false, noSpillover); } } diff --git a/Source/Game/Reputation/ReputationManager.cs b/Source/Game/Reputation/ReputationManager.cs index 7d4c3c78d..bf7a8b4a7 100644 --- a/Source/Game/Reputation/ReputationManager.cs +++ b/Source/Game/Reputation/ReputationManager.cs @@ -264,9 +264,17 @@ namespace Game } } - public bool ModifyReputation(FactionRecord factionEntry, int standing, bool noSpillover = false) { return SetReputation(factionEntry, standing, true, noSpillover); } + public bool ModifyReputation(FactionRecord factionEntry, int standing, bool spillOverOnly = false, bool noSpillover = false) + { + return SetReputation(factionEntry, standing, true, spillOverOnly, noSpillover); + } - public bool SetReputation(FactionRecord factionEntry, int standing, bool incremental = false, bool noSpillover = false) + public bool SetReputation(FactionRecord factionEntry, int standing) + { + return SetReputation(factionEntry, standing, false, false, false); + } + + public bool SetReputation(FactionRecord factionEntry, int standing, bool incremental, bool spillOverOnly, bool noSpillover) { Global.ScriptMgr.OnPlayerReputationChange(_player, factionEntry.Id, standing, incremental); bool res = false; @@ -336,7 +344,10 @@ namespace Game var faction = _factions.LookupByKey(factionEntry.ReputationIndex); if (faction != null) { - res = SetOneFactionReputation(factionEntry, standing, incremental); + // if we update spillover only, do not update main reputation (rank exceeds creature reward rate) + if (!spillOverOnly) + res = SetOneFactionReputation(factionEntry, standing, incremental); + // only this faction gets reported to client, even if it has no own visible standing SendState(faction); }