Core/Spells: restored accidentally dropped spell cast target limit to fix client crashes when hitting more than 255 targets with a single spell

This commit is contained in:
Ovahlord
2021-02-19 18:31:45 +01:00
parent 3d20971d01
commit bcf9476e96
2 changed files with 15 additions and 1 deletions

View File

@@ -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<uint8>::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;

View File

@@ -109,7 +109,7 @@ namespace WorldPackets
uint32 CastFlagsEx = 0;
uint32 CastTime = 0;
SpellTargetData Target;
Optional<SpellHitInfo> HitInfo;
mutable Optional<SpellHitInfo> HitInfo;
Optional<uint8> DestLocSpellCastIndex;
Optional<SpellHealPrediction> Predict;
Optional<CreatureImmunities> Immunities;