aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Spells/Spell.cpp203
-rw-r--r--src/server/game/Spells/Spell.h20
2 files changed, 112 insertions, 111 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 874391f0f3a..1f3f2883d09 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -200,82 +200,72 @@ bool SpellCastTargets::read (WorldPacket * data, Unit *caster)
if (m_targetMask == TARGET_FLAG_SELF)
return true;
- // TARGET_FLAG_UNK2 is used for non-combat pets, maybe other?
- if (m_targetMask & (TARGET_FLAG_UNIT | TARGET_FLAG_UNK2))
+ for (uint8 i = 0; i < MAX_TARGET_FLAGS;++i)
{
- if (!data->readPackGUID(m_unitTargetGUID))
- return false;
- if (m_targetMask & TARGET_FLAG_UNIT)
- m_intTargetFlags |= FLAG_INT_UNIT;
- }
-
- if (m_targetMask & (TARGET_FLAG_OBJECT))
- {
- if (!data->readPackGUID(m_GOTargetGUID))
- return false;
- m_intTargetFlags |= FLAG_INT_OBJECT;
- }
-
- if ((m_targetMask & (TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM)) && caster->GetTypeId() == TYPEID_PLAYER)
- 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)
- {
- if (data->rpos() + 1 + 4 + 4 + 4 > data->size())
- return false;
-
- if (!data->readPackGUID(m_unitTargetGUID))
- return false;
-
- *data >> m_srcPos.m_positionX >> m_srcPos.m_positionY >> m_srcPos.m_positionZ;
- if (!m_srcPos.IsPositionValid())
- return false;
- m_intTargetFlags |= FLAG_INT_SRC_LOC;
- }
- else
- m_srcPos.Relocate(caster);
-
- if (m_targetMask & TARGET_FLAG_DEST_LOCATION)
- {
- if (data->rpos() + 1 + 4 + 4 + 4 > data->size())
- return false;
-
- if (!data->readPackGUID(m_unitTargetGUID))
- return false;
-
- *data >> m_dstPos.m_positionX >> m_dstPos.m_positionY >> m_dstPos.m_positionZ;
- if (!m_dstPos.IsPositionValid())
- return false;
-
- m_intTargetFlags |= FLAG_INT_DST_LOC;
-
- if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
+ if (!(m_targetMask & (1<<i)))
+ continue;
+ switch (1<<i)
{
- if (data->rpos() + 4 + 4 <= data->size())
+ case TARGET_FLAG_UNIT:
+ case TARGET_FLAG_UNK17: // used for non-combat pets, maybe other?
+ if (!data->readPackGUID(m_unitTargetGUID))
+ return false;
+ if (m_targetMask & TARGET_FLAG_UNIT)
+ m_intTargetFlags |= FLAG_INT_UNIT;
+ break;
+ case TARGET_FLAG_OBJECT:
+ if (!data->readPackGUID(m_GOTargetGUID))
+ return false;
+ m_intTargetFlags |= FLAG_INT_OBJECT;
+ 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:
{
- *data >> m_elevation >> m_speed;
- // TODO: should also read
+ 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();
- //*data >> uint16 >> uint8 >> uint32 >> uint32;
- //*data >> float >> float >> float >> float...
+ if (!m_srcPos.IsPositionValid())
+ return false;
+ m_intTargetFlags |= FLAG_INT_SRC_LOC;
+ 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;
+ m_intTargetFlags |= FLAG_INT_DST_LOC;
+ break;
+ }
+ case TARGET_FLAG_STRING:
+ if (data->rpos() + 1 > data->size())
+ return false;
+ *data >> m_strTarget;
+ break;
}
}
- else
- m_dstPos.Relocate(caster);
- if (m_targetMask & TARGET_FLAG_STRING)
- {
- if (data->rpos() + 1 > data->size())
- return false;
+ if (!(m_targetMask & TARGET_FLAG_SOURCE_LOCATION))
+ m_srcPos.Relocate(caster);
- *data >> m_strTarget;
- }
+ if (!(m_targetMask & TARGET_FLAG_DEST_LOCATION)
+ m_dstPos.Relocate(caster);
// find real units/GOs
Update(caster);
@@ -287,50 +277,51 @@ void SpellCastTargets::write (WorldPacket * data)
*data << uint32(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_unitTarget)
- data->append(m_unitTarget->GetPackGUID());
- else
- *data << uint8(0);
- }
- else if (m_targetMask & TARGET_FLAG_OBJECT)
+ if (!(m_targetMask & (1<<i)))
+ continue;
+ switch (1<<i)
{
- if (m_GOTarget)
- data->append(m_GOTarget->GetPackGUID());
- else
+ 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:
*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_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); // 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;
- }
-
- if (m_targetMask & TARGET_FLAG_DEST_LOCATION)
- {
- *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;
- }
-
- if (m_targetMask & TARGET_FLAG_STRING)
- *data << m_strTarget;
}
Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, Spell** triggeringContainer, bool skipCheck)
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index e9e6fe626a2..53123d49288 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -60,13 +60,14 @@ enum SpellCastTargetFlags
TARGET_FLAG_OBJECT = 0x00000800, // pguid, 2 spells
TARGET_FLAG_TRADE_ITEM = 0x00001000, // pguid, 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_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_UNK3 = 0x00040000, //
- TARGET_FLAG_UNK4 = 0x00080000 // uint32, loop { vec3, guid -> if guid == 0 break }
+ TARGET_FLAG_UNK19 = 0x00040000, //
+ TARGET_FLAG_UNK20 = 0x00080000 // uint32, loop { vec3, guid -> if guid == 0 break }
};
+#define MAX_TARGET_FLAGS 21
enum SpellCastFlags
{
@@ -93,7 +94,16 @@ enum SpellCastFlags
CAST_FLAG_UNKNOWN_20 = 0x00080000,
CAST_FLAG_UNKNOWN_21 = 0x00100000,
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