Core/Misc: Fix exploit

Fix exploit that allowed to duplicate stackable splitable items. If the item that cast the spell can't be found anymore, the spell is cancelled.

Fixes https://github.com/TrinityCore/TrinityCore/issues/11977
This commit is contained in:
jackpoz committed 2014-05-03 21:22:12 +02:00
1 parent d7b1405725
commit 720c3cbbd0
3 files changed
+33 -6

No files matched your search

+29 -5
View File
@@ -3016,7 +3016,12 @@ void Spell::cancel()
void Spell::cast(bool skipCheck)
{
// update pointers base at GUIDs to prevent access to non-existed already object
UpdatePointers();
if (!UpdatePointers())
{
// cancel the spell if UpdatePointers() returned false, something wrong happened there
cancel();
return;
}
// cancel at lost explicit target during cast
if (m_targets.GetObjectTargetGUID() && !m_targets.GetObjectTarget())
@@ -3266,7 +3271,12 @@ void Spell::handle_immediate()
uint64 Spell::handle_delayed(uint64 t_offset)
{
UpdatePointers();
if (!UpdatePointers())
{
// finish the spell if UpdatePointers() returned false, something wrong happened there
finish(false);
return 0;
}
if (m_caster->GetTypeId() == TYPEID_PLAYER)
m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
@@ -3418,7 +3428,12 @@ void Spell::SendSpellCooldown()
void Spell::update(uint32 difftime)
{
// update pointers based at it's GUIDs
UpdatePointers();
if (!UpdatePointers())
{
// cancel the spell if UpdatePointers() returned false, something wrong happened there
cancel();
return;
}
if (m_targets.GetUnitTargetGUID() && !m_targets.GetUnitTarget())
{
@@ -4248,6 +4263,7 @@ void Spell::TakeCastItem()
m_targets.SetItemTarget(NULL);
m_CastItem = NULL;
m_castItemGUID = 0;
}
}
@@ -4492,6 +4508,7 @@ void Spell::TakeReagents()
}
m_CastItem = NULL;
m_castItemGUID = 0;
}
// if GetItemTarget is also spell reagent
@@ -6301,7 +6318,7 @@ void Spell::DelayedChannel()
SendChannelUpdate(m_timer);
}
void Spell::UpdatePointers()
bool Spell::UpdatePointers()
{
if (m_originalCasterGUID == m_caster->GetGUID())
m_originalCaster = m_caster;
@@ -6313,13 +6330,18 @@ void Spell::UpdatePointers()
}
if (m_castItemGUID && m_caster->GetTypeId() == TYPEID_PLAYER)
{
m_CastItem = m_caster->ToPlayer()->GetItemByGuid(m_castItemGUID);
// cast item not found, somehow the item is no longer where we expected
if (!m_CastItem)
return false;
}
m_targets.Update(m_caster);
// further actions done only for dest targets
if (!m_targets.HasDst())
return;
return true;
// cache last transport
WorldObject* transport = NULL;
@@ -6340,6 +6362,8 @@ void Spell::UpdatePointers()
dest._position.RelocateOffset(dest._transportOffset);
}
}
return true;
}
CurrentSpellTypes Spell::GetCurrentContainer() const
+1 -1
View File
@@ -486,7 +486,7 @@ class Spell
SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
int32 GetPowerCost() const { return m_powerCost; }
void UpdatePointers(); // must be used at call Spell code after time delay (non triggered spell cast/update spell call/etc)
bool UpdatePointers(); // must be used at call Spell code after time delay (non triggered spell cast/update spell call/etc)
void CleanupTargetList();
+3
View File
@@ -2096,6 +2096,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
m_targets.SetItemTarget(NULL);
m_CastItem = NULL;
m_castItemGUID = 0;
player->StoreItem(dest, pNewItem, true);
return;
@@ -2114,6 +2115,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
m_targets.SetItemTarget(NULL);
m_CastItem = NULL;
m_castItemGUID = 0;
player->BankItem(dest, pNewItem, true);
return;
@@ -2136,6 +2138,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
m_targets.SetItemTarget(NULL);
m_CastItem = NULL;
m_castItemGUID = 0;
player->EquipItem(dest, pNewItem, true);
player->AutoUnequipOffhandIfNeed();