TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SpellPackets.cpp File Reference
#include "SpellPackets.h"
#include "MovementPackets.h"
+ Include dependency graph for SpellPackets.cpp:

Functions

ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellCastLogData const &spellCastLogData)
 
ByteBufferoperator>> (ByteBuffer &buffer, Optional< WorldPackets::Spells::TargetLocation > &location)
 
ByteBufferoperator>> (ByteBuffer &buffer, WorldPackets::Spells::SpellTargetData &targetData)
 
ByteBufferoperator>> (ByteBuffer &buffer, WorldPackets::Spells::MissileTrajectoryRequest &trajectory)
 
ByteBufferoperator>> (ByteBuffer &buffer, WorldPackets::Spells::SpellCastRequest &request)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::TargetLocation const &targetLocation)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellTargetData const &spellTargetData)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellMissStatus const &spellMissStatus)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellPowerData const &spellPowerData)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::RuneData const &runeData)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::MissileTrajectoryResult const &missileTrajectory)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellAmmo const &spellAmmo)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::CreatureImmunities const &immunities)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellHealPrediction const &spellPred)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellCastData const &spellCastData)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellModifierData const &spellModifierData)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellModifier const &spellModifier)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellCooldownStruct const &cooldown)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellHistoryEntry const &historyEntry)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellChargeEntry const &chargeEntry)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellChannelStartInterruptImmunities const &interruptImmunities)
 
ByteBufferoperator<< (ByteBuffer &data, WorldPackets::Spells::SpellTargetedHealPrediction const &targetedHealPrediction)
 

Function Documentation

ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellCastLogData const spellCastLogData 
)
100 {
101  data << spellCastLogData.Health;
102  data << spellCastLogData.AttackPower;
103  data << spellCastLogData.SpellPower;
104  data << int32(spellCastLogData.PowerData.size());
105  for (WorldPackets::Spells::SpellLogPowerData const& powerData : spellCastLogData.PowerData)
106  {
107  data << powerData.PowerType;
108  data << powerData.Amount;
109  }
110  data.WriteBit(false);
111  // data << float // Unk data if bit is true
112  data.FlushBits();
113 
114  return data;
115 }
Definition: SpellPackets.h:166
int32 PowerType
Definition: SpellPackets.h:170
void FlushBits()
Definition: ByteBuffer.h:150
bool WriteBit(uint32 bit)
Definition: ByteBuffer.h:170
int32_t int32
Definition: g3dmath.h:167
int32 Amount
Definition: SpellPackets.h:171

+ Here is the call graph for this function:

ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::TargetLocation const targetLocation 
)
261 {
262  data << targetLocation.Transport;
263  data << float(targetLocation.Location.m_positionX);
264  data << float(targetLocation.Location.m_positionY);
265  data << float(targetLocation.Location.m_positionZ);
266  return data;
267 }
ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellTargetData const spellTargetData 
)
270 {
271  data.WriteBits(spellTargetData.Flags, 23);
272  data.WriteBit(spellTargetData.SrcLocation.is_initialized());
273  data.WriteBit(spellTargetData.DstLocation.is_initialized());
274  data.WriteBit(spellTargetData.Orientation.is_initialized());
275  data.WriteBits(spellTargetData.Name.size(), 7);
276  data.FlushBits();
277 
278  data << spellTargetData.Unit;
279  data << spellTargetData.Item;
280 
281  if (spellTargetData.SrcLocation)
282  data << *spellTargetData.SrcLocation;
283 
284  if (spellTargetData.DstLocation)
285  data << *spellTargetData.DstLocation;
286 
287  if (spellTargetData.Orientation)
288  data << *spellTargetData.Orientation;
289 
290  data.WriteString(spellTargetData.Name);
291 
292  return data;
293 }
void FlushBits()
Definition: ByteBuffer.h:150
bool WriteBit(uint32 bit)
Definition: ByteBuffer.h:170
void WriteString(std::string const &str)
Definition: ByteBuffer.h:540
void WriteBits(T value, int32 bits)
Definition: ByteBuffer.h:198

