*Fixes in spell targets packet reading and writing.
--HG-- branch : trunk
This commit is contained in:
@@ -200,82 +200,72 @@ bool SpellCastTargets::read (WorldPacket * data, Unit *caster)
|
|||||||
if (m_targetMask == TARGET_FLAG_SELF)
|
if (m_targetMask == TARGET_FLAG_SELF)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// TARGET_FLAG_UNK2 is used for non-combat pets, maybe other?
|
for (uint8 i = 0; i < MAX_TARGET_FLAGS;++i)
|
||||||
if (m_targetMask & (TARGET_FLAG_UNIT | TARGET_FLAG_UNK2))
|
|
||||||
{
|
{
|
||||||
|
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))
|
if (!data->readPackGUID(m_unitTargetGUID))
|
||||||
return false;
|
return false;
|
||||||
if (m_targetMask & TARGET_FLAG_UNIT)
|
if (m_targetMask & TARGET_FLAG_UNIT)
|
||||||
m_intTargetFlags |= FLAG_INT_UNIT;
|
m_intTargetFlags |= FLAG_INT_UNIT;
|
||||||
}
|
break;
|
||||||
|
case TARGET_FLAG_OBJECT:
|
||||||
if (m_targetMask & (TARGET_FLAG_OBJECT))
|
|
||||||
{
|
|
||||||
if (!data->readPackGUID(m_GOTargetGUID))
|
if (!data->readPackGUID(m_GOTargetGUID))
|
||||||
return false;
|
return false;
|
||||||
m_intTargetFlags |= FLAG_INT_OBJECT;
|
m_intTargetFlags |= FLAG_INT_OBJECT;
|
||||||
}
|
break;
|
||||||
|
case TARGET_FLAG_CORPSE:
|
||||||
if ((m_targetMask & (TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM)) && caster->GetTypeId() == TYPEID_PLAYER)
|
case TARGET_FLAG_PVP_CORPSE:
|
||||||
if (!data->readPackGUID(m_itemTargetGUID))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (m_targetMask & (TARGET_FLAG_CORPSE | TARGET_FLAG_PVP_CORPSE))
|
|
||||||
if (!data->readPackGUID(m_CorpseTargetGUID))
|
if (!data->readPackGUID(m_CorpseTargetGUID))
|
||||||
return false;
|
return false;
|
||||||
|
break;
|
||||||
if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
|
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:
|
||||||
{
|
{
|
||||||
if (data->rpos() + 1 + 4 + 4 + 4 > data->size())
|
uint64 relativePositionObjGUID;
|
||||||
|
if (!data->readPackGUID(relativePositionObjGUID))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!data->readPackGUID(m_unitTargetGUID))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
*data >> m_srcPos.m_positionX >> m_srcPos.m_positionY >> m_srcPos.m_positionZ;
|
*data >> m_srcPos.m_positionX >> m_srcPos.m_positionY >> m_srcPos.m_positionZ;
|
||||||
|
m_srcPos.m_orientation = caster->GetOrientation();
|
||||||
if (!m_srcPos.IsPositionValid())
|
if (!m_srcPos.IsPositionValid())
|
||||||
return false;
|
return false;
|
||||||
m_intTargetFlags |= FLAG_INT_SRC_LOC;
|
m_intTargetFlags |= FLAG_INT_SRC_LOC;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
case TARGET_FLAG_DEST_LOCATION:
|
||||||
m_srcPos.Relocate(caster);
|
|
||||||
|
|
||||||
if (m_targetMask & TARGET_FLAG_DEST_LOCATION)
|
|
||||||
{
|
{
|
||||||
if (data->rpos() + 1 + 4 + 4 + 4 > data->size())
|
uint64 relativePositionObjGUID;
|
||||||
|
if (!data->readPackGUID(relativePositionObjGUID))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!data->readPackGUID(m_unitTargetGUID))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
*data >> m_dstPos.m_positionX >> m_dstPos.m_positionY >> m_dstPos.m_positionZ;
|
*data >> m_dstPos.m_positionX >> m_dstPos.m_positionY >> m_dstPos.m_positionZ;
|
||||||
if (!m_dstPos.IsPositionValid())
|
if (!m_dstPos.IsPositionValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_intTargetFlags |= FLAG_INT_DST_LOC;
|
m_intTargetFlags |= FLAG_INT_DST_LOC;
|
||||||
|
break;
|
||||||
if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
|
|
||||||
{
|
|
||||||
if (data->rpos() + 4 + 4 <= data->size())
|
|
||||||
{
|
|
||||||
*data >> m_elevation >> m_speed;
|
|
||||||
// TODO: should also read
|
|
||||||
m_srcPos.m_orientation = caster->GetOrientation();
|
|
||||||
//*data >> uint16 >> uint8 >> uint32 >> uint32;
|
|
||||||
//*data >> float >> float >> float >> float...
|
|
||||||
}
|
}
|
||||||
}
|
case TARGET_FLAG_STRING:
|
||||||
}
|
|
||||||
else
|
|
||||||
m_dstPos.Relocate(caster);
|
|
||||||
|
|
||||||
if (m_targetMask & TARGET_FLAG_STRING)
|
|
||||||
{
|
|
||||||
if (data->rpos() + 1 > data->size())
|
if (data->rpos() + 1 > data->size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*data >> m_strTarget;
|
*data >> m_strTarget;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(m_targetMask & TARGET_FLAG_SOURCE_LOCATION))
|
||||||
|
m_srcPos.Relocate(caster);
|
||||||
|
|
||||||
|
if (!(m_targetMask & TARGET_FLAG_DEST_LOCATION)
|
||||||
|
m_dstPos.Relocate(caster);
|
||||||
|
|
||||||
// find real units/GOs
|
// find real units/GOs
|
||||||
Update(caster);
|
Update(caster);
|
||||||
@@ -287,50 +277,51 @@ void SpellCastTargets::write (WorldPacket * data)
|
|||||||
*data << uint32(m_targetMask);
|
*data << uint32(m_targetMask);
|
||||||
//sLog.outDebug("Spell write, target mask = %u", m_targetMask);
|
//sLog.outDebug("Spell write, target mask = %u", m_targetMask);
|
||||||
|
|
||||||
if (m_targetMask & (TARGET_FLAG_UNIT | TARGET_FLAG_PVP_CORPSE | TARGET_FLAG_OBJECT | TARGET_FLAG_CORPSE | TARGET_FLAG_UNK2))
|
for (uint8 i = 0; i < MAX_TARGET_FLAGS;++i)
|
||||||
{
|
{
|
||||||
if (m_targetMask & TARGET_FLAG_UNIT)
|
if (!(m_targetMask & (1<<i)))
|
||||||
|
continue;
|
||||||
|
switch (1<<i)
|
||||||
{
|
{
|
||||||
|
case TARGET_FLAG_UNIT:
|
||||||
if (m_unitTarget)
|
if (m_unitTarget)
|
||||||
data->append(m_unitTarget->GetPackGUID());
|
data->append(m_unitTarget->GetPackGUID());
|
||||||
else
|
else
|
||||||
*data << uint8(0);
|
*data << uint8(0);
|
||||||
}
|
break;
|
||||||
else if (m_targetMask & TARGET_FLAG_OBJECT)
|
case TARGET_FLAG_OBJECT:
|
||||||
{
|
|
||||||
if (m_GOTarget)
|
if (m_GOTarget)
|
||||||
data->append(m_GOTarget->GetPackGUID());
|
data->append(m_GOTarget->GetPackGUID());
|
||||||
else
|
else
|
||||||
*data << uint8(0);
|
*data << uint8(0);
|
||||||
}
|
break;
|
||||||
else if (m_targetMask & (TARGET_FLAG_CORPSE | TARGET_FLAG_PVP_CORPSE))
|
case TARGET_FLAG_CORPSE:
|
||||||
|
case TARGET_FLAG_PVP_CORPSE:
|
||||||
data->appendPackGUID(m_CorpseTargetGUID);
|
data->appendPackGUID(m_CorpseTargetGUID);
|
||||||
else
|
break;
|
||||||
|
case TARGET_FLAG_UNK17:
|
||||||
*data << uint8(0);
|
*data << uint8(0);
|
||||||
}
|
break;
|
||||||
|
case TARGET_FLAG_ITEM:
|
||||||
if (m_targetMask & (TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM))
|
case TARGET_FLAG_TRADE_ITEM:
|
||||||
{
|
|
||||||
if (m_itemTarget)
|
if (m_itemTarget)
|
||||||
data->append(m_itemTarget->GetPackGUID());
|
data->append(m_itemTarget->GetPackGUID());
|
||||||
else
|
else
|
||||||
*data << uint8(0);
|
*data << uint8(0);
|
||||||
}
|
break;
|
||||||
|
case TARGET_FLAG_SOURCE_LOCATION:
|
||||||
if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
|
*data << uint8(0); // relative position guid here - transport for example
|
||||||
{
|
|
||||||
*data << uint8(0); // It seems the client doesn't like unit target GUID being sent here, we must send 0
|
|
||||||
*data << m_srcPos.m_positionX << m_srcPos.m_positionY << m_srcPos.m_positionZ;
|
*data << m_srcPos.m_positionX << m_srcPos.m_positionY << m_srcPos.m_positionZ;
|
||||||
}
|
break;
|
||||||
|
case TARGET_FLAG_DEST_LOCATION:
|
||||||
if (m_targetMask & TARGET_FLAG_DEST_LOCATION)
|
*data << uint8(0); // relative position guid here - transport for example
|
||||||
{
|
|
||||||
*data << uint8(0); // It seems the client doesn't like unit target GUID being sent here, we must send 0
|
|
||||||
*data << m_dstPos.m_positionX << m_dstPos.m_positionY << m_dstPos.m_positionZ;
|
*data << m_dstPos.m_positionX << m_dstPos.m_positionY << m_dstPos.m_positionZ;
|
||||||
}
|
break;
|
||||||
|
case TARGET_FLAG_STRING:
|
||||||
if (m_targetMask & TARGET_FLAG_STRING)
|
|
||||||
*data << m_strTarget;
|
*data << m_strTarget;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, Spell** triggeringContainer, bool skipCheck)
|
Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, Spell** triggeringContainer, bool skipCheck)
|
||||||
|
|||||||
@@ -60,13 +60,14 @@ enum SpellCastTargetFlags
|
|||||||
TARGET_FLAG_OBJECT = 0x00000800, // pguid, 2 spells
|
TARGET_FLAG_OBJECT = 0x00000800, // pguid, 2 spells
|
||||||
TARGET_FLAG_TRADE_ITEM = 0x00001000, // pguid, 0 spells
|
TARGET_FLAG_TRADE_ITEM = 0x00001000, // pguid, 0 spells
|
||||||
TARGET_FLAG_STRING = 0x00002000, // string, 0 spells
|
TARGET_FLAG_STRING = 0x00002000, // string, 0 spells
|
||||||
TARGET_FLAG_UNK1 = 0x00004000, // 199 spells, opening object/lock
|
TARGET_FLAG_UNK15 = 0x00004000, // 199 spells, opening object/lock
|
||||||
TARGET_FLAG_CORPSE = 0x00008000, // pguid, resurrection spells
|
TARGET_FLAG_CORPSE = 0x00008000, // pguid, resurrection spells
|
||||||
TARGET_FLAG_UNK2 = 0x00010000, // pguid, not used in any spells as of 3.2.2a (can be set dynamically)
|
TARGET_FLAG_UNK17 = 0x00010000, // pguid, not used in any spells as of 3.2.2a (can be set dynamically)
|
||||||
TARGET_FLAG_GLYPH = 0x00020000, // used in glyph spells
|
TARGET_FLAG_GLYPH = 0x00020000, // used in glyph spells
|
||||||
TARGET_FLAG_UNK3 = 0x00040000, //
|
TARGET_FLAG_UNK19 = 0x00040000, //
|
||||||
TARGET_FLAG_UNK4 = 0x00080000 // uint32, loop { vec3, guid -> if guid == 0 break }
|
TARGET_FLAG_UNK20 = 0x00080000 // uint32, loop { vec3, guid -> if guid == 0 break }
|
||||||
};
|
};
|
||||||
|
#define MAX_TARGET_FLAGS 21
|
||||||
|
|
||||||
enum SpellCastFlags
|
enum SpellCastFlags
|
||||||
{
|
{
|
||||||
@@ -93,7 +94,16 @@ enum SpellCastFlags
|
|||||||
CAST_FLAG_UNKNOWN_20 = 0x00080000,
|
CAST_FLAG_UNKNOWN_20 = 0x00080000,
|
||||||
CAST_FLAG_UNKNOWN_21 = 0x00100000,
|
CAST_FLAG_UNKNOWN_21 = 0x00100000,
|
||||||
CAST_FLAG_RUNE_LIST = 0x00200000,
|
CAST_FLAG_RUNE_LIST = 0x00200000,
|
||||||
CAST_FLAG_UNKNOWN_23 = 0x04000000
|
CAST_FLAG_UNKNOWN_23 = 0x00400000,
|
||||||
|
CAST_FLAG_UNKNOWN_24 = 0x00800000,
|
||||||
|
CAST_FLAG_UNKNOWN_25 = 0x01000000,
|
||||||
|
CAST_FLAG_UNKNOWN_26 = 0x02000000,
|
||||||
|
CAST_FLAG_UNKNOWN_27 = 0x04000000,
|
||||||
|
CAST_FLAG_UNKNOWN_28 = 0x08000000,
|
||||||
|
CAST_FLAG_UNKNOWN_29 = 0x10000000,
|
||||||
|
CAST_FLAG_UNKNOWN_30 = 0x20000000,
|
||||||
|
CAST_FLAG_UNKNOWN_31 = 0x40000000,
|
||||||
|
CAST_FLAG_UNKNOWN_32 = 0x80000000,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SpellRangeFlag
|
enum SpellRangeFlag
|
||||||
|
|||||||
Reference in New Issue
Block a user