From b61f190df62e5425771bbcc0734942b907dd991c Mon Sep 17 00:00:00 2001 From: Ray Koopa Date: Fri, 4 Jan 2019 03:38:46 +0100 Subject: [PATCH] Fix channel packet format. --- src/Syroot.Worms.OnlineWorms.Server/Client.cs | 4 ++++ src/Syroot.Worms.OnlineWorms.Server/Net/GameConnection.cs | 7 +++---- .../Net/Packets/ChannelConnectQuery.cs | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Syroot.Worms.OnlineWorms.Server/Client.cs b/src/Syroot.Worms.OnlineWorms.Server/Client.cs index dcb4deb..cc728aa 100644 --- a/src/Syroot.Worms.OnlineWorms.Server/Client.cs +++ b/src/Syroot.Worms.OnlineWorms.Server/Client.cs @@ -128,6 +128,10 @@ namespace Syroot.Worms.OnlineWorms.Server public void HandleChannelConnect(ChannelConnectQuery packet) { + SendPacket(new RawPacket(PacketType.Channel, 0x11) + { + Data = new byte[] { 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF } + }); } #if DEBUG diff --git a/src/Syroot.Worms.OnlineWorms.Server/Net/GameConnection.cs b/src/Syroot.Worms.OnlineWorms.Server/Net/GameConnection.cs index f9ac5cb..d7d5015 100644 --- a/src/Syroot.Worms.OnlineWorms.Server/Net/GameConnection.cs +++ b/src/Syroot.Worms.OnlineWorms.Server/Net/GameConnection.cs @@ -140,8 +140,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net throw new IOException("Invalid channel packet start tag."); dataSize = _receiveStream.ReadUInt16(); id = _receiveStream.Read1Byte(); - _receiveStream.ReadAll(_receiveBuffer, 0, dataSize - sizeof(byte)); - _ = _receiveStream.Read1Byte(); // ? + _receiveStream.ReadAll(_receiveBuffer, 0, dataSize); ushort endTag = _receiveStream.ReadUInt16(); if (endTag != _channelPacketEndTag) throw new IOException("Invalid channel packet end tag."); @@ -183,8 +182,8 @@ namespace Syroot.Worms.OnlineWorms.Server.Net _receiveStream.WriteUInt16(_channelPacketStartTag); _receiveStream.WriteByte(1); _receiveStream.WriteUInt16(dataSize); + _receiveStream.WriteByte((byte)attribute.PacketID); _receiveStream.Write(_sendDataBuffer, 0, dataSize); - _receiveStream.WriteByte(0); // ? _receiveStream.Write(_channelPacketEndTag); break; case PacketType.Server: @@ -193,7 +192,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net _receiveStream.Write(_sendDataBuffer, 0, dataSize); break; default: - throw new InvalidOperationException("Cannot send unknown packet type."); + throw new IOException("Cannot send unknown packet type."); } return true; } diff --git a/src/Syroot.Worms.OnlineWorms.Server/Net/Packets/ChannelConnectQuery.cs b/src/Syroot.Worms.OnlineWorms.Server/Net/Packets/ChannelConnectQuery.cs index 17fcdcf..6512f9b 100644 --- a/src/Syroot.Worms.OnlineWorms.Server/Net/Packets/ChannelConnectQuery.cs +++ b/src/Syroot.Worms.OnlineWorms.Server/Net/Packets/ChannelConnectQuery.cs @@ -21,6 +21,8 @@ namespace Syroot.Worms.OnlineWorms.Server.Net public ushort UnknownA { get; set; } // Always 1? + public byte UnknownB { get; set; } + // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- internal override void Deserialize(PacketStream stream) @@ -46,6 +48,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net Password = stream.ReadString(12) }); } + UnknownB = stream.Read1Byte(); } internal override void Serialize(PacketStream stream) => throw new NotImplementedException();