diff options
| author | Shauren <shauren.trinity@gmail.com> | 2015-01-30 23:58:16 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2015-01-30 23:58:16 +0100 |
| commit | 3f28fd304d833eadefff8d343ab45caf8d0575c2 (patch) | |
| tree | d62b98f75a4607bd1e7cdc2944dce7f730981f6d /src/server/game/Server | |
| parent | beb1a06ea56526de838cc8e0de15317660a9ddcf (diff) | |
Core/Spells: Reimplemented automatic spell learning
* Fixed learning/unlearning talents
Diffstat (limited to 'src/server/game/Server')
| -rw-r--r-- | src/server/game/Server/Packets/SpellPackets.cpp | 119 | ||||
| -rw-r--r-- | src/server/game/Server/Packets/SpellPackets.h | 104 | ||||
| -rw-r--r-- | src/server/game/Server/Protocol/Opcodes.cpp | 4 | ||||
| -rw-r--r-- | src/server/game/Server/WorldSession.h | 7 |
4 files changed, 122 insertions, 112 deletions
diff --git a/src/server/game/Server/Packets/SpellPackets.cpp b/src/server/game/Server/Packets/SpellPackets.cpp index 053bb6c504f..6f93fec73f2 100644 --- a/src/server/game/Server/Packets/SpellPackets.cpp +++ b/src/server/game/Server/Packets/SpellPackets.cpp @@ -141,78 +141,91 @@ WorldPacket const* WorldPackets::Spells::AuraUpdate::Write() return &_worldPacket; } -void WorldPackets::Spells::SpellCastRequest::Read() +ByteBuffer& operator>>(ByteBuffer& buffer, WorldPackets::Spells::TargetLocation& location) { - if (_worldPacket.GetOpcode() == CMSG_PET_CAST_SPELL) - _worldPacket >> PetGuid; - - _worldPacket >> CastID; - _worldPacket >> SpellID; - _worldPacket >> Misc; - - _worldPacket.ResetBitPos(); - - TargetFlags = _worldPacket.ReadBits(21); - bool HasSrcLocation = _worldPacket.ReadBit(); - bool HasDstLocation = _worldPacket.ReadBit(); - bool HasOrientation = _worldPacket.ReadBit(); - uint32 NameLen = _worldPacket.ReadBits(7); - - _worldPacket >> UnitGuid; - _worldPacket >> ItemGuid; + buffer >> location.Transport; + buffer >> location.Location.m_positionX; + buffer >> location.Location.m_positionY; + buffer >> location.Location.m_positionZ; + return buffer; +} - if (HasSrcLocation) - { - _worldPacket >> SrcTransportGuid; - _worldPacket >> SrcPos.m_positionX; - _worldPacket >> SrcPos.m_positionY; - _worldPacket >> SrcPos.m_positionZ; - } +ByteBuffer& operator>>(ByteBuffer& buffer, WorldPackets::Spells::SpellTargetData& targetData) +{ + buffer.ResetBitPos(); - if (HasDstLocation) - { - _worldPacket >> DstTransportGuid; - _worldPacket >> DstPos.m_positionX; - _worldPacket >> DstPos.m_positionY; - _worldPacket >> DstPos.m_positionZ; - } + targetData.Flags = buffer.ReadBits(21); + targetData.SrcLocation.HasValue = buffer.ReadBit(); + targetData.DstLocation.HasValue = buffer.ReadBit(); + targetData.Orientation.HasValue = buffer.ReadBit(); + uint32 nameLength = buffer.ReadBits(7); - if (HasOrientation) - _worldPacket >> Orientation; + buffer >> targetData.Unit; + buffer >> targetData.Item; - Name = _worldPacket.ReadString(NameLen); + if (targetData.SrcLocation.HasValue) + buffer >> targetData.SrcLocation.Value; - _worldPacket >> Pitch; - _worldPacket >> Speed; + if (targetData.DstLocation.HasValue) + buffer >> targetData.DstLocation.Value; - _worldPacket >> Guid; + if (targetData.Orientation.HasValue) + buffer >> targetData.Orientation.Value; - _worldPacket.ResetBitPos(); + targetData.Name = buffer.ReadString(nameLength); - SendCastFlags = _worldPacket.ReadBits(5); + return buffer; +} - bool HasMoveUpdate = _worldPacket.ReadBit(); - uint32 SpellWeightCount = _worldPacket.ReadBits(2); +ByteBuffer& operator>>(ByteBuffer& buffer, WorldPackets::Spells::MissileTrajectoryRequest& trajectory) +{ + buffer >> trajectory.Pitch; + buffer >> trajectory.Speed; + return buffer; +} - if (HasMoveUpdate) +ByteBuffer& operator>>(ByteBuffer& buffer, WorldPackets::Spells::SpellCastRequest& request) +{ + buffer >> request.CastID; + buffer >> request.SpellID; + buffer >> request.Misc; + buffer >> request.Target; + buffer >> request.MissileTrajectory; + buffer >> request.Charmer; + + buffer.ResetBitPos(); + request.SendCastFlags = buffer.ReadBits(5); + request.MoveUpdate.HasValue = buffer.ReadBit(); + request.Weight.resize(buffer.ReadBits(2)); + + if (request.MoveUpdate.HasValue) + buffer >> request.MoveUpdate.Value; + + for (WorldPackets::Spells::SpellWeight& weight : request.Weight) { - _worldPacket >> movementInfo; + buffer.ResetBitPos(); + weight.Type = buffer.ReadBits(2); + buffer >> weight.ID; + buffer >> weight.Quantity; } - for (uint32 i = 0; i < SpellWeightCount; ++i) - { - _worldPacket.ResetBitPos(); - SpellWeight unused; - unused.Type = _worldPacket.ReadBits(2); - _worldPacket >> unused.ID; - _worldPacket >> unused.Quantity; - } + return buffer; +} + +void WorldPackets::Spells::CastSpell::Read() +{ + _worldPacket >> Cast; +} + +void WorldPackets::Spells::PetCastSpell::Read() +{ + _worldPacket >> PetGUID; + _worldPacket >> Cast; } ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::TargetLocation const& targetLocation) { data << targetLocation.Transport; - // data << targetLocation.Location.PositionXYZStream(); data << targetLocation.Location.m_positionX; data << targetLocation.Location.m_positionY; data << targetLocation.Location.m_positionZ; diff --git a/src/server/game/Server/Packets/SpellPackets.h b/src/server/game/Server/Packets/SpellPackets.h index fa7b8e0b04a..fa5af7b2882 100644 --- a/src/server/game/Server/Packets/SpellPackets.h +++ b/src/server/game/Server/Packets/SpellPackets.h @@ -155,46 +155,6 @@ namespace WorldPackets std::vector<AuraInfo> Auras; }; - class SpellCastRequest final : public ClientPacket - { - public: - struct SpellWeight - { - uint32 Type = 0; - int32 ID = 0; - uint32 Quantity = 0; - }; - - SpellCastRequest(WorldPacket&& packet) : ClientPacket(std::move(packet)) - { - ASSERT(packet.GetOpcode() == CMSG_CAST_SPELL || packet.GetOpcode() == CMSG_PET_CAST_SPELL); - } - - void Read() override; - - ObjectGuid PetGuid; - uint8 CastID = 0; - uint32 SpellID = 0; - uint32 Misc = 0; - uint32 TargetFlags = 0; - ObjectGuid UnitGuid; - ObjectGuid ItemGuid; - - ObjectGuid SrcTransportGuid; - ObjectGuid DstTransportGuid; - Position SrcPos; - Position DstPos; - float Orientation = 0.0f; - - std::string Name; - float Pitch = 0.0f; - float Speed = 0.0f; - ObjectGuid Guid; - uint32 SendCastFlags = 0; - - MovementInfo movementInfo; - }; - struct TargetLocation { ObjectGuid Transport; @@ -208,10 +168,59 @@ namespace WorldPackets ObjectGuid Item; Optional<TargetLocation> SrcLocation; Optional<TargetLocation> DstLocation; - Optional<float> Orientation; // Not found in JAM structures + Optional<float> Orientation; std::string Name; }; + struct MissileTrajectoryRequest + { + float Pitch = 0.0f; + float Speed = 0.0f; + }; + + struct SpellWeight + { + uint32 Type = 0; + int32 ID = 0; + uint32 Quantity = 0; + }; + + struct SpellCastRequest + { + uint8 CastID = 0; + uint32 SpellID = 0; + uint32 Misc = 0; + uint8 SendCastFlags = 0; + SpellTargetData Target; + MissileTrajectoryRequest MissileTrajectory; + Optional<MovementInfo> MoveUpdate; + std::vector<SpellWeight> Weight; + ObjectGuid Charmer; + }; + + class CastSpell final : public ClientPacket + { + public: + + CastSpell(WorldPacket&& packet) : ClientPacket(CMSG_CAST_SPELL, std::move(packet)) { } + + void Read() override; + + SpellCastRequest Cast; + }; + + class PetCastSpell final : public ClientPacket + { + public: + + PetCastSpell(WorldPacket&& packet) : ClientPacket(CMSG_PET_CAST_SPELL, std::move(packet)) { } + + void Read() override; + + ObjectGuid PetGUID; + SpellCastRequest Cast; + }; + struct SpellMissStatus { uint8 Reason = 0; @@ -392,18 +401,5 @@ namespace WorldPackets } ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellCastLogData const& spellCastLogData); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::TargetLocation const& targetLocation); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellTargetData const& spellTargetData); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellMissStatus const& spellMissStatus); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellPowerData const& spellPowerData); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::RuneData const& runeData); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::MissileTrajectoryResult const& missileTrajectory); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellAmmo const& spellAmmo); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::ProjectileVisualData const& projectileVisual); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::CreatureImmunities const& immunities); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellHealPrediction const& spellPred); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellCastData const& spellCastData); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellModifierData const& spellModifierData); -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellModifier const& spellModifier); #endif // SpellPackets_h__ diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index 49649c2df0c..988a858e83b 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -255,7 +255,7 @@ void OpcodeTable::Initialize() DEFINE_OPCODE_HANDLER_OLD(CMSG_CANCEL_TEMP_ENCHANTMENT, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCancelTempEnchantmentOpcode); DEFINE_HANDLER(CMSG_CANCEL_TRADE, STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT, PROCESS_THREADUNSAFE, WorldPackets::Trade::CancelTrade, &WorldSession::HandleCancelTradeOpcode); DEFINE_OPCODE_HANDLER_OLD(CMSG_CAN_DUEL, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); - DEFINE_HANDLER(CMSG_CAST_SPELL, STATUS_LOGGEDIN, PROCESS_THREADSAFE, WorldPackets::Spells::SpellCastRequest, &WorldSession::HandleCastSpellOpcode); + DEFINE_HANDLER(CMSG_CAST_SPELL, STATUS_LOGGEDIN, PROCESS_THREADSAFE, WorldPackets::Spells::CastSpell, &WorldSession::HandleCastSpellOpcode); DEFINE_OPCODE_HANDLER_OLD(CMSG_CHALLENGE_MODE_REQUEST_LEADERS, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); DEFINE_OPCODE_HANDLER_OLD(CMSG_CHALLENGE_MODE_REQUEST_MAP_STATS, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); DEFINE_OPCODE_HANDLER_OLD(CMSG_CHANGE_BAG_SLOT_FLAG, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); @@ -650,7 +650,7 @@ void OpcodeTable::Initialize() DEFINE_OPCODE_HANDLER_OLD(CMSG_PET_BATTLE_REQUEST_WILD, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); DEFINE_OPCODE_HANDLER_OLD(CMSG_PET_BATTLE_SCRIPT_ERROR_NOTIFY, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); DEFINE_OPCODE_HANDLER_OLD(CMSG_PET_CANCEL_AURA, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandlePetCancelAuraOpcode ); - DEFINE_HANDLER(CMSG_PET_CAST_SPELL, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Spells::SpellCastRequest, &WorldSession::HandlePetCastSpellOpcode); + DEFINE_HANDLER(CMSG_PET_CAST_SPELL, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Spells::PetCastSpell, &WorldSession::HandlePetCastSpellOpcode); DEFINE_OPCODE_HANDLER_OLD(CMSG_PET_LEARN_TALENT, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandlePetLearnTalent ); DEFINE_OPCODE_HANDLER_OLD(CMSG_PET_NAME_CACHE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); DEFINE_OPCODE_HANDLER_OLD(CMSG_PET_NAME_QUERY, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandlePetNameQuery ); diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 5c9c05bbe92..291ba0a9f66 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -247,7 +247,8 @@ namespace WorldPackets namespace Spells { class CancelAura; - class SpellCastRequest; + class CastSpell; + class PetCastSpell; class SetActionButton; } @@ -947,7 +948,7 @@ class WorldSession void HandleUseItemOpcode(WorldPacket& recvPacket); void HandleOpenItemOpcode(WorldPacket& recvPacket); - void HandleCastSpellOpcode(WorldPackets::Spells::SpellCastRequest& castRequest); + void HandleCastSpellOpcode(WorldPackets::Spells::CastSpell& castRequest); void HandleCancelCastOpcode(WorldPacket& recvPacket); void HandleCancelAuraOpcode(WorldPackets::Spells::CancelAura& cancelAura); void HandleCancelGrowthAuraOpcode(WorldPacket& recvPacket); @@ -1030,7 +1031,7 @@ class WorldSession void HandlePetRename(WorldPacket& recvData); void HandlePetCancelAuraOpcode(WorldPacket& recvPacket); void HandlePetSpellAutocastOpcode(WorldPacket& recvPacket); - void HandlePetCastSpellOpcode(WorldPackets::Spells::SpellCastRequest& castRequest); + void HandlePetCastSpellOpcode(WorldPackets::Spells::PetCastSpell& castRequest); void HandlePetLearnTalent(WorldPacket& recvPacket); void HandleSetActionBarToggles(WorldPacket& recvData); |
