aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorAlιAѕѕaѕѕιN <AilSynthax@gmail.com>2019-08-28 10:33:41 +0430
committerShauren <shauren.trinity@gmail.com>2021-12-18 21:31:17 +0100
commite1598fa1d64b46fc53607182898fae2da172957b (patch)
tree763306eb21e782a14b331ba5b6d26f2e9b597ce1 /src/server/game/Entities
parent9d3dd3db84a86f77a77d78039b5ad3a9b873ef10 (diff)
[3.3.5] Fix spell_area not checking for zoneID for quests (#23719)
* Fix spell_area not checking for zoneID for quests * Addendum to bdffe0a4a641414fe26c9b75b00f8e70ff0f1cb8 * Fix spell_area handle same spell with the same quests Also fix not checking for quest_end at all. * Addendum to 2d6b0545e3762b3a25005726d4093cf4a7945a8d * Better commenting for 7a50189de3104f000d8b31fa6c415bb69cf1a3e7 * Addendum to 2d6b0545e3762b3a25005726d4093cf4a7945a8d (cherry picked from commit 92d83c3c2eaba3f5b58dc98472318872f3a54706)
Diffstat (limited to 'src/server/game/Entities')
-rw-r--r--src/server/game/Entities/Player/Player.cpp45
1 files changed, 37 insertions, 8 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index c53bb8a693c..23f919da9c0 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -16535,21 +16535,50 @@ void Player::RemoveRewardedQuest(uint32 questId, bool update /*= true*/)
void Player::SendQuestUpdate(uint32 questId)
{
- uint32 zone = 0, area = 0;
- GetZoneAndAreaId(zone, area);
-
- SpellAreaForQuestAreaMapBounds saBounds = sSpellMgr->GetSpellAreaForQuestAreaMapBounds(area, questId);
+ SpellAreaForQuestMapBounds saBounds = sSpellMgr->GetSpellAreaForQuestMapBounds(questId);
if (saBounds.first != saBounds.second)
{
- for (SpellAreaForQuestAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
+ std::set<uint32> aurasToRemove, aurasToCast;
+ uint32 zone = 0, area = 0;
+ GetZoneAndAreaId(zone, area);
+
+ for (SpellAreaForQuestMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
{
if (itr->second->flags & SPELL_AREA_FLAG_AUTOREMOVE && !itr->second->IsFitToRequirements(this, zone, area))
- RemoveAurasDueToSpell(itr->second->spellId);
+ aurasToRemove.insert(itr->second->spellId);
else if (itr->second->flags & SPELL_AREA_FLAG_AUTOCAST && !(itr->second->flags & SPELL_AREA_FLAG_IGNORE_AUTOCAST_ON_QUEST_STATUS_CHANGE))
- if (!HasAura(itr->second->spellId))
- CastSpell(this, itr->second->spellId, true);
+ aurasToCast.insert(itr->second->spellId);
+ }
+
+ // Auras matching the requirements will be inside the aurasToCast container.
+ // Auras not matching the requirements may prevent using auras matching the requirements.
+ // aurasToCast will erase conflicting auras in aurasToRemove container to handle spells used by multiple quests.
+
+ for (auto itr = aurasToRemove.begin(); itr != aurasToRemove.end();)
+ {
+ bool auraRemoved = false;
+
+ for (const auto i : aurasToCast)
+ {
+ if (*itr == i)
+ {
+ itr = aurasToRemove.erase(itr);
+ auraRemoved = true;
+ break;
+ }
+ }
+
+ if (!auraRemoved)
+ ++itr;
}
+
+ for (auto spellId : aurasToCast)
+ if (!HasAura(spellId))
+ CastSpell(this, spellId, true);
+
+ for (auto spellId : aurasToRemove)
+ RemoveAurasDueToSpell(spellId);
}
UpdateVisibleGameobjectsOrSpellClicks();