From 14ad1def8b66a26f62363fb1e217213ea99fca74 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Fri, 6 Aug 2021 18:39:35 +0200 Subject: [PATCH] fix(Core/Spells): pets should not dispel beneficials bufs from neutral units not being at war with pet's owner (#7230) - Closes #6691 --- src/server/game/Entities/Unit/Unit.cpp | 22 ++++++++++++++++++++- src/server/game/Reputation/ReputationMgr.h | 13 ------------ src/server/shared/DataStores/DBCEnums.h | 13 ++++++++++++ src/server/shared/DataStores/DBCStructure.h | 5 +++++ 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index a2a868e02..fd0d8f06d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -5137,7 +5137,27 @@ void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelCharges if (dispelMask & (1 << DISPEL_DISEASE) && HasAura(50536)) dispelMask &= ~(1 << DISPEL_DISEASE); - bool positive = IsFriendlyTo(caster); + ReputationRank rank = GetReactionTo(caster); + bool positive = rank >= REP_FRIENDLY; + + // Neutral unit not at war with caster should be treated as a friendly unit + if (rank == REP_NEUTRAL) + { + if (Player* casterPlayer = caster->GetAffectingPlayer()) + { + if (FactionTemplateEntry const* factionTemplateEntry = GetFactionTemplateEntry()) + { + if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction)) + { + if (factionEntry->CanBeSetAtWar()) + { + positive = !casterPlayer->GetReputationMgr().IsAtWar(factionEntry); + } + } + } + } + } + Unit::VisibleAuraMap const* visibleAuras = GetVisibleAuras(); for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr) { diff --git a/src/server/game/Reputation/ReputationMgr.h b/src/server/game/Reputation/ReputationMgr.h index 798f72768..c0721f160 100644 --- a/src/server/game/Reputation/ReputationMgr.h +++ b/src/server/game/Reputation/ReputationMgr.h @@ -20,19 +20,6 @@ static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK] = LANG_REP_FRIENDLY, LANG_REP_HONORED, LANG_REP_REVERED, LANG_REP_EXALTED }; -enum FactionFlags -{ - FACTION_FLAG_NONE = 0x00, // no faction flag - FACTION_FLAG_VISIBLE = 0x01, // makes visible in client (set or can be set at interaction with target of this faction) - FACTION_FLAG_AT_WAR = 0x02, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation - FACTION_FLAG_HIDDEN = 0x04, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client) - FACTION_FLAG_INVISIBLE_FORCED = 0x08, // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions - FACTION_FLAG_PEACE_FORCED = 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions - FACTION_FLAG_INACTIVE = 0x20, // player controlled, state stored in characters.data (CMSG_SET_FACTION_INACTIVE) - FACTION_FLAG_RIVAL = 0x40, // flag for the two competing outland factions - FACTION_FLAG_SPECIAL = 0x80 // horde and alliance home cities and their northrend allies have this flag -}; - typedef uint32 RepListID; struct FactionState { diff --git a/src/server/shared/DataStores/DBCEnums.h b/src/server/shared/DataStores/DBCEnums.h index 675095b22..cae9bf191 100644 --- a/src/server/shared/DataStores/DBCEnums.h +++ b/src/server/shared/DataStores/DBCEnums.h @@ -278,6 +278,19 @@ enum SpawnMask SPAWNMASK_RAID_ALL = (SPAWNMASK_RAID_NORMAL_ALL | SPAWNMASK_RAID_HEROIC_ALL), }; +enum FactionFlags +{ + FACTION_FLAG_NONE = 0x00, // no faction flag + FACTION_FLAG_VISIBLE = 0x01, // makes visible in client (set or can be set at interaction with target of this faction) + FACTION_FLAG_AT_WAR = 0x02, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation + FACTION_FLAG_HIDDEN = 0x04, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client) + FACTION_FLAG_INVISIBLE_FORCED = 0x08, // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions + FACTION_FLAG_PEACE_FORCED = 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions + FACTION_FLAG_INACTIVE = 0x20, // player controlled, state stored in characters.data (CMSG_SET_FACTION_INACTIVE) + FACTION_FLAG_RIVAL = 0x40, // flag for the two competing outland factions + FACTION_FLAG_SPECIAL = 0x80 // horde and alliance home cities and their northrend allies have this flag +}; + enum FactionTemplateFlags { FACTION_TEMPLATE_FLAG_PVP = 0x00000800, // flagged for PvP diff --git a/src/server/shared/DataStores/DBCStructure.h b/src/server/shared/DataStores/DBCStructure.h index 62a047225..163ee4842 100644 --- a/src/server/shared/DataStores/DBCStructure.h +++ b/src/server/shared/DataStores/DBCStructure.h @@ -875,6 +875,11 @@ struct FactionEntry { return reputationListID >= 0; } + + [[nodiscard]] bool CanBeSetAtWar() const + { + return reputationListID >= 0 && BaseRepRaceMask[0] == 1791; + } }; #define MAX_FACTION_RELATIONS 4