diff options
-rw-r--r-- | src/server/game/Server/Packets/SpellPackets.cpp | 72 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 115 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.h | 3 |
3 files changed, 55 insertions, 135 deletions
diff --git a/src/server/game/Server/Packets/SpellPackets.cpp b/src/server/game/Server/Packets/SpellPackets.cpp index b88f876dd49..50251c71c8b 100644 --- a/src/server/game/Server/Packets/SpellPackets.cpp +++ b/src/server/game/Server/Packets/SpellPackets.cpp @@ -235,9 +235,9 @@ void WorldPackets::Spells::UseItem::Read() ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::TargetLocation const& targetLocation) { data << targetLocation.Transport; - data << targetLocation.Location.m_positionX; - data << targetLocation.Location.m_positionY; - data << targetLocation.Location.m_positionZ; + data << float(targetLocation.Location.m_positionX); + data << float(targetLocation.Location.m_positionY); + data << float(targetLocation.Location.m_positionZ); return data; } @@ -277,15 +277,15 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellMissStatus c ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellPowerData const& spellPowerData) { - data << spellPowerData.Cost; - data << spellPowerData.Type; + data << int32(spellPowerData.Cost); + data << int8(spellPowerData.Type); return data; } ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::RuneData const& runeData) { - data << runeData.Start; - data << runeData.Count; + data << uint8(runeData.Start); + data << uint8(runeData.Count); data.WriteBits(runeData.Cooldowns.size(), 3); data.FlushBits(); @@ -298,36 +298,36 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::RuneData const& r ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::MissileTrajectoryResult const& missileTrajectory) { - data << missileTrajectory.TravelTime; - data << missileTrajectory.Pitch; + data << uint32(missileTrajectory.TravelTime); + data << float(missileTrajectory.Pitch); return data; } ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellAmmo const& spellAmmo) { - data << spellAmmo.DisplayID; - data << spellAmmo.InventoryType; + data << int32(spellAmmo.DisplayID); + data << int8(spellAmmo.InventoryType); return data; } ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::ProjectileVisualData const& projectileVisual) { - data << projectileVisual.ID[0]; - data << projectileVisual.ID[1]; + data << int32(projectileVisual.ID[0]); + data << int32(projectileVisual.ID[1]); return data; } ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::CreatureImmunities const& immunities) { - data << immunities.School; - data << immunities.Value; + data << int32(immunities.School); + data << int32(immunities.Value); return data; } ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellHealPrediction const& spellPred) { - data << spellPred.Points; - data << spellPred.Type; + data << int32(spellPred.Points); + data << uint8(spellPred.Type); data << spellPred.BeaconGUID; return data; } @@ -336,10 +336,10 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellCastData con { data << spellCastData.CasterGUID; data << spellCastData.CasterUnit; - data << spellCastData.CastID; - data << spellCastData.SpellID; - data << spellCastData.CastFlags; - data << spellCastData.CastTime; + data << uint8(spellCastData.CastID); + data << int32(spellCastData.SpellID); + data << uint32(spellCastData.CastFlags); + data << uint32(spellCastData.CastTime); data << uint32(spellCastData.HitTargets.size()); data << uint32(spellCastData.MissTargets.size()); data << uint32(spellCastData.MissStatus.size()); @@ -347,7 +347,7 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellCastData con data << uint32(spellCastData.RemainingPower.size()); data << spellCastData.MissileTrajectory; data << spellCastData.Ammo; - data << spellCastData.DestLocSpellCastIndex; + data << uint8(spellCastData.DestLocSpellCastIndex); data << uint32(spellCastData.TargetPoints.size()); data << spellCastData.Immunities; data << spellCastData.Predict; @@ -416,9 +416,9 @@ WorldPacket const* WorldPackets::Spells::LearnedSpells::Write() WorldPacket const* WorldPackets::Spells::SpellFailure::Write() { _worldPacket << CasterUnit; - _worldPacket << CastID; - _worldPacket << SpellID; - _worldPacket << Reason; + _worldPacket << uint8(CastID); + _worldPacket << int32(SpellID); + _worldPacket << uint8(Reason); return &_worldPacket; } @@ -426,35 +426,35 @@ WorldPacket const* WorldPackets::Spells::SpellFailure::Write() WorldPacket const* WorldPackets::Spells::SpellFailedOther::Write() { _worldPacket << CasterUnit; - _worldPacket << CastID; - _worldPacket << SpellID; - _worldPacket << Reason; + _worldPacket << uint8(CastID); + _worldPacket << uint32(SpellID); + _worldPacket << uint8(Reason); return &_worldPacket; } WorldPacket const* WorldPackets::Spells::CastFailed::Write() { - _worldPacket << SpellID; - _worldPacket << Reason; - _worldPacket << FailedArg1; - _worldPacket << FailedArg2; - _worldPacket << CastID; + _worldPacket << int32(SpellID); + _worldPacket << int32(Reason); + _worldPacket << int32(FailedArg1); + _worldPacket << int32(FailedArg2); + _worldPacket << uint8(CastID); return &_worldPacket; } ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellModifierData const& spellModifierData) { - data << spellModifierData.ModifierValue; - data << spellModifierData.ClassIndex; + data << float(spellModifierData.ModifierValue); + data << uint8(spellModifierData.ClassIndex); return data; } ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellModifier const& spellModifier) { - data << spellModifier.ModIndex; + data << uint8(spellModifier.ModIndex); data << uint32(spellModifier.ModifierData.size()); for (WorldPackets::Spells::SpellModifierData const& modData : spellModifier.ModifierData) data << modData; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 46becb8139c..60c29ee9d70 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4075,9 +4075,7 @@ void Spell::SendSpellGo() castData.CastFlags = castFlags; castData.CastTime = getMSTime(); - /// @todo implement multiple targets - if (m_targets.GetUnitTarget()) - castData.HitTargets.push_back(m_targets.GetUnitTargetGUID()); + WriteSpellGoTargets(castData); m_targets.Write(castData.Target); @@ -4122,86 +4120,12 @@ void Spell::SendSpellGo() castData.MissileTrajectory.TravelTime = m_delayMoment; castData.MissileTrajectory.Pitch = m_targets.GetPitch(); } - /*WorldPacket data(SMSG_SPELL_GO, 50); // guess size - - if (m_CastItem) - data << m_CastItem->GetPackGUID(); - else - data << m_caster->GetPackGUID(); - - data << m_caster->GetPackGUID(); - data << uint8(m_cast_count); // pending spell cast? - data << uint32(m_spellInfo->Id); // spellId - data << uint32(castFlags); // cast flags - data << uint32(m_timer); - data << uint32(getMSTime()); // timestamp - - WriteSpellGoTargets(&data); - - //m_targets.Write(data); - - if (castFlags & CAST_FLAG_POWER_LEFT_SELF) - data << uint32(m_caster->GetPower((Powers)m_spellInfo->PowerType)); - - if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list - { - /// @todo There is a crash caused by a spell with CAST_FLAG_RUNE_LIST cast by a creature - //The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster - if (Player* player = m_caster->ToPlayer()) - { - data << uint8(m_runesState); // runes state before - data << uint8(player->GetRunesState()); // runes state after - for (uint8 i = 0; i < MAX_RUNES; ++i) - { - // float casts ensure the division is performed on floats as we need float result - float baseCd = float(player->GetRuneBaseCooldown(i)); - data << uint8((baseCd - float(player->GetRuneCooldown(i))) / baseCd * 255); // rune cooldown passed - } - } - } - - if (castFlags & CAST_FLAG_ADJUST_MISSILE) - { - data << m_targets.GetElevation(); - data << uint32(m_delayMoment); - } - - if (castFlags & CAST_FLAG_PROJECTILE) - { - data << uint32(0); // Ammo display ID - data << uint32(0); // Inventory Type - } - - if (castFlags & CAST_FLAG_VISUAL_CHAIN) - { - data << uint32(0); - data << uint32(0); - } - - if (m_targets.GetTargetMask() & TARGET_FLAG_DEST_LOCATION) - { - data << uint8(0); - } - - if (m_targets.GetTargetMask() & TARGET_FLAG_EXTRA_TARGETS) - { - data << uint32(0); // Extra targets count - - for (uint8 i = 0; i < count; ++i) - { - data << float(0); // Target Position X - data << float(0); // Target Position Y - data << float(0); // Target Position Z - data << uint64(0); // Target Guid - } - - }*/ m_caster->SendMessageToSet(packet.Write(), true); } /// Writes miss and hit targets for a SMSG_SPELL_GO packet -void Spell::WriteSpellGoTargets(WorldPacket* data) +void Spell::WriteSpellGoTargets(WorldPackets::Spells::SpellCastData& data) { // This function also fill data for channeled spells: // m_needAliveTargetMask req for stop channelig if one target die @@ -4219,44 +4143,39 @@ void Spell::WriteSpellGoTargets(WorldPacket* data) // correct count for both hit and miss). uint32 hit = 0; - size_t hitPos = data->wpos(); - *data << (uint8)0; // placeholder - for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end() && hit < 255; ++ihit) + + for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { if ((*ihit).missCondition == SPELL_MISS_NONE) // Add only hits { - *data << (ihit->targetGUID); - m_channelTargetEffectMask |=ihit->effectMask; - ++hit; + data.HitTargets.push_back(ihit->targetGUID); + m_channelTargetEffectMask |= ihit->effectMask; } } - for (std::list<GOTargetInfo>::const_iterator ighit = m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end() && hit < 255; ++ighit) + for (std::list<GOTargetInfo>::const_iterator ighit = m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end(); ++ighit) { - *data << (ighit->targetGUID); // Always hits - ++hit; + data.HitTargets.push_back(ighit->targetGUID); // Always hits } - uint32 miss = 0; - size_t missPos = data->wpos(); - *data << (uint8)0; // placeholder - for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end() && miss < 255; ++ihit) + for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { if (ihit->missCondition != SPELL_MISS_NONE) // Add only miss { - *data << (ihit->targetGUID); - *data << uint8(ihit->missCondition); + data.MissTargets.push_back(ihit->targetGUID); + + WorldPackets::Spells::SpellMissStatus missStatus; + missStatus.Reason = ihit->missCondition; if (ihit->missCondition == SPELL_MISS_REFLECT) - *data << uint8(ihit->reflectResult); - ++miss; + missStatus.ReflectStatus = ihit->reflectResult; + + data.MissStatus.push_back(missStatus); } } + // Reset m_needAliveTargetMask for non channeled spell if (!m_spellInfo->IsChanneled()) m_channelTargetEffectMask = 0; - - data->put<uint8>(hitPos, (uint8)hit); - data->put<uint8>(missPos, (uint8)miss); } void Spell::SendLogExecute() diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index ac2e909b97f..ebbc429d511 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -31,6 +31,7 @@ namespace WorldPackets { struct SpellCastRequest; struct SpellTargetData; + struct SpellCastData; } } @@ -437,7 +438,7 @@ class Spell void setState(uint32 state) { m_spellState = state; } void DoCreateItem(uint32 i, uint32 itemtype); - void WriteSpellGoTargets(WorldPacket* data); + void WriteSpellGoTargets(WorldPackets::Spells::SpellCastData& data); bool CheckEffectTarget(Unit const* target, SpellEffectInfo const* effect, Position const* losPosition) const; bool CheckEffectTarget(GameObject const* target, SpellEffectInfo const* effect) const; |