Core/Conditions: allow spellclick conditions to properly work for aura apply/remove (#23527)
(cherry picked from commit 12e545f7e2247f91db3fd1e8e2f961982422a147)
This commit is contained in:
@@ -1071,6 +1071,11 @@ bool ConditionMgr::IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConditionMgr::IsSpellUsedInSpellClickConditions(uint32 spellId) const
|
||||
{
|
||||
return SpellsUsedInSpellClickConditions.find(spellId) != SpellsUsedInSpellClickConditions.end();
|
||||
}
|
||||
|
||||
ConditionContainer const* ConditionMgr::GetConditionsForAreaTrigger(uint32 areaTriggerId, bool isServerSide) const
|
||||
{
|
||||
return Trinity::Containers::MapGetValuePtr(AreaTriggerConditionContainerStore, { areaTriggerId, isServerSide });
|
||||
@@ -1294,6 +1299,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
|
||||
@@ -1360,6 +1367,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;
|
||||
}
|
||||
@@ -2554,6 +2563,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)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
class Creature;
|
||||
@@ -292,6 +293,9 @@ class TC_GAME_API ConditionMgr
|
||||
bool IsObjectMeetingVehicleSpellConditions(uint32 creatureId, uint32 spellId, Player* player, Unit* vehicle) const;
|
||||
bool IsObjectMeetingSmartEventConditions(int64 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;
|
||||
|
||||
ConditionContainer const* GetConditionsForAreaTrigger(uint32 areaTriggerId, bool isServerSide) const;
|
||||
bool IsObjectMeetingTrainerSpellConditions(uint32 trainerId, uint32 spellId, Player* player) const;
|
||||
|
||||
@@ -329,6 +333,8 @@ class TC_GAME_API ConditionMgr
|
||||
ConditionEntriesByCreatureIdMap SpellClickEventConditionStore;
|
||||
ConditionEntriesByCreatureIdMap NpcVendorConditionContainerStore;
|
||||
SmartEventConditionContainer SmartEventConditionStore;
|
||||
|
||||
std::unordered_set<uint32> SpellsUsedInSpellClickConditions;
|
||||
ConditionEntriesByAreaTriggerIdMap AreaTriggerConditionContainerStore;
|
||||
ConditionEntriesByCreatureIdMap TrainerSpellConditionContainerStore;
|
||||
};
|
||||
|
||||
@@ -16546,7 +16546,7 @@ void Player::SendQuestUpdate(uint32 questId)
|
||||
}
|
||||
}
|
||||
|
||||
UpdateForQuestWorldObjects();
|
||||
UpdateVisibleGameobjectsOrSpellClicks();
|
||||
PhasingHandler::OnConditionChange(this);
|
||||
}
|
||||
|
||||
@@ -16914,8 +16914,7 @@ void Player::ItemRemovedQuestCheck(uint32 entry, uint32 count)
|
||||
IncompleteQuest(questId);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateForQuestWorldObjects();
|
||||
UpdateVisibleGameobjectsOrSpellClicks();
|
||||
}
|
||||
|
||||
void Player::KilledMonster(CreatureTemplate const* cInfo, ObjectGuid guid)
|
||||
@@ -17095,7 +17094,7 @@ void Player::UpdateQuestObjectiveProgress(QuestObjectiveType objectiveType, int3
|
||||
}
|
||||
|
||||
if (anyObjectiveChangedCompletionState)
|
||||
UpdateForQuestWorldObjects();
|
||||
UpdateVisibleGameobjectsOrSpellClicks();
|
||||
}
|
||||
|
||||
bool Player::HasQuestForItem(uint32 itemid) const
|
||||
@@ -25257,7 +25256,7 @@ bool Player::HasQuestForGO(int32 GOId) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void Player::UpdateForQuestWorldObjects()
|
||||
void Player::UpdateVisibleGameobjectsOrSpellClicks()
|
||||
{
|
||||
if (m_clientGUIDs.empty())
|
||||
return;
|
||||
@@ -25306,23 +25305,13 @@ 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)
|
||||
{
|
||||
UF::ObjectData::Base objMask;
|
||||
UF::UnitData::Base unitMask;
|
||||
unitMask.MarkChanged(&UF::UnitData::NpcFlags, 0); // NpcFlags[0] has UNIT_NPC_FLAG_SPELLCLICK
|
||||
obj->BuildValuesUpdateForPlayerWithMask(&udata, objMask.GetChangesMask(), unitMask.GetChangesMask(), this);
|
||||
break;
|
||||
}
|
||||
UF::ObjectData::Base objMask;
|
||||
UF::UnitData::Base unitMask;
|
||||
unitMask.MarkChanged(&UF::UnitData::NpcFlags, 0); // NpcFlags[0] has UNIT_NPC_FLAG_SPELLCLICK
|
||||
obj->BuildValuesUpdateForPlayerWithMask(&udata, objMask.GetChangesMask(), unitMask.GetChangesMask(), this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1599,7 +1599,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
void UpdateQuestObjectiveProgress(QuestObjectiveType objectiveType, int32 objectId, int64 addCount, ObjectGuid victimGuid = ObjectGuid::Empty);
|
||||
bool HasQuestForItem(uint32 itemId) const;
|
||||
bool HasQuestForGO(int32 goId) const;
|
||||
void UpdateForQuestWorldObjects();
|
||||
void UpdateVisibleGameobjectsOrSpellClicks();
|
||||
bool CanShareQuest(uint32 questId) const;
|
||||
|
||||
int32 GetQuestObjectiveData(QuestObjective const& objective) const;
|
||||
|
||||
@@ -3223,6 +3223,10 @@ void Unit::_ApplyAura(AuraApplication* aurApp, uint32 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
|
||||
@@ -3309,6 +3313,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();
|
||||
|
||||
@@ -326,7 +326,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();
|
||||
}
|
||||
|
||||
void Group::ConvertToGroup()
|
||||
@@ -357,7 +357,7 @@ void Group::ConvertToGroup()
|
||||
// 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)
|
||||
@@ -534,7 +534,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
|
||||
@@ -622,7 +622,7 @@ bool Group::RemoveMember(ObjectGuid guid, RemoveMethod method /*= GROUP_REMOVEME
|
||||
player->SetGroup(nullptr);
|
||||
|
||||
// quest related GO state dependent from raid membership
|
||||
player->UpdateForQuestWorldObjects();
|
||||
player->UpdateVisibleGameobjectsOrSpellClicks();
|
||||
}
|
||||
|
||||
player->SetPartyType(m_groupCategory, GROUP_TYPE_NONE);
|
||||
@@ -859,7 +859,7 @@ void Group::Disband(bool hideDestroy /* = false */)
|
||||
|
||||
// quest related GO state dependent from raid membership
|
||||
if (isRaidGroup())
|
||||
player->UpdateForQuestWorldObjects();
|
||||
player->UpdateVisibleGameobjectsOrSpellClicks();
|
||||
|
||||
if (!hideDestroy)
|
||||
player->SendDirectMessage(WorldPackets::Party::GroupDestroyed().Write());
|
||||
|
||||
@@ -529,7 +529,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPackets::AreaTrigger::AreaTrigge
|
||||
}
|
||||
|
||||
if (anyObjectiveChangedCompletionState)
|
||||
player->UpdateForQuestWorldObjects();
|
||||
player->UpdateVisibleGameobjectsOrSpellClicks();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user