Core/PacketIO: Updated and enabled SMSG_SPELL_CHANNEL_START and SMSG_SPELL_CHANNEL_UPDATE

This commit is contained in:
Shauren
2015-04-04 16:04:40 +02:00
parent e2abc9edf8
commit b66d2da2c7
6 changed files with 99 additions and 41 deletions

View File

@@ -20,6 +20,7 @@
#include "DatabaseEnv.h"
#include "Log.h"
#include "WorldPacket.h"
#include "SpellPackets.h"
#include "ObjectMgr.h"
#include "SpellMgr.h"
#include "Pet.h"
@@ -297,15 +298,16 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
/// @todo pets should be summoned from real cast instead of just faking it?
if (summonSpellId)
{
WorldPacket data(SMSG_SPELL_GO, (8+8+4+4+2));
data << owner->GetPackGUID();
data << owner->GetPackGUID();
data << uint8(0);
data << uint32(summonSpellId);
data << uint32(256); // CAST_FLAG_UNKNOWN3
data << uint32(0);
data << uint32(getMSTime());
owner->SendMessageToSet(&data, true);
WorldPackets::Spells::SpellGo spellGo;
WorldPackets::Spells::SpellCastData& castData = spellGo.Cast;
castData.CasterGUID = owner->GetGUID();
castData.CasterUnit = owner->GetGUID();
castData.SpellID = summonSpellId;
castData.CastFlags = CAST_FLAG_UNKNOWN_9;
castData.CastTime = getMSTime();
owner->SendMessageToSet(spellGo.Write(), true);
}
owner->SetMinion(this, true);

View File

@@ -632,3 +632,42 @@ void WorldPackets::Spells::OpenItem::Read()
_worldPacket >> Slot
>> PackSlot;
}
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellChannelStartInterruptImmunities const& interruptImmunities)
{
data << int32(interruptImmunities.SchoolImmunities);
data << int32(interruptImmunities.Immunities);
return data;
}
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellTargetedHealPrediction const& targetedHealPrediction)
{
data << targetedHealPrediction.TargetGUID;
data << targetedHealPrediction.Predict;
return data;
}
WorldPacket const* WorldPackets::Spells::SpellChannelStart::Write()
{
_worldPacket << CasterGUID;
_worldPacket << int32(SpellID);
_worldPacket << uint32(ChannelDuration);
_worldPacket.WriteBit(InterruptImmunities.HasValue);
_worldPacket.WriteBit(HealPrediction.HasValue);
_worldPacket.FlushBits();
if (InterruptImmunities.HasValue)
_worldPacket << InterruptImmunities.Value;
if (HealPrediction.HasValue)
_worldPacket << HealPrediction.Value;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Spells::SpellChannelUpdate::Write()
{
_worldPacket << CasterGUID;
_worldPacket << int32(TimeRemaining);
return &_worldPacket;
}

View File

@@ -599,6 +599,43 @@ namespace WorldPackets
uint8 Slot = 0;
uint8 PackSlot = 0;
};
struct SpellChannelStartInterruptImmunities
{
int32 SchoolImmunities = 0;
int32 Immunities = 0;
};
struct SpellTargetedHealPrediction
{
ObjectGuid TargetGUID;
SpellHealPrediction Predict;
};
class SpellChannelStart final : public ServerPacket
{
public:
SpellChannelStart() : ServerPacket(SMSG_SPELL_CHANNEL_START, 4 + 16 + 4) { }
WorldPacket const* Write() override;
int32 SpellID = 0;
Optional<SpellChannelStartInterruptImmunities> InterruptImmunities;
ObjectGuid CasterGUID;
Optional<SpellTargetedHealPrediction> HealPrediction;
uint32 ChannelDuration = 0;
};
class SpellChannelUpdate final : public ServerPacket
{
public:
SpellChannelUpdate() : ServerPacket(SMSG_SPELL_CHANNEL_UPDATE, 16 + 4) { }
WorldPacket const* Write() override;
ObjectGuid CasterGUID;
int32 TimeRemaining = 0;
};
}
}

View File

@@ -1624,8 +1624,8 @@ void OpcodeTable::Initialize()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SOCKET_GEMS, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SOR_START_EXPERIENCE_INCOMPLETE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPECIAL_MOUNT_ANIM, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_CHANNEL_START, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_CHANNEL_UPDATE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_CHANNEL_START, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_CHANNEL_UPDATE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_COOLDOWN, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_DAMAGE_SHIELD, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_DELAYED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);

View File

@@ -4245,11 +4245,10 @@ void Spell::SendChannelUpdate(uint32 time)
m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, 0);
}
WorldPacket data(SMSG_SPELL_CHANNEL_UPDATE, 8 + 4);
data << m_caster->GetPackGUID();
data << uint32(time);
m_caster->SendMessageToSet(&data, true);
WorldPackets::Spells::SpellChannelUpdate spellChannelUpdate;
spellChannelUpdate.CasterGUID = m_caster->GetGUID();
spellChannelUpdate.TimeRemaining = time;
m_caster->SendMessageToSet(spellChannelUpdate.Write(), true);
}
void Spell::SendChannelStart(uint32 duration)
@@ -4259,30 +4258,11 @@ void Spell::SendChannelStart(uint32 duration)
if (m_UniqueTargetInfo.size() + m_UniqueGOTargetInfo.size() == 1) // this is for TARGET_SELECT_CATEGORY_NEARBY
channelTarget = !m_UniqueTargetInfo.empty() ? m_UniqueTargetInfo.front().targetGUID : m_UniqueGOTargetInfo.front().targetGUID;
WorldPacket data(SMSG_SPELL_CHANNEL_START, (8 + 4 + 4));
data << m_caster->GetPackGUID();
data << uint32(m_spellInfo->Id);
data << uint32(duration);
data << uint8(0); // immunity (castflag & 0x04000000)
/*
if (immunity)
{
data << uint32(); // CastSchoolImmunities
data << uint32(); // CastImmunities
}
*/
data << uint8(0); // healPrediction (castflag & 0x40000000)
/*
if (healPrediction)
{
data.appendPackGUID(channelTarget); // target packguid
data << uint32(); // spellid
data << uint8(0); // unk3
if (unk3 == 2)
data.append(); // unk packed guid (unused ?)
}
*/
m_caster->SendMessageToSet(&data, true);
WorldPackets::Spells::SpellChannelStart spellChannelStart;
spellChannelStart.CasterGUID = m_caster->GetGUID();
spellChannelStart.SpellID = m_spellInfo->Id;
spellChannelStart.ChannelDuration = duration;
m_caster->SendMessageToSet(spellChannelStart.Write(), true);
m_timer = duration;
if (!channelTarget.IsEmpty())

View File

@@ -524,7 +524,7 @@ class Spell
void SetSpellValue(SpellValueMod mod, int32 value);
SpellEffectInfoVector GetEffects() const { return _effects; }
SpellEffectInfoVector const& GetEffects() const { return _effects; }
SpellEffectInfo const* GetEffect(uint32 index) const
{
if (index >= _effects.size())