+ Here is the call graph for this function:

ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellMissStatus const spellMissStatus 
)
296 {
297  data.WriteBits(spellMissStatus.Reason, 4);
298  data.WriteBits(spellMissStatus.ReflectStatus, 4);
299  // No need to flush bits as we written exactly 8 bits (1 byte)
300  return data;
301 }
void WriteBits(T value, int32 bits)
Definition: ByteBuffer.h:198

+ Here is the call graph for this function:

ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellPowerData const spellPowerData 
)
304 {
305  data << int32(spellPowerData.Cost);
306  data << int8(spellPowerData.Type);
307  return data;
308 }
int8_t int8
Definition: g3dmath.h:163
int32_t int32
Definition: g3dmath.h:167
ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::RuneData const runeData 
)
311 {
312  data << uint8(runeData.Start);
313  data << uint8(runeData.Count);
314 
315  data.WriteBits(runeData.Cooldowns.size(), 3);
316  data.FlushBits();
317 
318  for (uint8 cd : runeData.Cooldowns)
319  data << cd;
320 
321  return data;
322 }
void FlushBits()
Definition: ByteBuffer.h:150
uint8_t uint8
Definition: g3dmath.h:164
uint8_t uint8
Definition: Define.h:152
void WriteBits(T value, int32 bits)
Definition: ByteBuffer.h:198

+ Here is the call graph for this function:

ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::MissileTrajectoryResult const missileTrajectory 
)
325 {
326  data << uint32(missileTrajectory.TravelTime);
327  data << float(missileTrajectory.Pitch);
328  return data;
329 }
uint32_t uint32
Definition: g3dmath.h:168
ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellAmmo const spellAmmo 
)
332 {
333  data << int32(spellAmmo.DisplayID);
334  data << int8(spellAmmo.InventoryType);
335  return data;
336 }
int8_t int8
Definition: g3dmath.h:163
int32_t int32
Definition: g3dmath.h:167
ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::CreatureImmunities const immunities 
)
339 {
340  data << int32(immunities.School);
341  data << int32(immunities.Value);
342  return data;
343 }
int32_t int32
Definition: g3dmath.h:167
ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellHealPrediction const spellPred 
)
346 {
347  data << int32(spellPred.Points);
348  data << uint8(spellPred.Type);
349  data << spellPred.BeaconGUID;
350  return data;
351 }
uint8_t uint8
Definition: g3dmath.h:164
int32_t int32
Definition: g3dmath.h:167
ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellCastData const spellCastData 
)
354 {
355  data << spellCastData.CasterGUID;
356  data << spellCastData.CasterUnit;
357  data << uint8(spellCastData.CastID);
358  data << int32(spellCastData.SpellID);
359  data << uint32(spellCastData.SpellXSpellVisualID);
360  data << uint32(spellCastData.CastFlags);
361  data << uint32(spellCastData.CastTime);
362  data << uint32(spellCastData.HitTargets.size());
363  data << uint32(spellCastData.MissTargets.size());
364  data << uint32(spellCastData.MissStatus.size());
365  data << spellCastData.Target;
366  data << uint32(spellCastData.RemainingPower.size());
367  data << spellCastData.MissileTrajectory;
368  data << spellCastData.Ammo;
369  data << uint8(spellCastData.DestLocSpellCastIndex);
370  data << uint32(spellCastData.TargetPoints.size());
371  data << spellCastData.Immunities;
372  data << spellCastData.Predict;
373 
374  for (ObjectGuid const& target : spellCastData.HitTargets)
375  data << target;
376 
377  for (ObjectGuid const& target : spellCastData.MissTargets)
378  data << target;
379 
380  for (WorldPackets::Spells::SpellMissStatus const& status : spellCastData.MissStatus)
381  data << status;
382 
383  for (WorldPackets::Spells::SpellPowerData const& power : spellCastData.RemainingPower)
384  data << power;
385 
386  for (WorldPackets::Spells::TargetLocation const& targetLoc : spellCastData.TargetPoints)
387  data << targetLoc;
388 
389  data.WriteBits(spellCastData.CastFlagsEx, 20);
390  data.WriteBit(spellCastData.RemainingRunes.is_initialized());
391  data.FlushBits();
392 
393  if (spellCastData.RemainingRunes)
394  data << *spellCastData.RemainingRunes;
395 
396  return data;
397 }
void FlushBits()
Definition: ByteBuffer.h:150
Definition: SpellPackets.h:217
bool WriteBit(uint32 bit)
Definition: ByteBuffer.h:170
uint8_t uint8
Definition: g3dmath.h:164
Definition: SpellPackets.h:295
int32_t int32
Definition: g3dmath.h:167
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
Definition: SpellPackets.h:301
void WriteBits(T value, int32 bits)
Definition: ByteBuffer.h:198

