From 36560a4ff3514b60f7435c9fbbe75a94259d087a Mon Sep 17 00:00:00 2001 From: Benjamin Jackson <38561765+heyitsbench@users.noreply.github.com> Date: Sun, 11 Jan 2026 14:57:04 -0500 Subject: [PATCH] fix(Core/Entities): Don't reward quest reputation for factions that are hostile to your player's team. (#24100) Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com> --- src/server/game/Entities/Player/Player.cpp | 31 +++++++++++++++++++-- src/server/shared/DataStores/DBCStructure.h | 2 ++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index d0eaceae0..af9e82be5 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -5993,6 +5993,19 @@ void Player::RewardReputation(Unit* victim) } } +FactionTemplateEntry const* GetAnyFactionTemplateForFaction(uint32 factionId) +{ + for (uint32 i = 0; i < sFactionTemplateStore.GetNumRows(); ++i) + { + if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(i)) + { + if (factionTemplate->faction == factionId) + return factionTemplate; + } + } + return nullptr; +} + // Calculate how many reputation points player gain with the quest void Player::RewardReputation(Quest const* quest) { @@ -6046,10 +6059,24 @@ void Player::RewardReputation(Quest const* quest) sScriptMgr->OnPlayerGiveReputation(this, quest->RewardFactionId[i], rep, REPUTATION_SOURCE_QUEST); } - if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i])) + FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i]); + if (!factionEntry) + continue; + + FactionTemplateEntry const* templateEntry = GetAnyFactionTemplateForFaction(factionEntry->ID); + if (templateEntry) { - GetReputationMgr().ModifyReputation(factionEntry, rep, quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_NO_REP_SPILLOVER)); + bool hostile = (GetTeamId() == TEAM_ALLIANCE) ? templateEntry->IsHostileToAlliancePlayers() + : templateEntry->IsHostileToHordePlayers(); + + if (hostile) + { + LOG_DEBUG("sql.sql", "RewardReputation: {} is hostile with player ({}), skipping!", templateEntry->ID, GetGUID().ToString()); + continue; + } } + + GetReputationMgr().ModifyReputation(factionEntry, rep, quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_NO_REP_SPILLOVER)); } } diff --git a/src/server/shared/DataStores/DBCStructure.h b/src/server/shared/DataStores/DBCStructure.h index 4e7e8ca2c..f72d4ead6 100644 --- a/src/server/shared/DataStores/DBCStructure.h +++ b/src/server/shared/DataStores/DBCStructure.h @@ -979,6 +979,8 @@ struct FactionTemplateEntry return (hostileMask & entry.ourMask) != 0; } [[nodiscard]] bool IsHostileToPlayers() const { return (hostileMask & FACTION_MASK_PLAYER) != 0; } + [[nodiscard]] bool IsHostileToAlliancePlayers() const { return (hostileMask & FACTION_MASK_ALLIANCE) != 0; } + [[nodiscard]] bool IsHostileToHordePlayers() const { return (hostileMask & FACTION_MASK_HORDE) != 0; } [[nodiscard]] bool IsNeutralToAll() const { for (unsigned int i : enemyFaction)