diff options
author | Wyrserth <wyrserth@protonmail.com> | 2019-07-05 14:11:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-05 14:11:15 +0200 |
commit | 12e545f7e2247f91db3fd1e8e2f961982422a147 (patch) | |
tree | 0d5fe35be9b5e888e0953cf8625fc89962137f74 /src | |
parent | c44fb37f74347e3b6d399c941716971503af4cf8 (diff) |
Core/Conditions: allow spellclick conditions to properly work for aura apply/remove (#23527)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Conditions/ConditionMgr.cpp | 10 | ||||
-rw-r--r-- | src/server/game/Conditions/ConditionMgr.h | 5 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 24 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 8 | ||||
-rw-r--r-- | src/server/game/Groups/Group.cpp | 8 |
6 files changed, 35 insertions, 22 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 7078b127520..2aa97eb2d48 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -1026,6 +1026,11 @@ bool ConditionMgr::IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32 return true; } +bool ConditionMgr::IsSpellUsedInSpellClickConditions(uint32 spellId) const +{ + return SpellsUsedInSpellClickConditions.find(spellId) != SpellsUsedInSpellClickConditions.end(); +} + ConditionMgr* ConditionMgr::instance() { static ConditionMgr instance; @@ -1226,6 +1231,8 @@ void ConditionMgr::LoadConditions(bool isReload) case CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT: { SpellClickEventConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond); + if (cond->ConditionType == CONDITION_AURA) + SpellsUsedInSpellClickConditions.insert(cond->ConditionValue1); valid = true; ++count; continue; // do not add to m_AllocatedMemory to avoid double deleting @@ -1275,6 +1282,8 @@ void ConditionMgr::LoadConditions(bool isReload) //handle not grouped conditions //add new Condition to storage based on Type/Entry + if (cond->SourceType == CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT && cond->ConditionType == CONDITION_AURA) + SpellsUsedInSpellClickConditions.insert(cond->ConditionValue1); ConditionStore[cond->SourceType][cond->SourceEntry].push_back(cond); ++count; } @@ -2377,6 +2386,7 @@ void ConditionMgr::Clean() delete *i; SpellClickEventConditionStore.clear(); + SpellsUsedInSpellClickConditions.clear(); for (ConditionEntriesByCreatureIdMap::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.end(); ++itr) for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it) diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 3e99d6acaed..c8b8c775268 100644 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -23,6 +23,7 @@ #include "Hash.h" #include <array> #include <unordered_map> +#include <unordered_set> #include <vector> class Creature; @@ -263,6 +264,8 @@ class TC_GAME_API ConditionMgr bool IsObjectMeetingSmartEventConditions(int32 entryOrGuid, uint32 eventId, uint32 sourceType, Unit* unit, WorldObject* baseObject) const; bool IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32 itemId, Player* player, Creature* vendor) const; + bool IsSpellUsedInSpellClickConditions(uint32 spellId) const; + struct ConditionTypeInfo { char const* Name; @@ -292,6 +295,8 @@ class TC_GAME_API ConditionMgr ConditionEntriesByCreatureIdMap SpellClickEventConditionStore; ConditionEntriesByCreatureIdMap NpcVendorConditionContainerStore; SmartEventConditionContainer SmartEventConditionStore; + + std::unordered_set<uint32> SpellsUsedInSpellClickConditions; }; #define sConditionMgr ConditionMgr::instance() diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 40399c527be..3b6ec5f0600 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -15960,7 +15960,7 @@ void Player::SendQuestUpdate(uint32 questId) } } - UpdateForQuestWorldObjects(); + UpdateVisibleGameobjectsOrSpellClicks(); } QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver) @@ -16264,12 +16264,12 @@ void Player::ItemAddedQuestCheck(uint32 entry, uint32 count) if (CanCompleteQuest(questid)) CompleteQuest(questid); else if (q_status.ItemCount[j] == reqitemcount) // Send quest update when an objective is completed - UpdateForQuestWorldObjects(); + UpdateVisibleGameobjectsOrSpellClicks(); return; } } } - UpdateForQuestWorldObjects(); + UpdateVisibleGameobjectsOrSpellClicks(); } void Player::ItemRemovedQuestCheck(uint32 entry, uint32 count) @@ -16312,7 +16312,7 @@ void Player::ItemRemovedQuestCheck(uint32 entry, uint32 count) } } } - UpdateForQuestWorldObjects(); + UpdateVisibleGameobjectsOrSpellClicks(); } void Player::KilledMonster(CreatureTemplate const* cInfo, ObjectGuid guid) @@ -23403,7 +23403,7 @@ bool Player::HasQuestForGO(int32 GOId) const return false; } -void Player::UpdateForQuestWorldObjects() +void Player::UpdateVisibleGameobjectsOrSpellClicks() { if (m_clientGUIDs.empty()) return; @@ -23430,20 +23430,10 @@ void Player::UpdateForQuestWorldObjects() auto clickBounds = sObjectMgr->GetSpellClickInfoMapBounds(obj->GetEntry()); for (auto const& clickPair : clickBounds) { - //! This code doesn't look right, but it was logically converted to condition system to do the exact - //! same thing it did before. It definitely needs to be overlooked for intended functionality. if (ConditionContainer const* conds = sConditionMgr->GetConditionsForSpellClickEvent(obj->GetEntry(), clickPair.second.spellId)) { - bool buildUpdateBlock = false; - for (ConditionContainer::const_iterator jtr = conds->begin(); jtr != conds->end() && !buildUpdateBlock; ++jtr) - if ((*jtr)->ConditionType == CONDITION_QUESTREWARDED || (*jtr)->ConditionType == CONDITION_QUESTTAKEN || (*jtr)->ConditionType == CONDITION_QUEST_COMPLETE) - buildUpdateBlock = true; - - if (buildUpdateBlock) - { - obj->BuildValuesUpdateBlockForPlayer(&udata, this); - break; - } + obj->BuildValuesUpdateBlockForPlayer(&udata, this); + break; } } } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 999398bc987..80b3cd9e0cb 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1285,7 +1285,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> void ReputationChanged2(FactionEntry const* factionEntry); bool HasQuestForItem(uint32 itemId, uint32 excludeQuestId = 0, bool turnIn = false) const; bool HasQuestForGO(int32 goId) const; - void UpdateForQuestWorldObjects(); + void UpdateVisibleGameobjectsOrSpellClicks(); bool CanShareQuest(uint32 questId) const; void SendQuestComplete(uint32 questId) const; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 937048030fd..60f30c0a428 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3342,6 +3342,10 @@ void Unit::_ApplyAura(AuraApplication* aurApp, uint8 effMask) if (effMask & 1 << i && (!aurApp->GetRemoveMode())) aurApp->_HandleEffect(i, true); } + + if (Player* player = ToPlayer()) + if (sConditionMgr->IsSpellUsedInSpellClickConditions(aurApp->GetBase()->GetId())) + player->UpdateVisibleGameobjectsOrSpellClicks(); } // removes aura application from lists and unapplies effects @@ -3428,6 +3432,10 @@ void Unit::_UnapplyAura(AuraApplicationMap::iterator& i, AuraRemoveMode removeMo aura->HandleAuraSpecificMods(aurApp, caster, false, false); + if (Player* player = ToPlayer()) + if (sConditionMgr->IsSpellUsedInSpellClickConditions(aurApp->GetBase()->GetId())) + player->UpdateVisibleGameobjectsOrSpellClicks(); + // only way correctly remove all auras from list //if (removedAuras != m_removedAurasCount) new aura may be added i = m_appliedAuras.begin(); diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 4bed2f71a16..1057e8bd0d3 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -321,7 +321,7 @@ void Group::ConvertToRaid() // update quest related GO states (quest activity dependent from raid membership) for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr) if (Player* player = ObjectAccessor::FindPlayer(citr->guid)) - player->UpdateForQuestWorldObjects(); + player->UpdateVisibleGameobjectsOrSpellClicks(); } bool Group::AddInvite(Player* player) @@ -486,7 +486,7 @@ bool Group::AddMember(Player* player) // quest related GO state dependent from raid membership if (isRaidGroup()) - player->UpdateForQuestWorldObjects(); + player->UpdateVisibleGameobjectsOrSpellClicks(); { // Broadcast new player group member fields to rest of the group @@ -582,7 +582,7 @@ bool Group::RemoveMember(ObjectGuid guid, RemoveMethod const& method /*= GROUP_R player->SetGroup(nullptr); // quest related GO state dependent from raid membership - player->UpdateForQuestWorldObjects(); + player->UpdateVisibleGameobjectsOrSpellClicks(); } WorldPacket data; @@ -816,7 +816,7 @@ void Group::Disband(bool hideDestroy /* = false */) // quest related GO state dependent from raid membership if (isRaidGroup()) - player->UpdateForQuestWorldObjects(); + player->UpdateVisibleGameobjectsOrSpellClicks(); if (!player->GetSession()) continue; |