+ Here is the call graph for this function:

ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellModifierData const spellModifierData 
)
464 {
465  data << float(spellModifierData.ModifierValue);
466  data << uint8(spellModifierData.ClassIndex);
467 
468  return data;
469 }
uint8_t uint8
Definition: g3dmath.h:164
ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellModifier const spellModifier 
)
472 {
473  data << uint8(spellModifier.ModIndex);
474  data << uint32(spellModifier.ModifierData.size());
475  for (WorldPackets::Spells::SpellModifierData const& modData : spellModifier.ModifierData)
476  data << modData;
477 
478  return data;
479 }
Definition: SpellPackets.h:436
uint8_t uint8
Definition: g3dmath.h:164
uint32_t uint32
Definition: g3dmath.h:168
ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellCooldownStruct const cooldown 
)
544 {
545  data << uint32(cooldown.SrecID);
546  data << uint32(cooldown.ForcedCooldown);
547  return data;
548 }
uint32_t uint32
Definition: g3dmath.h:168
ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellHistoryEntry const historyEntry 
)
562 {
563  data << uint32(historyEntry.SpellID);
564  data << uint32(historyEntry.ItemID);
565  data << uint32(historyEntry.Category);
566  data << int32(historyEntry.RecoveryTime);
567  data << int32(historyEntry.CategoryRecoveryTime);
568  data.WriteBit(historyEntry.unused622_1.is_initialized());
569  data.WriteBit(historyEntry.unused622_2.is_initialized());
570  data.WriteBit(historyEntry.OnHold);
571  if (historyEntry.unused622_1)
572  data << uint32(*historyEntry.unused622_1);
573  if (historyEntry.unused622_2)
574  data << uint32(*historyEntry.unused622_2);
575  data.FlushBits();
576 
577  return data;
578 }
void FlushBits()
Definition: ByteBuffer.h:150
bool WriteBit(uint32 bit)
Definition: ByteBuffer.h:170
int32_t int32
Definition: g3dmath.h:167
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellChargeEntry const chargeEntry 
)
618 {
619  data << uint32(chargeEntry.Category);
620  data << uint32(chargeEntry.NextRecoveryTime);
621  data << uint8(chargeEntry.ConsumedCharges);
622  return data;
623 }
uint8_t uint8
Definition: g3dmath.h:164
uint32_t uint32
Definition: g3dmath.h:168
ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellChannelStartInterruptImmunities const interruptImmunities 
)
679 {
680  data << int32(interruptImmunities.SchoolImmunities);
681  data << int32(interruptImmunities.Immunities);
682  return data;
683 }
int32_t int32
Definition: g3dmath.h:167
ByteBuffer& operator<< ( ByteBuffer data,
WorldPackets::Spells::SpellTargetedHealPrediction const targetedHealPrediction 
)
686 {
687  data << targetedHealPrediction.TargetGUID;
688  data << targetedHealPrediction.Predict;
689  return data;
690 }
ByteBuffer& operator>> ( ByteBuffer buffer,
Optional< WorldPackets::Spells::TargetLocation > &  location 
)
164 {
165  location = boost::in_place();
166  buffer >> location->Transport;
167  buffer >> location->Location.m_positionX;
168  buffer >> location->Location.m_positionY;
169  buffer >> location->Location.m_positionZ;
170  return buffer;
171 }
ByteBuffer& operator>> ( ByteBuffer buffer,
WorldPackets::Spells::SpellTargetData targetData 
)
174 {
175  buffer.ResetBitPos();
176 
177  targetData.Flags = buffer.ReadBits(23);
178  bool const hasSrcLocation = buffer.ReadBit();
179  bool const hasDstLocation = buffer.ReadBit();
180  bool const hasOrientation = buffer.ReadBit();
181  uint32 nameLength = buffer.ReadBits(7);
182 
183  buffer >> targetData.Unit;
184  buffer >> targetData.Item;
185 
186  if (hasSrcLocation)
187  buffer >> targetData.SrcLocation;
188 
189  if (hasDstLocation)
190  buffer >> targetData.DstLocation;
191 
192  if (hasOrientation)
193  targetData.Orientation = buffer.read<float>();
194 
195  targetData.Name = buffer.ReadString(nameLength);
196 
197  return buffer;
198 }
Optional< TargetLocation > SrcLocation
Definition: SpellPackets.h:228
uint32 ReadBits(int32 bits)
Definition: ByteBuffer.h:204
ObjectGuid Unit
Definition: SpellPackets.h:226
void ResetBitPos()
Definition: ByteBuffer.h:161
Optional< TargetLocation > DstLocation
Definition: SpellPackets.h:229
std::string ReadString(uint32 length)
Definition: ByteBuffer.h:524
ObjectGuid Item
Definition: SpellPackets.h:227
uint32 Flags
Definition: SpellPackets.h:225
uint32_t uint32
Definition: Define.h:150
Optional< float > Orientation
Definition: SpellPackets.h:230
std::string Name
Definition: SpellPackets.h:231
bool ReadBit()
Definition: ByteBuffer.h:186
T read()
Definition: ByteBuffer.h:484

