Skip to content

Commit

Permalink
Spell: Clear item pointer on consumption
Browse files Browse the repository at this point in the history
Closes #476
  • Loading branch information
killerwife committed Oct 28, 2023
1 parent 1fbd32e commit b4a86fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ void SpellCastTargets::setItemTarget(Item* item)
m_targetMask |= TARGET_FLAG_ITEM;
}

void SpellCastTargets::clearItemPointer()
{
// keep the other information so its clear how the spell was targeted
m_itemTarget = nullptr;
}

void SpellCastTargets::setTradeItemTarget(Player* caster)
{
m_itemTargetGUID = ObjectGuid(uint64(TRADE_SLOT_NONTRADED));
Expand Down Expand Up @@ -5305,7 +5311,7 @@ void Spell::TakeReagents()

// if getItemTarget is also spell reagent
if (m_targets.getItemTargetEntry() == itemid)
m_targets.setItemTarget(nullptr);
m_targets.clearItemPointer();

p_caster->DestroyItemCount(itemid, itemcount, true);
}
Expand Down Expand Up @@ -8934,7 +8940,7 @@ bool Spell::IsAuraProcced(Aura* aura)
void Spell::ClearCastItem()
{
if (m_CastItem == m_targets.getItemTarget())
m_targets.setItemTarget(nullptr);
m_targets.clearItemPointer();

m_CastItem = nullptr;
}
Expand Down
1 change: 1 addition & 0 deletions src/game/Spells/Spell.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class SpellCastTargets
Corpse* getCorpseTarget() const { return m_CorpseTarget; }

void setItemTarget(Item* item);
void clearItemPointer();
ObjectGuid getItemTargetGuid() const { return m_itemTargetGUID; }
Item* getItemTarget() const { return m_itemTarget; }
uint32 getItemTargetEntry() const { return m_itemTargetEntry; }
Expand Down

0 comments on commit b4a86fe

Please sign in to comment.