diff options
| author | joschiwald <joschiwald.trinity@gmail.com> | 2014-11-15 16:22:32 +0100 |
|---|---|---|
| committer | joschiwald <joschiwald.trinity@gmail.com> | 2014-11-15 16:22:32 +0100 |
| commit | 96fa1eb5ecb6667b4150b1d9bffa7efed79fedd8 (patch) | |
| tree | 9485396a939f556900700e1da43f8c0b5e7b80e8 /src/server/game/Server/Packets | |
| parent | c375748b7636fe88f1daf37197dc9da3d4a674a1 (diff) | |
Core/Packets: added few channel packet structs
Diffstat (limited to 'src/server/game/Server/Packets')
| -rw-r--r-- | src/server/game/Server/Packets/ChannelPackets.cpp | 78 | ||||
| -rw-r--r-- | src/server/game/Server/Packets/ChannelPackets.h | 90 | ||||
| -rw-r--r-- | src/server/game/Server/Packets/MovementPackets.cpp | 6 |
3 files changed, 171 insertions, 3 deletions
diff --git a/src/server/game/Server/Packets/ChannelPackets.cpp b/src/server/game/Server/Packets/ChannelPackets.cpp new file mode 100644 index 00000000000..8aa4ac51d42 --- /dev/null +++ b/src/server/game/Server/Packets/ChannelPackets.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "ChannelPackets.h" +#include "Channel.h" + +WorldPacket const* WorldPackets::Channel::ChannelNotify::Write() +{ + _worldPacket.WriteBits(Type, 6); + _worldPacket.WriteBits(Channel.length(), 7); + _worldPacket.WriteBits(Sender.length(), 6); + + _worldPacket << SenderGuid; + _worldPacket << SenderBnetAccountID; + _worldPacket << uint32(SenderVirtualRealm); + _worldPacket << TargetGuid; + _worldPacket << uint32(TargetVirtualRealm); + _worldPacket << int32(ChatChannelID); + + if (Type == CHAT_MODE_CHANGE_NOTICE) + { + _worldPacket << uint8(OldFlags); + _worldPacket << uint8(NewFlags); + } + + _worldPacket.WriteString(Channel); + _worldPacket.WriteString(Sender); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Channel::ChannelNotifyJoined::Write() +{ + _worldPacket.WriteBits(Channel.length(), 7); + _worldPacket.WriteBits(ChannelWelcomeMsg.length(), 10); + _worldPacket << uint8(ChannelFlags); + _worldPacket << int32(ChatChannelID); + _worldPacket << uint64(InstanceID); + _worldPacket.WriteString(Channel); + _worldPacket.WriteString(ChannelWelcomeMsg); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Channel::ChannelNotifyLeft::Write() +{ + _worldPacket.WriteBits(Channel.length(), 7); + _worldPacket.WriteBit(Suspended); + _worldPacket << int32(ChatChannelID); + _worldPacket.WriteString(Channel); + + return &_worldPacket; +} + +void WorldPackets::Channel::JoinChannel::Read() +{ + _worldPacket >> ChatChannelId; + CreateVoiceSession = _worldPacket.ReadBit(); + Internal = _worldPacket.ReadBit(); + uint32 channelLength = _worldPacket.ReadBits(7); + uint32 passwordLength = _worldPacket.ReadBits(7); + ChannelName = _worldPacket.ReadString(channelLength); + Password = _worldPacket.ReadString(passwordLength); +} diff --git a/src/server/game/Server/Packets/ChannelPackets.h b/src/server/game/Server/Packets/ChannelPackets.h new file mode 100644 index 00000000000..d3984e18f57 --- /dev/null +++ b/src/server/game/Server/Packets/ChannelPackets.h @@ -0,0 +1,90 @@ +/* +* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along +* with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef ChannelPackets_h__ +#define ChannelPackets_h__ + +#include "Packet.h" +#include "ObjectGuid.h" + +namespace WorldPackets +{ + namespace Channel + { + class ChannelNotify final : public ServerPacket + { + public: + ChannelNotify() : ServerPacket(SMSG_CHANNEL_NOTIFY, 80) { } + + WorldPacket const* Write() override; + + std::string Sender; + ObjectGuid SenderGuid; + ObjectGuid SenderBnetAccountID; + uint8 Type = 0; + uint8 OldFlags = 0; + uint8 NewFlags = 0; + std::string Channel; + uint32 SenderVirtualRealm = 0; + ObjectGuid TargetGuid; + uint32 TargetVirtualRealm = 0; + int32 ChatChannelID = 0; + }; + + class ChannelNotifyJoined final : public ServerPacket + { + public: + ChannelNotifyJoined() : ServerPacket(SMSG_CHANNEL_NOTIFY_JOINED, 50) { } + + WorldPacket const* Write() override; + + std::string ChannelWelcomeMsg; + int32 ChatChannelID = 0; + int32 InstanceID = 0; + uint8 ChannelFlags = 0; + std::string Channel; + }; + + class ChannelNotifyLeft final : public ServerPacket + { + public: + ChannelNotifyLeft() : ServerPacket(SMSG_CHANNEL_NOTIFY_LEFT, 30) { } + + WorldPacket const* Write() override; + + std::string Channel; + int32 ChatChannelID = 0; + bool Suspended = false; + }; + + class JoinChannel final : public ClientPacket + { + public: + JoinChannel(WorldPacket&& packet) : ClientPacket(CMSG_JOIN_CHANNEL, std::move(packet)) { } + + void Read() override; + + std::string Password; + std::string ChannelName; + bool CreateVoiceSession = false; + int32 ChatChannelId = 0; + bool Internal = false; + }; + } +} + +#endif // ChannelPackets_h__ diff --git a/src/server/game/Server/Packets/MovementPackets.cpp b/src/server/game/Server/Packets/MovementPackets.cpp index 487e230a4a1..45d5b86e3fd 100644 --- a/src/server/game/Server/Packets/MovementPackets.cpp +++ b/src/server/game/Server/Packets/MovementPackets.cpp @@ -44,7 +44,7 @@ void WorldPackets::Movement::ClientPlayerMovement::Read() movementInfo.flags = _worldPacket.ReadBits(30); movementInfo.flags2 = _worldPacket.ReadBits(15); - + bool hasTransport = _worldPacket.ReadBit(); bool hasFall = _worldPacket.ReadBit(); @@ -170,8 +170,8 @@ WorldPacket const* WorldPackets::Movement::ServerPlayerMovement::Write() _worldPacket << movementInfo.jump.xyspeed; } } - + _worldPacket.FlushBits(); return &_worldPacket; -}
\ No newline at end of file +} |
