From e1598fa1d64b46fc53607182898fae2da172957b Mon Sep 17 00:00:00 2001 From: AlιAѕѕaѕѕιN Date: Wed, 28 Aug 2019 10:33:41 +0430 Subject: [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) --- src/server/game/Entities/Player/Player.cpp | 45 ++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'src/server/game/Entities/Player') 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 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(); -- cgit v1.2.3