From 441648da6a00cf889d01e28631b83489157f56ec Mon Sep 17 00:00:00 2001 From: Ray Koopa Date: Sun, 20 Jan 2019 00:14:22 +0100 Subject: [PATCH] Implement ChannelCmdPacket. --- .../Client.WorldPartyAqua.cs | 32 ++++++++ src/Syroot.Worms.Mgame.GameServer/Client.cs | 2 +- .../Packets/AppConnection.cs | 34 ++++----- .../OnlineWorms/ChannelEnterFinishReply.cs | 8 +- .../Packets/OnlineWorms/ChannelEnterQuery.cs | 8 +- .../Packets/OnlineWorms/ChannelEnterReply.cs | 8 +- .../Packets/OnlineWorms/ChannelListReply.cs | 8 +- .../Packets/OnlineWorms/ChannelLoginQuery.cs | 8 +- .../Packets/OnlineWorms/ChannelLoginReply.cs | 8 +- .../Packets/OnlineWorms/ChannelTop20Query.cs | 8 +- .../Packets/OnlineWorms/ChannelTop20Reply.cs | 8 +- .../Packets/OnlineWorms/ConnectQuery.cs | 8 +- .../Packets/OnlineWorms/ConnectReply.cs | 8 +- .../Packets/OnlineWorms/LoginQuery.cs | 8 +- .../Packets/OnlineWorms/LoginReply.cs | 8 +- .../Packets/OnlineWorms/ServerInfoReply.cs | 8 +- .../OnlineWorms/StartSingleGameQuery.cs | 8 +- .../OnlineWorms/StartSingleGameReply.cs | 8 +- .../Packets/Packet.cs | 8 +- .../Packets/PacketAttribute.cs | 2 +- .../Packets/PacketFactory.cs | 21 +++--- .../Packets/RawPacket.cs | 6 +- .../WorldPartyAqua/ChannelCmdPacket.cs | 74 +++++++++++++++++++ .../Packets/WorldPartyAqua/ChannelCmdQuery.cs | 23 ++++++ .../Packets/WorldPartyAqua/ChannelCmdReply.cs | 30 ++++++++ .../WorldPartyAqua/ChannelListQuery.cs | 8 +- .../WorldPartyAqua/ChannelListReply.cs | 16 ++-- .../WorldPartyAqua/ChannelLoginQuery.cs | 8 +- .../WorldPartyAqua/ChannelLoginReply.cs | 17 +++++ .../Packets/WorldPartyAqua/ConnectQuery.cs | 8 +- .../Packets/WorldPartyAqua/ConnectReply.cs | 8 +- .../Packets/WorldPartyAqua/DisconnectQuery.cs | 8 +- .../Packets/WorldPartyAqua/LoginQuery.cs | 8 +- .../Packets/WorldPartyAqua/LoginReply.cs | 8 +- .../StartSingleGameQueryData.cs | 16 ++++ .../StartSingleGameReplyData.cs | 42 +++++++++++ 36 files changed, 367 insertions(+), 132 deletions(-) create mode 100644 src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelCmdPacket.cs create mode 100644 src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelCmdQuery.cs create mode 100644 src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelCmdReply.cs create mode 100644 src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelLoginReply.cs create mode 100644 src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/StartSingleGameQueryData.cs create mode 100644 src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/StartSingleGameReplyData.cs diff --git a/src/Syroot.Worms.Mgame.GameServer/Client.WorldPartyAqua.cs b/src/Syroot.Worms.Mgame.GameServer/Client.WorldPartyAqua.cs index 6a8e702..53ca689 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Client.WorldPartyAqua.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Client.WorldPartyAqua.cs @@ -93,9 +93,41 @@ namespace Syroot.Worms.Mgame.GameServer public void HandleWwpaChannelConnect(ChannelLoginQuery packet) { + SendPacket(new ChannelLoginReply()); + } + public void HandleWwpaChannelCmd(ChannelCmdQuery packet) + { + switch (packet.Data) + { + case StartSingleGameQueryData startSingleGameQuery: + HandleWwpaStartGameQuery(startSingleGameQuery); + break; + } } public void HandleWwpaDisconnectQuery(DisconnectQuery packet) { } + + // ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- + + // ---- ChannelCmds ---- + + private void HandleWwpaStartGameQuery(StartSingleGameQueryData data) + { + SendPacket(new ChannelCmdReply(new StartSingleGameReplyData + { + Stuff = new List + { + new StartSingleGameReplyStuff + { + UnknownA = 1, + UnknownB = 2, + UnknownC = 3, + UnknownD = 4, + UnknownE = 5 + } + } + })); + } } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Client.cs b/src/Syroot.Worms.Mgame.GameServer/Client.cs index 5540acb..6f69c58 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Client.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Client.cs @@ -43,7 +43,7 @@ namespace Syroot.Worms.Mgame.GameServer // ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- - private string FormatPacket(Packet packet, string direction) + private string FormatPacket(IPacket packet, string direction) => $"{TcpClient.Client.RemoteEndPoint} {direction} {packet.GetType().Name}{ObjectDumper.Dump(packet)}"; } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/AppConnection.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/AppConnection.cs index 3400eab..80bb2de 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/AppConnection.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/AppConnection.cs @@ -9,7 +9,7 @@ using Syroot.Worms.Mgame.GameServer.Core.Reflection; namespace Syroot.Worms.Mgame.GameServer.Packets { /// - /// Represents a class capable of dispatching received instances to a corresponding method. + /// Represents a class capable of dispatching received instances to a corresponding method. /// internal class AppConnection : IDisposable { @@ -23,7 +23,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets // ---- FIELDS ------------------------------------------------------------------------------------------------- - private readonly MethodHandler _methodHandler; + private readonly MethodHandler _methodHandler; private readonly SafeNetworkStream _tcpStream; private bool _disposed; @@ -36,15 +36,15 @@ namespace Syroot.Worms.Mgame.GameServer.Packets /// The to communicate with. internal AppConnection(TcpClient tcpClient) { - _methodHandler = new MethodHandler(this); + _methodHandler = new MethodHandler(this); TcpClient = tcpClient; _tcpStream = TcpClient.GetSafeStream(); } // ---- EVENTS ------------------------------------------------------------------------------------------------- - protected event EventHandler PrePacketHandle; - protected event EventHandler PrePacketSend; + protected event EventHandler PrePacketHandle; + protected event EventHandler PrePacketSend; // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -68,7 +68,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets /// internal void Listen() { - Packet packet; + IPacket packet; while ((packet = ReceivePacket()) != null) { PrePacketHandle?.Invoke(this, packet); @@ -88,7 +88,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets } } - protected bool SendPacket(Packet packet) + protected bool SendPacket(IPacket packet) { PrePacketSend?.Invoke(this, packet); try @@ -117,7 +117,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets // ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- - private Packet ReceivePacket() + private IPacket ReceivePacket() { try { @@ -137,7 +137,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets catch (ObjectDisposedException) { return null; } // The underlying stream closed. } - private Packet ReceiveOWChannelPacket() + private IPacket ReceiveOWChannelPacket() { // Read head. if (_tcpStream.Read1Byte() != 1) @@ -152,12 +152,12 @@ namespace Syroot.Worms.Mgame.GameServer.Packets throw new IOException("Invalid OW channel packet end tag."); // Instantiate, deserialize, and return packet. - Packet packet = PacketFactory.Create(PacketFormat.OWChannel, id); + IPacket packet = PacketFactory.Create(PacketFormat.OWChannel, id); packet.Load(ref reader); return packet; } - private Packet ReceiveOWServerPacket(int tag) + private IPacket ReceiveOWServerPacket(int tag) { // Read head. int dataSize = _tcpStream.ReadUInt16(); @@ -165,12 +165,12 @@ namespace Syroot.Worms.Mgame.GameServer.Packets SpanReader reader = new SpanReader(_tcpStream.ReadBytes(dataSize), encoding: Encodings.Korean); // Instantiate, deserialize, and return packet. - Packet packet = PacketFactory.Create(PacketFormat.OWServer, tag); + IPacket packet = PacketFactory.Create(PacketFormat.OWServer, tag); packet.Load(ref reader); return packet; } - private Packet ReceiveWwpaPacket() + private IPacket ReceiveWwpaPacket() { // Read head. if (!_tcpStream.ReadBoolean()) @@ -193,13 +193,13 @@ namespace Syroot.Worms.Mgame.GameServer.Packets // Instantiate, deserialize, and return packet. SpanReader reader = new SpanReader(PacketCompression.Decompress(compressedData), encoding: Encodings.Korean); int id = reader.ReadInt32(); - Packet packet = PacketFactory.Create(PacketFormat.Wwpa, id); + IPacket packet = PacketFactory.Create(PacketFormat.Wwpa, id); SpanReader dataReader = reader.Slice(); packet.Load(ref dataReader); return packet; } - private void SendOWChannelPacket(int id, Packet packet) + private void SendOWChannelPacket(int id, IPacket packet) { // Retrieve data. Must have at least 1 byte. SpanWriter writer = new SpanWriter(new byte[_maxDataSize], encoding: Encodings.Korean); @@ -219,7 +219,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets _tcpStream.WriteUInt16(_owTagEndChannel); } - private void SendOWServerPacket(int id, Packet packet) + private void SendOWServerPacket(int id, IPacket packet) { // Retrieve data. SpanWriter writer = new SpanWriter(new byte[_maxDataSize], encoding: Encodings.Korean); @@ -233,7 +233,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets _tcpStream.Write(writer.Span); } - private void SendWwpaPacket(int id, Packet packet, bool compress) + private void SendWwpaPacket(int id, IPacket packet, bool compress) { // Retrieve (decompressed) data. SpanWriter writer = new SpanWriter(new byte[_maxDataSize], encoding: Encodings.Korean); diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelEnterFinishReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelEnterFinishReply.cs index 1290436..8f47f28 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelEnterFinishReply.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelEnterFinishReply.cs @@ -8,12 +8,12 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// to the channel screen (game lobby). /// [Packet(PacketFormat.OWChannel, 0x44)] - internal class ChannelEnterFinishReply : Packet + internal class ChannelEnterFinishReply : IPacket { - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => throw new NotImplementedException(); + public void Load(ref SpanReader reader) => throw new NotImplementedException(); - internal override void Save(ref SpanWriter writer) { } + public void Save(ref SpanWriter writer) { } } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelEnterQuery.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelEnterQuery.cs index 3a64b79..98c48c3 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelEnterQuery.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelEnterQuery.cs @@ -8,7 +8,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents the client request for a . /// [Packet(PacketFormat.OWServer, 0x8034)] - internal class ChannelEnterQuery : Packet + internal class ChannelEnterQuery : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -16,14 +16,14 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms public IPEndPoint ChannelEndPoint { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) + public void Load(ref SpanReader reader) { PlayerID = reader.ReadString2(); ChannelEndPoint = new IPEndPoint(IPAddress.Parse(reader.ReadString2()), reader.ReadUInt16()); } - internal override void Save(ref SpanWriter writer) => throw new NotImplementedException(); + public void Save(ref SpanWriter writer) => throw new NotImplementedException(); } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelEnterReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelEnterReply.cs index 00e1fb1..20d5a6e 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelEnterReply.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelEnterReply.cs @@ -8,7 +8,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents the server response to a . /// [Packet(PacketFormat.OWServer, 0x8035)] - internal class ChannelEnterReply : Packet + internal class ChannelEnterReply : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -17,11 +17,11 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// public IPEndPoint EndPoint { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => throw new NotImplementedException(); + public void Load(ref SpanReader reader) => throw new NotImplementedException(); - internal override void Save(ref SpanWriter writer) + public void Save(ref SpanWriter writer) { writer.WriteString2(EndPoint.Address.ToString()); writer.WriteUInt16((ushort)EndPoint.Port); diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelListReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelListReply.cs index 55e0a34..582dc2d 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelListReply.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelListReply.cs @@ -11,17 +11,17 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents an additional server response to a , providing available server channels. /// [Packet(PacketFormat.OWServer, 0x80C9)] - internal class ChannelListReply : Packet + internal class ChannelListReply : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- public IList Channels { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => throw new NotImplementedException(); + public void Load(ref SpanReader reader) => throw new NotImplementedException(); - internal override void Save(ref SpanWriter writer) + public void Save(ref SpanWriter writer) { writer.WriteUInt16((ushort)Channels.Count); foreach (ChannelInfo channel in Channels) diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelLoginQuery.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelLoginQuery.cs index eb320df..a5fac7d 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelLoginQuery.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelLoginQuery.cs @@ -10,7 +10,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents the client request for a . /// [Packet(PacketFormat.OWChannel, 0x10)] - internal class ChannelLoginQuery : Packet + internal class ChannelLoginQuery : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -24,9 +24,9 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms public byte UnknownB { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) + public void Load(ref SpanReader reader) { Players = new List { @@ -52,6 +52,6 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms UnknownB = reader.ReadByte(); } - internal override void Save(ref SpanWriter writer) => throw new NotImplementedException(); + public void Save(ref SpanWriter writer) => throw new NotImplementedException(); } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelLoginReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelLoginReply.cs index 1a08667..9916aa3 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelLoginReply.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelLoginReply.cs @@ -7,7 +7,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents the server response to a . /// [Packet(PacketFormat.OWChannel, 0x11)] - internal class ChannelLoginReply : Packet + internal class ChannelLoginReply : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -15,11 +15,11 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms public ChannelConnectPlayerInfo Player { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => throw new NotImplementedException(); + public void Load(ref SpanReader reader) => throw new NotImplementedException(); - internal override void Save(ref SpanWriter writer) + public void Save(ref SpanWriter writer) { if (Result == ChannelConnectResult.Success) { diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelTop20Query.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelTop20Query.cs index 580751e..e741f21 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelTop20Query.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelTop20Query.cs @@ -7,7 +7,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents the client request for a . /// [Packet(PacketFormat.OWChannel, 0x37)] - internal class ChannelTop20Query : Packet + internal class ChannelTop20Query : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -16,13 +16,13 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// public ushort Count { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) + public void Load(ref SpanReader reader) { Count = reader.ReadUInt16(); } - internal override void Save(ref SpanWriter writer) => throw new NotImplementedException(); + public void Save(ref SpanWriter writer) => throw new NotImplementedException(); } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelTop20Reply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelTop20Reply.cs index 24f1466..4763c0b 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelTop20Reply.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ChannelTop20Reply.cs @@ -8,7 +8,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents the server response to a . /// [Packet(PacketFormat.OWChannel, 0x36)] - internal class ChannelTop20Reply : Packet + internal class ChannelTop20Reply : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -16,11 +16,11 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms public IList Top20 { get; set; } // 20 elements. - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => throw new NotImplementedException(); + public void Load(ref SpanReader reader) => throw new NotImplementedException(); - internal override void Save(ref SpanWriter writer) + public void Save(ref SpanWriter writer) { writer.WriteStringFix(UnknownA, 30); foreach (ChannelTop20Player top20Player in Top20) diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ConnectQuery.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ConnectQuery.cs index 60d4185..721a1cf 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ConnectQuery.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ConnectQuery.cs @@ -7,12 +7,12 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents the client request for a . /// [Packet(PacketFormat.OWServer, 0x800E)] - internal class ConnectQuery : Packet + internal class ConnectQuery : IPacket { - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) { } + public void Load(ref SpanReader reader) { } - internal override void Save(ref SpanWriter writer) => throw new NotImplementedException(); + public void Save(ref SpanWriter writer) => throw new NotImplementedException(); } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ConnectReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ConnectReply.cs index 367fdd6..2af1845 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ConnectReply.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ConnectReply.cs @@ -7,7 +7,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents the server response to a . /// [Packet(PacketFormat.OWServer, 0x800F)] - internal class ConnectReply : Packet + internal class ConnectReply : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -17,11 +17,11 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms internal ushort Version { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => throw new NotImplementedException(); + public void Load(ref SpanReader reader) => throw new NotImplementedException(); - internal override void Save(ref SpanWriter writer) + public void Save(ref SpanWriter writer) { writer.WriteString2(Unknown); writer.WriteByte(0); diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/LoginQuery.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/LoginQuery.cs index 7b5db3b..79bd4a7 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/LoginQuery.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/LoginQuery.cs @@ -9,7 +9,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents the client request for a . /// [Packet(PacketFormat.OWServer, 0x8000)] - internal class LoginQuery : Packet + internal class LoginQuery : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -19,9 +19,9 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms internal IPAddress ClientIP { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) + public void Load(ref SpanReader reader) { Unknown1 = reader.ReadUInt16(); Players = new PlayerCredentials[reader.ReadUInt16()]; @@ -30,6 +30,6 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms ClientIP = IPAddress.Parse(reader.ReadString2()); } - internal override void Save(ref SpanWriter writer) => throw new NotImplementedException(); + public void Save(ref SpanWriter writer) => throw new NotImplementedException(); } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/LoginReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/LoginReply.cs index 157b279..5f3c4ea 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/LoginReply.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/LoginReply.cs @@ -7,7 +7,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents the server response to a . /// [Packet(PacketFormat.OWServer, 0x8001)] - internal class LoginReply : Packet + internal class LoginReply : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -21,11 +21,11 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms internal LoginPlayerInfo[] PlayerInfos { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => throw new NotImplementedException(); + public void Load(ref SpanReader reader) => throw new NotImplementedException(); - internal override void Save(ref SpanWriter writer) + public void Save(ref SpanWriter writer) { bool loginSuccessful = Result == LoginResult.Success; writer.WriteBoolean(loginSuccessful); diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ServerInfoReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ServerInfoReply.cs index efaca99..0a9a76b 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ServerInfoReply.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/ServerInfoReply.cs @@ -8,7 +8,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// screen text. /// [Packet(PacketFormat.OWServer, 0x8033)] - internal class ServerInfoReply : Packet + internal class ServerInfoReply : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -17,11 +17,11 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// internal string Text { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => throw new NotImplementedException(); + public void Load(ref SpanReader reader) => throw new NotImplementedException(); - internal override void Save(ref SpanWriter writer) + public void Save(ref SpanWriter writer) { writer.WriteString2(Text.Replace(Environment.NewLine, "\n")); } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/StartSingleGameQuery.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/StartSingleGameQuery.cs index 284b7ae..a1c9bdd 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/StartSingleGameQuery.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/StartSingleGameQuery.cs @@ -7,7 +7,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents the client request for a . /// [Packet(PacketFormat.OWChannel, 0x38)] - internal class StartSingleGameQuery : Packet + internal class StartSingleGameQuery : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -15,16 +15,16 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms public byte UnknownB { get; set; } public byte UnknownC { get; set; } // 0x3D on first round, 0x3E on any other - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) + public void Load(ref SpanReader reader) { RoundType = reader.ReadEnumSafe(); UnknownB = reader.ReadByte(); UnknownC = reader.ReadByte(); } - internal override void Save(ref SpanWriter writer) => throw new NotImplementedException(); + public void Save(ref SpanWriter writer) => throw new NotImplementedException(); } internal enum GameStartRoundType : byte diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/StartSingleGameReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/StartSingleGameReply.cs index ea47cc2..bccbb1f 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/StartSingleGameReply.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/OnlineWorms/StartSingleGameReply.cs @@ -7,17 +7,17 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.OnlineWorms /// Represents the server response to a . /// [Packet(PacketFormat.OWChannel, 0x39)] - internal class StartSingleGameReply : Packet + internal class StartSingleGameReply : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- public bool Success { get; set; } = true; - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => throw new NotImplementedException(); + public void Load(ref SpanReader reader) => throw new NotImplementedException(); - internal override void Save(ref SpanWriter writer) + public void Save(ref SpanWriter writer) { writer.WriteBoolean2(Success); } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/Packet.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/Packet.cs index c1d1c4b..cc2aa00 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/Packet.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/Packet.cs @@ -6,12 +6,12 @@ namespace Syroot.Worms.Mgame.GameServer.Packets /// Represents a packet with an ID specifying its contents. To allow the server to instantiate child packet classes, /// decorate it with the . /// - internal abstract class Packet + internal interface IPacket { - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS ------------------------------------------------------------------------------------------------ - internal abstract void Load(ref SpanReader reader); + void Load(ref SpanReader reader); - internal abstract void Save(ref SpanWriter writer); + void Save(ref SpanWriter writer); } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/PacketAttribute.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/PacketAttribute.cs index cf4e755..ba99cd8 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/PacketAttribute.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/PacketAttribute.cs @@ -3,7 +3,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets { /// - /// Decorates a child class with the ID of the packet it represents. + /// Decorates a child class with the ID of the packet it represents. /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] internal class PacketAttribute : Attribute diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/PacketFactory.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/PacketFactory.cs index e72309c..938279e 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/PacketFactory.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/PacketFactory.cs @@ -6,7 +6,7 @@ using System.Reflection; namespace Syroot.Worms.Mgame.GameServer.Packets { /// - /// Represents a factory creating instances by mapping their ID to types to instantiate. + /// Represents a factory creating instances by mapping their ID to types to instantiate. /// internal static class PacketFactory { @@ -37,31 +37,32 @@ namespace Syroot.Worms.Mgame.GameServer.Packets // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- /// - /// Creates a new instance mapped to the given . + /// Creates a new instance mapped to the given . /// + /// The to instantiate. /// The ID of the packet class to instantiate. - /// The created instance. + /// The created instance. /// No class was mapped to the given packet ID. - internal static Packet Create(PacketFormat type, int id) + internal static IPacket Create(PacketFormat format, int id) { foreach (KeyValuePair packetMeta in _packetCache) { - if (packetMeta.Key.Format == type && packetMeta.Key.ID == id) - return (Packet)Activator.CreateInstance(packetMeta.Value, true); + if (packetMeta.Key.ID == id) + return (IPacket)Activator.CreateInstance(packetMeta.Value, true); } // No packet metadata matching. #if DEBUG - return new RawPacket(type, id); + return new RawPacket(format, id); #endif - throw new ArgumentException($"{type} packet with ID {id} could not be created."); + throw new ArgumentException($"{format} packet with ID {id} could not be created."); } /// /// Gets the metadata for the class of the given . /// - /// The whose metadata will be returned. + /// The whose metadata will be returned. /// The metadata of the packet class. - internal static PacketAttribute GetAttribute(Packet packet) + internal static PacketAttribute GetAttribute(IPacket packet) { #if DEBUG if (packet is RawPacket rawPacket) diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/RawPacket.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/RawPacket.cs index dd10e57..ca8f27f 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/RawPacket.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/RawPacket.cs @@ -6,7 +6,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets /// /// Represents a special fallback packet which simply stores any ID and the raw packet data. /// - internal class RawPacket : Packet + internal class RawPacket : IPacket { // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------ @@ -27,9 +27,9 @@ namespace Syroot.Worms.Mgame.GameServer.Packets // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => Data = reader.ReadBytes(reader.Length); + public void Load(ref SpanReader reader) => Data = reader.ReadBytes(reader.Length); - internal override void Save(ref SpanWriter writer) => writer.WriteBytes(Data); + public void Save(ref SpanWriter writer) => writer.WriteBytes(Data); } } #endif diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelCmdPacket.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelCmdPacket.cs new file mode 100644 index 0000000..aa95543 --- /dev/null +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelCmdPacket.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Syroot.BinaryData.Memory; +using Syroot.Worms.Mgame.GameServer.Core.IO; + +namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua +{ + // TODO: Ugly, but requires bigger redesign to allow a second identifier in the packets. + + /// + /// Represents the base class for and packets. + /// + internal abstract class ChannelCmdPacket : IPacket + { + // ---- PROPERTIES --------------------------------------------------------------------------------------------- + + public IChannelCmdData Data { get; set; } + + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- + + public void Load(ref SpanReader reader) + { + ChannelCmd cmd = reader.ReadEnum(); + Data = GetDataClasses().TryGetValue(cmd, out Type type) + ? (IChannelCmdData)Activator.CreateInstance(type) + : new RawChannelCmdData(cmd); + Data.Load(ref reader); + } + + public void Save(ref SpanWriter writer) + { + ChannelCmd cmd; + switch (Data) + { + case RawChannelCmdData rawChannelCmdData: + cmd = rawChannelCmdData.Cmd; + break; + default: + Type dataType = Data.GetType(); + cmd = GetDataClasses().First(x => x.Value == dataType).Key; + break; + } + writer.WriteEnum(cmd); + Data.Save(ref writer); + } + + // ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------ + + protected abstract IDictionary GetDataClasses(); + } + + internal enum ChannelCmd : int + { + StartSingleGameQuery = 5 + } + + internal interface IChannelCmdData + { + void Load(ref SpanReader reader); + void Save(ref SpanWriter writer); + } + + internal class RawChannelCmdData : IChannelCmdData + { + public RawChannelCmdData(ChannelCmd cmd) => Cmd = cmd; + + internal ChannelCmd Cmd { get; } + internal byte[] Data { get; set; } + + public void Load(ref SpanReader reader) => Data = reader.ReadToEnd(); + public void Save(ref SpanWriter writer) => writer.WriteBytes(Data); + } +} diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelCmdQuery.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelCmdQuery.cs new file mode 100644 index 0000000..f9dc05f --- /dev/null +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelCmdQuery.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; + +namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua +{ + /// + /// Represents the client request for a . + /// + [Packet(PacketFormat.Wwpa, 0x10A)] + internal class ChannelCmdQuery : ChannelCmdPacket + { + // ---- FIELDS ------------------------------------------------------------------------------------------------- + + private static readonly Dictionary _queryClasses = new Dictionary + { + [ChannelCmd.StartSingleGameQuery] = typeof(StartSingleGameQueryData) + }; + + // ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------ + + protected override IDictionary GetDataClasses() => _queryClasses; + } +} diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelCmdReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelCmdReply.cs new file mode 100644 index 0000000..3d35f9d --- /dev/null +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelCmdReply.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; + +namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua +{ + /// + /// Represents the server response to a . + /// + [Packet(PacketFormat.Wwpa, 0x10B)] + internal class ChannelCmdReply : ChannelCmdPacket + { + // ---- FIELDS ------------------------------------------------------------------------------------------------- + + private static readonly Dictionary _replyClasses = new Dictionary + { + [ChannelCmd.StartSingleGameQuery] = typeof(StartSingleGameReplyData) + }; + + // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------ + + internal ChannelCmdReply(IChannelCmdData data) + { + Data = data; + } + + // ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------ + + protected override IDictionary GetDataClasses() => _replyClasses; + } +} diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelListQuery.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelListQuery.cs index 68ad04c..7e01836 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelListQuery.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelListQuery.cs @@ -6,12 +6,12 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua /// Represents the client request for a . /// [Packet(PacketFormat.Wwpa, 0x801E)] - internal class ChannelListQuery : Packet + internal class ChannelListQuery : IPacket { - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) { } + public void Load(ref SpanReader reader) { } - internal override void Save(ref SpanWriter writer) { } + public void Save(ref SpanWriter writer) { } } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelListReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelListReply.cs index daf99a5..b73cd41 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelListReply.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelListReply.cs @@ -11,23 +11,23 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua /// Represents the server reply to a . /// [Packet(PacketFormat.Wwpa, 0x801F)] - internal class ChannelListReply : Packet + internal class ChannelListReply : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- public IList Channels { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => throw new NotImplementedException(); + public void Load(ref SpanReader reader) => throw new NotImplementedException(); - internal override void Save(ref SpanWriter writer) + public void Save(ref SpanWriter writer) { writer.WriteUInt16((ushort)Channels.Count); - writer.WriteByte((byte)Channels.Count(x => x.Type == ChannelType.Normal)); - writer.WriteByte((byte)Channels.Count(x => x.Type == ChannelType.Roping)); - writer.WriteByte((byte)Channels.Count(x => x.Type == ChannelType.Guild)); - writer.WriteByte((byte)Channels.Count(x => x.Type == ChannelType.Event)); + writer.WriteByte((byte)Channels.Count(x => x.Type == ChannelType.Normal)); // index 0 + writer.WriteByte((byte)Channels.Count(x => x.Type == ChannelType.Roping)); // index 3 + writer.WriteByte((byte)Channels.Count(x => x.Type == ChannelType.Guild)); // index 1 + writer.WriteByte((byte)Channels.Count(x => x.Type == ChannelType.Event)); // index 2 foreach (ChannelInfo channel in Channels) { writer.WriteUInt16(channel.UnknownA); diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelLoginQuery.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelLoginQuery.cs index 99d3209..0382674 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelLoginQuery.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelLoginQuery.cs @@ -11,7 +11,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua /// Represents the client request for a . /// [Packet(PacketFormat.Wwpa, 0x101)] - internal class ChannelLoginQuery : Packet + internal class ChannelLoginQuery : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -21,9 +21,9 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua public byte UnknownB { get; set; } public byte[] Remain { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) + public void Load(ref SpanReader reader) { IPAddress = IPAddress.Parse(reader.ReadString2()); Players = new List { reader.ReadCredentials() }; @@ -34,6 +34,6 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua Remain = reader.ReadToEnd(); } - internal override void Save(ref SpanWriter writer) => throw new NotImplementedException(); + public void Save(ref SpanWriter writer) => throw new NotImplementedException(); } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelLoginReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelLoginReply.cs new file mode 100644 index 0000000..f25326f --- /dev/null +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ChannelLoginReply.cs @@ -0,0 +1,17 @@ +using Syroot.BinaryData.Memory; + +namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua +{ + /// + /// Represents the server response to a . + /// + [Packet(PacketFormat.Wwpa, 0x145)] + internal class ChannelLoginReply : IPacket + { + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- + + public void Load(ref SpanReader reader) { } + + public void Save(ref SpanWriter writer) { } + } +} diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ConnectQuery.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ConnectQuery.cs index 391c2ac..fb0a206 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ConnectQuery.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ConnectQuery.cs @@ -6,12 +6,12 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua /// Represents the client request for a . /// [Packet(PacketFormat.Wwpa, 0x8001)] - internal class ConnectQuery : Packet + internal class ConnectQuery : IPacket { - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) { } + public void Load(ref SpanReader reader) { } - internal override void Save(ref SpanWriter writer) { } + public void Save(ref SpanWriter writer) { } } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ConnectReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ConnectReply.cs index 776770d..f72a24f 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ConnectReply.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/ConnectReply.cs @@ -7,7 +7,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua /// Represents the server response to a . /// [Packet(PacketFormat.Wwpa, 0x8002)] - internal class ConnectReply : Packet + internal class ConnectReply : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -22,11 +22,11 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua /// internal ushort ServerVersion { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => throw new NotImplementedException(); + public void Load(ref SpanReader reader) => throw new NotImplementedException(); - internal override void Save(ref SpanWriter writer) + public void Save(ref SpanWriter writer) { bool connectionFailed = ErrorMessage != null; writer.WriteBoolean4(connectionFailed); diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/DisconnectQuery.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/DisconnectQuery.cs index a31bb4f..feb5506 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/DisconnectQuery.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/DisconnectQuery.cs @@ -6,12 +6,12 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua /// Represents the client packet probably sent when it notifies about disconnecting. /// [Packet(PacketFormat.Wwpa, 0x801B)] - internal class DisconnectQuery : Packet + internal class DisconnectQuery : IPacket { - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) { } + public void Load(ref SpanReader reader) { } - internal override void Save(ref SpanWriter writer) { } + public void Save(ref SpanWriter writer) { } } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/LoginQuery.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/LoginQuery.cs index 83fe58c..ec72503 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/LoginQuery.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/LoginQuery.cs @@ -9,7 +9,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua /// Represents the client request for a . /// [Packet(PacketFormat.Wwpa, 0x8019)] - internal class LoginQuery : Packet + internal class LoginQuery : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -18,15 +18,15 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua /// public IList Players { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) + public void Load(ref SpanReader reader) { Players = new List { reader.ReadCredentials() }; if (reader.ReadBoolean()) Players.Add(reader.ReadCredentials()); } - internal override void Save(ref SpanWriter writer) => throw new NotImplementedException(); + public void Save(ref SpanWriter writer) => throw new NotImplementedException(); } } diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/LoginReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/LoginReply.cs index b547ce7..b71c779 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/LoginReply.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/LoginReply.cs @@ -7,7 +7,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua /// Represents the server response to a . /// [Packet(PacketFormat.Wwpa, 0x801A)] - internal class LoginReply : Packet + internal class LoginReply : IPacket { // ---- PROPERTIES --------------------------------------------------------------------------------------------- @@ -17,11 +17,11 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua public ushort UnknownB { get; set; } - // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- - internal override void Load(ref SpanReader reader) => throw new NotImplementedException(); + public void Load(ref SpanReader reader) => throw new NotImplementedException(); - internal override void Save(ref SpanWriter writer) + public void Save(ref SpanWriter writer) { writer.WriteEnumSafe(Result); if (Result == LoginResult.Success) diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/StartSingleGameQueryData.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/StartSingleGameQueryData.cs new file mode 100644 index 0000000..8bb909b --- /dev/null +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/StartSingleGameQueryData.cs @@ -0,0 +1,16 @@ +using Syroot.BinaryData.Memory; + +namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua +{ + /// + /// Represents the client request for a . + /// + internal class StartSingleGameQueryData : IChannelCmdData + { + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- + + public void Load(ref SpanReader reader) { } + + public void Save(ref SpanWriter writer) { } + } +} diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/StartSingleGameReplyData.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/StartSingleGameReplyData.cs new file mode 100644 index 0000000..eb792ad --- /dev/null +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/StartSingleGameReplyData.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using Syroot.BinaryData.Memory; + +namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua +{ + /// + /// Represents the server response to a . + /// + internal class StartSingleGameReplyData : IChannelCmdData + { + // ---- PROPERTIES --------------------------------------------------------------------------------------------- + + public IList Stuff { get; set; } + + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- + + public void Load(ref SpanReader reader) => throw new NotImplementedException(); + + public void Save(ref SpanWriter writer) + { + writer.WriteUInt16((ushort)Stuff.Count); + foreach (StartSingleGameReplyStuff stuff in Stuff) + { + writer.WriteByte(stuff.UnknownA); + writer.WriteByte(stuff.UnknownB); + writer.WriteUInt16(stuff.UnknownC); + writer.WriteUInt16(stuff.UnknownD); + writer.WriteUInt16(stuff.UnknownE); + } + } + } + + public class StartSingleGameReplyStuff + { + public byte UnknownA { get; set; } + public byte UnknownB { get; set; } + public ushort UnknownC { get; set; } + public ushort UnknownD { get; set; } + public ushort UnknownE { get; set; } + } +}