Core/Object: Range check vol. 2 (#23226)

* Core/Object: Fix all missing parts for #23062

* Update GameObject.cpp
This commit is contained in:
Jozef Dúc
2019-05-02 21:53:12 +02:00
committed by Giacomo Pozzoni
parent fe3bf57aba
commit 78070163dc
7 changed files with 83 additions and 73 deletions

View File

@@ -330,6 +330,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
uint32 spellId;
uint8 castCount, castFlags;
recvPacket >> castCount >> spellId >> castFlags;
TriggerCastFlags triggerFlag = TRIGGERED_NONE;
TC_LOG_DEBUG("network", "WORLD: got cast spell packet, castCount: %u, spellId: %u, castFlags: %u, data length = %u", castCount, spellId, castFlags, (uint32)recvPacket.size());
@@ -369,25 +370,39 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
caster = _player;
}
if (caster->GetTypeId() == TYPEID_PLAYER && !caster->ToPlayer()->HasActiveSpell(spellId))
{
// not have spell in spellbook
recvPacket.rfinish(); // prevent spam at ignore packet
return;
}
// can't use our own spells when we're in possession of another unit,
if (_player->isPossessing())
{
recvPacket.rfinish(); // prevent spam at ignore packet
return;
}
// client provided targets
SpellCastTargets targets;
targets.Read(recvPacket, caster);
HandleClientCastFlags(recvPacket, castFlags, targets);
// not have spell in spellbook
if (caster->GetTypeId() == TYPEID_PLAYER && !caster->ToPlayer()->HasActiveSpell(spellId))
{
bool allow = false;
// allow casting of unknown spells for special lock cases
if (GameObject *go = targets.GetGOTarget())
if (go->GetSpellForLock(caster->ToPlayer()) == spellInfo)
allow = true;
// TODO: Preparation for #23204
// allow casting of spells triggered by clientside periodic trigger auras
/*
if (caster->HasAuraTypeWithTriggerSpell(SPELL_AURA_PERIODIC_TRIGGER_SPELL_FROM_CLIENT, spellId))
{
allow = true;
triggerFlag = TRIGGERED_FULL_MASK;
}
*/
if (!allow)
return;
}
// can't use our own spells when we're in possession of another unit,
if (_player->isPossessing())
return;
// Client is resending autoshot cast opcode when other spell is cast during shoot rotation
// Skip it to prevent "interrupt" message
// Also check targets! target may have changed and we need to interrupt current spell
@@ -415,7 +430,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
spellInfo = actualSpellInfo;
}
Spell* spell = new Spell(caster, spellInfo, TRIGGERED_NONE);
Spell* spell = new Spell(caster, spellInfo, triggerFlag);
spell->m_cast_count = castCount; // set count of casts
spell->prepare(targets);
}