diff options
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 205 |
1 files changed, 107 insertions, 98 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 57f0c56a987..72ef74dbaad 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -191,76 +191,86 @@ bool SpellCastTargets::read (WorldPacket * data, Unit *caster) if (data->rpos() + 4 > data->size()) return false; - //data->hexlike(); - + uint8 clientCastFlags; + *data >> clientCastFlags; *data >> m_targetMask; //sLog.outDebug("Spell read, target mask = %u", m_targetMask); if (m_targetMask == TARGET_FLAG_SELF) return true; - for (uint8 i = 0; i < MAX_TARGET_FLAGS;++i) + if(m_targetMask & ( TARGET_FLAG_OBJECT)) { - if (!(m_targetMask & (1<<i))) - continue; - switch (1<<i) - { - case TARGET_FLAG_UNIT: - case TARGET_FLAG_UNK17: // used for non-combat pets, maybe other? - if (!data->readPackGUID(m_unitTargetGUID)) - return false; - break; - case TARGET_FLAG_OBJECT: - if (!data->readPackGUID(m_GOTargetGUID)) - return false; - break; - case TARGET_FLAG_CORPSE: - case TARGET_FLAG_PVP_CORPSE: - if (!data->readPackGUID(m_CorpseTargetGUID)) - return false; - break; - case TARGET_FLAG_ITEM: - case TARGET_FLAG_TRADE_ITEM: - if (caster->GetTypeId() != TYPEID_PLAYER) - return false; - if (!data->readPackGUID(m_itemTargetGUID)) - return false; - break; - case TARGET_FLAG_SOURCE_LOCATION: - { - uint64 relativePositionObjGUID; - if (!data->readPackGUID(relativePositionObjGUID)) - return false; - *data >> m_srcPos.m_positionX >> m_srcPos.m_positionY >> m_srcPos.m_positionZ; - m_srcPos.m_orientation = caster->GetOrientation(); - if (!m_srcPos.IsPositionValid()) - return false; - break; - } - case TARGET_FLAG_DEST_LOCATION: - { - uint64 relativePositionObjGUID; - if (!data->readPackGUID(relativePositionObjGUID)) - return false; - *data >> m_dstPos.m_positionX >> m_dstPos.m_positionY >> m_dstPos.m_positionZ; - if (!m_dstPos.IsPositionValid()) - return false; - break; - } - case TARGET_FLAG_STRING: - if (data->rpos() + 1 > data->size()) - return false; - *data >> m_strTarget; - break; - } + if (!data->readPackGUID(m_GOTargetGUID)) + return false; } - if (!(m_targetMask & TARGET_FLAG_SOURCE_LOCATION)) + if(m_targetMask & ( TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM)) + { + if(caster->GetTypeId() == TYPEID_PLAYER) + return false; + if (!data->readPackGUID(m_itemTargetGUID)) + return false; + } + + if(m_targetMask & (TARGET_FLAG_CORPSE | TARGET_FLAG_PVP_CORPSE)) + { + if (!data->readPackGUID(m_CorpseTargetGUID)) + return false; + } + + if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION) + { + uint64 relativePositionObjGUID; + if (!data->readPackGUID(relativePositionObjGUID)) + return false; + *data >> m_srcPos.PositionXYZStream(); + if (!m_srcPos.IsPositionValid()) + return false; + } + else m_srcPos.Relocate(caster); - if (!(m_targetMask & TARGET_FLAG_DEST_LOCATION)) + if (m_targetMask & TARGET_FLAG_DEST_LOCATION) + { + uint64 relativePositionObjGUID; + if (!data->readPackGUID(relativePositionObjGUID)) + return false; + *data >> m_dstPos.PositionXYZStream(); + if (!m_dstPos.IsPositionValid()) + return false; + } + else m_dstPos.Relocate(caster); + if(m_targetMask & TARGET_FLAG_STRING) + { + if (data->rpos() + 1 > data->size()) + return false; + *data << m_strTarget; + } + + // some spell cast packet including more data (for projectiles?) + if (clientCastFlags & 0x02) + { + // not sure about these two + *data >> m_elevation; + *data >> m_speed; + uint8 hasMovementInfo; + *data >> hasMovementInfo; // bool + if (hasMovementInfo) + { + data->read_skip<uint32>(); // MSG_MOVE_STOP - hardcoded in client + uint64 guid; // guid - unused + if (!data->readPackGUID(guid)) + return false; + + data->rpos(data->wpos()); // prevent spam at ignore packet + //MovementInfo movementInfo; + //ReadMovementInfo(*data, &movementInfo); + } + } + // find real units/GOs Update(caster); return true; @@ -271,51 +281,50 @@ void SpellCastTargets::write (WorldPacket * data) *data << uint32(m_targetMask); //sLog.outDebug("Spell write, target mask = %u", m_targetMask); - for (uint8 i = 0; i < MAX_TARGET_FLAGS;++i) + if (m_targetMask & (TARGET_FLAG_UNIT | TARGET_FLAG_PVP_CORPSE | TARGET_FLAG_OBJECT | TARGET_FLAG_CORPSE | TARGET_FLAG_UNK17)) { - if (!(m_targetMask & (1<<i))) - continue; - switch (1<<i) + if (m_targetMask & TARGET_FLAG_UNIT) { - case TARGET_FLAG_UNIT: - if (m_unitTarget) - data->append(m_unitTarget->GetPackGUID()); - else - *data << uint8(0); - break; - case TARGET_FLAG_OBJECT: - if (m_GOTarget) - data->append(m_GOTarget->GetPackGUID()); - else - *data << uint8(0); - break; - case TARGET_FLAG_CORPSE: - case TARGET_FLAG_PVP_CORPSE: - data->appendPackGUID(m_CorpseTargetGUID); - break; - case TARGET_FLAG_UNK17: + if (m_unitTarget) + data->append(m_unitTarget->GetPackGUID()); + else *data << uint8(0); - break; - case TARGET_FLAG_ITEM: - case TARGET_FLAG_TRADE_ITEM: - if (m_itemTarget) - data->append(m_itemTarget->GetPackGUID()); - else - *data << uint8(0); - break; - case TARGET_FLAG_SOURCE_LOCATION: - *data << uint8(0); // relative position guid here - transport for example - *data << m_srcPos.m_positionX << m_srcPos.m_positionY << m_srcPos.m_positionZ; - break; - case TARGET_FLAG_DEST_LOCATION: - *data << uint8(0); // relative position guid here - transport for example - *data << m_dstPos.m_positionX << m_dstPos.m_positionY << m_dstPos.m_positionZ; - break; - case TARGET_FLAG_STRING: - *data << m_strTarget; - break; } + else if (m_targetMask & TARGET_FLAG_OBJECT) + { + if(m_GOTarget) + data->append(m_GOTarget->GetPackGUID()); + else + *data << uint8(0); + } + else if (m_targetMask & ( TARGET_FLAG_CORPSE | TARGET_FLAG_PVP_CORPSE)) + data->appendPackGUID(m_CorpseTargetGUID); + else + *data << uint8(0); } + + if (m_targetMask & ( TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM)) + { + if(m_itemTarget) + data->append(m_itemTarget->GetPackGUID()); + else + *data << uint8(0); + } + + if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION) + { + *data << uint8(0); // relative position guid here - transport for example + *data << m_srcPos.PositionXYZStream(); + } + + if (m_targetMask & TARGET_FLAG_DEST_LOCATION) + { + *data << uint8(0); // relative position guid here - transport for example + *data << m_dstPos.PositionXYZStream(); + } + + if (m_targetMask & TARGET_FLAG_STRING) + *data << m_strTarget; } Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, Spell** triggeringContainer, bool skipCheck) @@ -4689,7 +4698,7 @@ SpellCastResult Spell::CheckCast(bool strict) Unit *target = m_targets.getUnitTarget(); // In pure self-cast spells, the client won't send any unit target - if (!target && (m_targets.getTargetMask() == TARGET_FLAG_SELF || m_targets.getTargetMask() & TARGET_FLAG_CASTER)) // TARGET_FLAG_SELF == 0, remember! + if (!target && (m_targets.getTargetMask() == TARGET_FLAG_SELF || m_targets.getTargetMask() & TARGET_FLAG_UNIT_CASTER)) // TARGET_FLAG_SELF == 0, remember! target = m_caster; if (target) |
