diff --git a/src/server/game/Server/Packets/SpellPackets.cpp b/src/server/game/Server/Packets/SpellPackets.cpp index c4570565662..b57ef1d2580 100644 --- a/src/server/game/Server/Packets/SpellPackets.cpp +++ b/src/server/game/Server/Packets/SpellPackets.cpp @@ -121,7 +121,21 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellCastData con data << uint32(spellCastData.CastTime); if (spellCastData.HitInfo) + { + // Hit and miss target counts are both uint8, that limits us to 255 targets for each + // sending more than 255 targets crashes the client (since count sent would be wrong) + // Spells like 40647 (with a huge radius) can easily reach this limit (spell might need + // target conditions but we still need to limit the number of targets sent and keeping + // correct count for both hit and miss). + static std::size_t const PACKET_TARGET_LIMIT = std::numeric_limits::max(); + if (spellCastData.HitInfo->HitTargets.size() > PACKET_TARGET_LIMIT) + spellCastData.HitInfo->HitTargets.resize(PACKET_TARGET_LIMIT); + + if (spellCastData.HitInfo->MissStatus.size() > PACKET_TARGET_LIMIT) + spellCastData.HitInfo->MissStatus.resize(PACKET_TARGET_LIMIT); + data << *spellCastData.HitInfo; + } data << spellCastData.Target; diff --git a/src/server/game/Server/Packets/SpellPackets.h b/src/server/game/Server/Packets/SpellPackets.h index 56d65be4eca..178f2643c73 100644 --- a/src/server/game/Server/Packets/SpellPackets.h +++ b/src/server/game/Server/Packets/SpellPackets.h @@ -109,7 +109,7 @@ namespace WorldPackets uint32 CastFlagsEx = 0; uint32 CastTime = 0; SpellTargetData Target; - Optional HitInfo; + mutable Optional HitInfo; Optional DestLocSpellCastIndex; Optional Predict; Optional Immunities;