From 41991d6d78caf0a6109b8d5ba0718fb78d60352a Mon Sep 17 00:00:00 2001 From: Ray Koopa Date: Fri, 4 Jan 2019 19:57:38 +0100 Subject: [PATCH] Add ChannelEnterFinishReply. --- src/Syroot.Worms.OnlineWorms.Server/Client.cs | 4 +++- .../Net/GameConnection.cs | 4 +++- .../Net/Packets/ChannelEnterFinishReply.cs | 18 ++++++++++++++++++ .../Net/Packets/ChannelUnkInfoReply.cs | 5 ++++- .../OWServerConfig.json | 2 +- 5 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 src/Syroot.Worms.OnlineWorms.Server/Net/Packets/ChannelEnterFinishReply.cs diff --git a/src/Syroot.Worms.OnlineWorms.Server/Client.cs b/src/Syroot.Worms.OnlineWorms.Server/Client.cs index 0c15b78..d6fe476 100644 --- a/src/Syroot.Worms.OnlineWorms.Server/Client.cs +++ b/src/Syroot.Worms.OnlineWorms.Server/Client.cs @@ -142,6 +142,7 @@ namespace Syroot.Worms.OnlineWorms.Server public void HandleChannelUnkInfo(ChannelUnkInfoQuery packet) { + // Send player rank infos. ChannelUnkInfoReply reply = new ChannelUnkInfoReply { UnknownA = "Test", @@ -158,7 +159,8 @@ namespace Syroot.Worms.OnlineWorms.Server } SendPacket(reply); - SendPacket(new RawPacket(PacketType.Channel, 0x44, (byte)0x00)); + // This is the last channel info packet, tell the client to go to the channel screen. + SendPacket(new ChannelEnterFinishReply()); } #if DEBUG diff --git a/src/Syroot.Worms.OnlineWorms.Server/Net/GameConnection.cs b/src/Syroot.Worms.OnlineWorms.Server/Net/GameConnection.cs index d7d5015..1560382 100644 --- a/src/Syroot.Worms.OnlineWorms.Server/Net/GameConnection.cs +++ b/src/Syroot.Worms.OnlineWorms.Server/Net/GameConnection.cs @@ -167,9 +167,11 @@ namespace Syroot.Worms.OnlineWorms.Server.Net { OnPrePacketSend(packet); - // Serialize the raw packet data. + // Serialize the raw packet data, which must consist of at least 1 byte (at least for channels). _sendStream.Position = 0; packet.Serialize(_sendStream); + if (_sendStream.Position == 0) + _sendStream.WriteByte(0); ushort dataSize = (ushort)_sendStream.Position; // Send the data and return success. diff --git a/src/Syroot.Worms.OnlineWorms.Server/Net/Packets/ChannelEnterFinishReply.cs b/src/Syroot.Worms.OnlineWorms.Server/Net/Packets/ChannelEnterFinishReply.cs new file mode 100644 index 0000000..7d35cf3 --- /dev/null +++ b/src/Syroot.Worms.OnlineWorms.Server/Net/Packets/ChannelEnterFinishReply.cs @@ -0,0 +1,18 @@ +using System; + +namespace Syroot.Worms.OnlineWorms.Server.Net +{ + /// + /// Represents an additional server response to a , causing the client to switch + /// to the channel screen (game lobby). + /// + [Packet(PacketType.Channel, 0x44)] + internal class ChannelEnterFinishReply : Packet + { + // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- + + internal override void Deserialize(PacketStream stream) => throw new NotImplementedException(); + + internal override void Serialize(PacketStream stream) { } + } +} diff --git a/src/Syroot.Worms.OnlineWorms.Server/Net/Packets/ChannelUnkInfoReply.cs b/src/Syroot.Worms.OnlineWorms.Server/Net/Packets/ChannelUnkInfoReply.cs index 3076662..8636ae1 100644 --- a/src/Syroot.Worms.OnlineWorms.Server/Net/Packets/ChannelUnkInfoReply.cs +++ b/src/Syroot.Worms.OnlineWorms.Server/Net/Packets/ChannelUnkInfoReply.cs @@ -14,7 +14,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net public string UnknownA { get; set; } // Max. 30 chars - public IList UnkInfos { get; set; } // Client always requests 20 elements. + public IList UnkInfos { get; set; } // Apparently ranks. Client always requests 20 elements. // ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- @@ -32,6 +32,9 @@ namespace Syroot.Worms.OnlineWorms.Server.Net } } + /// + /// Represents a player channel rank, apparently. + /// public class ChannelUnkInfo { public ushort UnknownA { get; set; } diff --git a/src/Syroot.Worms.OnlineWorms.Server/OWServerConfig.json b/src/Syroot.Worms.OnlineWorms.Server/OWServerConfig.json index 8e0c119..c2190a2 100644 --- a/src/Syroot.Worms.OnlineWorms.Server/OWServerConfig.json +++ b/src/Syroot.Worms.OnlineWorms.Server/OWServerConfig.json @@ -1,5 +1,5 @@ { - "IP": "87.123.189.212", // external IP sent to clients to connect to + "IP": "127.0.0.1", // external IP sent to clients to connect to "Port": 17022, "Name": "Online Worms Private Server", "Region": "Global",