aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-05-02 16:14:41 +0200
committerShauren <shauren.trinity@gmail.com>2022-05-02 16:14:41 +0200
commitd818add0e20fcf2c86ef46b5cd94f942488511a0 (patch)
treefc996f31de4c2ffc98ec41d7368860a536904ec1
parent4ef983f689177660f2d4c16c7063040c7fb0236d (diff)
Core/Auras: Added support for SPELL_ATTR5_LIMIT_N limit to other number than just 1
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp20
-rw-r--r--src/server/game/Miscellaneous/SharedDefines.h2
-rw-r--r--src/server/game/Spells/SpellMgr.cpp2
3 files changed, 12 insertions, 12 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 2dd429741f4..6a5ab4627f7 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -3183,18 +3183,18 @@ void Unit::_AddAura(UnitAura* aura, Unit* caster)
// register single target aura
caster->GetSingleCastAuras().push_back(aura);
+
+ std::queue<Aura*> aurasSharingLimit;
// remove other single target auras
- Unit::AuraList& scAuras = caster->GetSingleCastAuras();
- for (Unit::AuraList::iterator itr = scAuras.begin(); itr != scAuras.end();)
+ for (Aura* scAura : caster->GetSingleCastAuras())
+ if (scAura != aura && scAura->IsSingleTargetWith(aura))
+ aurasSharingLimit.push(scAura);
+
+ uint32 maxOtherAuras = aura->GetSpellInfo()->MaxAffectedTargets - 1;
+ while (aurasSharingLimit.size() > maxOtherAuras)
{
- if ((*itr) != aura &&
- (*itr)->IsSingleTargetWith(aura))
- {
- (*itr)->Remove();
- itr = scAuras.begin();
- }
- else
- ++itr;
+ aurasSharingLimit.front()->Remove();
+ aurasSharingLimit.pop();
}
}
}
diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h
index 043fe6c1271..92d4701f066 100644
--- a/src/server/game/Miscellaneous/SharedDefines.h
+++ b/src/server/game/Miscellaneous/SharedDefines.h
@@ -594,7 +594,7 @@ enum SpellAttr5 : uint32
SPELL_ATTR5_REMOVE_ENTERING_ARENA = 0x00000004, // TITLE Remove Entering Arena DESCRIPTION Force this aura to be removed on entering arena, regardless of other properties
SPELL_ATTR5_ALLOW_WHILE_STUNNED = 0x00000008, // TITLE Allow While Stunned
SPELL_ATTR5_TRIGGERS_CHANNELING = 0x00000010, // TITLE Triggers Channeling
- SPELL_ATTR5_LIMIT_N = 0x00000020, /*INCOMPLETE IMPL*/ // TITLE Limit N DESCRIPTION Remove previous application to another unit if applied
+ SPELL_ATTR5_LIMIT_N = 0x00000020, // TITLE Limit N DESCRIPTION Remove previous application to another unit if applied
SPELL_ATTR5_IGNORE_AREA_EFFECT_PVP_CHECK = 0x00000040, /*NYI*/ // TITLE Ignore Area Effect PvP Check
SPELL_ATTR5_NOT_ON_PLAYER = 0x00000080, /*NYI*/ // TITLE Not On Player
SPELL_ATTR5_NOT_ON_PLAYER_CONTROLLED_NPC = 0x00000100, /*NYI*/ // TITLE Not On Player Controlled NPC
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index c11f101a922..fd780964fcb 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -4705,7 +4705,7 @@ void SpellMgr::LoadSpellInfoCorrections()
if (spellInfo->ActiveIconFileDataId == 135754) // flight
spellInfo->Attributes |= SPELL_ATTR0_PASSIVE;
- if (spellInfo->IsSingleTarget())
+ if (spellInfo->IsSingleTarget() && !spellInfo->MaxAffectedTargets)
spellInfo->MaxAffectedTargets = 1;
}