+ Here is the call graph for this function:

ByteBuffer& operator>> ( ByteBuffer buffer,
WorldPackets::Spells::MissileTrajectoryRequest trajectory 
)
201 {
202  buffer >> trajectory.Pitch;
203  buffer >> trajectory.Speed;
204  return buffer;
205 }
float Pitch
Definition: SpellPackets.h:236
float Speed
Definition: SpellPackets.h:237
ByteBuffer& operator>> ( ByteBuffer buffer,
WorldPackets::Spells::SpellCastRequest request 
)
208 {
209  buffer >> request.CastID;
210  buffer >> request.Misc[0];
211  buffer >> request.Misc[1];
212  buffer >> request.SpellID;
213  buffer >> request.SpellXSpellVisualID;
214  buffer >> request.Target;
215  buffer >> request.MissileTrajectory;
216  buffer >> request.Charmer;
217 
218  buffer.ResetBitPos();
219  request.SendCastFlags = buffer.ReadBits(5);
220  bool const hasMoveUpdate = buffer.ReadBit();
221  request.Weight.resize(buffer.ReadBits(2));
222 
223  if (hasMoveUpdate)
224  {
225  MovementInfo movementInfo;
226  buffer >> movementInfo;
227  request.MoveUpdate = movementInfo;
228  }
229 
230  for (WorldPackets::Spells::SpellWeight& weight : request.Weight)
231  {
232  buffer.ResetBitPos();
233  weight.Type = buffer.ReadBits(2);
234  buffer >> weight.ID;
235  buffer >> weight.Quantity;
236  }
237 
238  return buffer;
239 }
int32 SpellID
Definition: SpellPackets.h:250
uint32 ReadBits(int32 bits)
Definition: ByteBuffer.h:204
MissileTrajectoryRequest MissileTrajectory
Definition: SpellPackets.h:254
void ResetBitPos()
Definition: ByteBuffer.h:161
Optional< MovementInfo > MoveUpdate
Definition: SpellPackets.h:255
int32 ID
Definition: SpellPackets.h:243
SpellTargetData Target
Definition: SpellPackets.h:253
ObjectGuid Charmer
Definition: SpellPackets.h:257
int32 Misc[2]
Definition: SpellPackets.h:258
uint32 Type
Definition: SpellPackets.h:242
Definition: Object.h:267
uint32 SpellXSpellVisualID
Definition: SpellPackets.h:251
uint8 SendCastFlags
Definition: SpellPackets.h:252
std::vector< SpellWeight > Weight
Definition: SpellPackets.h:256
Definition: SpellPackets.h:240
bool ReadBit()
Definition: ByteBuffer.h:186
uint8 CastID
Definition: SpellPackets.h:249
uint32 Quantity
Definition: SpellPackets.h:244

+ Here is the call graph for this function: