diff --git a/src/Syroot.Worms.Mgame.GameServer/Client.WorldPartyAqua.Channel.cs b/src/Syroot.Worms.Mgame.GameServer/Client.WorldPartyAqua.Channel.cs index 8cabf35..ea6260e 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Client.WorldPartyAqua.Channel.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Client.WorldPartyAqua.Channel.cs @@ -17,6 +17,17 @@ namespace Syroot.Worms.Mgame.GameServer }); } + public void HandleWwpaChannelChatMessage(ChatMessageQuery packet) + { + SendPacket(new ChatMessageReply + { + UnknownA = 0, + Scene = ChatMessageScene.Current, + UnknownB = "Bla", + Message = packet.Message + }); + } + public void HandleWwpaChannelCmdFindUser(CmdFindUserQuery packet) { SendPacket(new CmdFindUserReply diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/Channel/ChatMessageQuery.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/Channel/ChatMessageQuery.cs new file mode 100644 index 0000000..18e3dbf --- /dev/null +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/Channel/ChatMessageQuery.cs @@ -0,0 +1,31 @@ +using System; +using Syroot.BinaryData.Memory; + +namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua.Channel +{ + /// + /// Represents the client request for a . + /// + [WwpaPacket(0x114)] + internal class ChatMessageQuery : IPacket + { + // ---- PROPERTIES --------------------------------------------------------------------------------------------- + + public int UnknownA { get; set; } + + public int UnknownB { get; set; } // Always 3? + + public string Message { get; set; } + + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- + + public void Load(ref SpanReader reader) + { + UnknownA = reader.ReadInt32(); + UnknownB = reader.ReadInt32(); + Message = reader.ReadString2(); + } + + public void Save(ref SpanWriter writer) => throw new NotImplementedException(); + } +} diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/Channel/ChatMessageReply.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/Channel/ChatMessageReply.cs new file mode 100644 index 0000000..fa09604 --- /dev/null +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/Channel/ChatMessageReply.cs @@ -0,0 +1,41 @@ +using System; +using Syroot.BinaryData.Memory; + +namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua.Channel +{ + /// + /// Represents the server response to a . + /// + [WwpaPacket(0x115)] + internal class ChatMessageReply : IPacket + { + // ---- PROPERTIES --------------------------------------------------------------------------------------------- + + public ChatMessageScene Scene { get; set; } + + public int UnknownA { get; set; } + + public string UnknownB { get; set; } + + public string Message { get; set; } + + // ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- + + public void Load(ref SpanReader reader) => throw new NotImplementedException(); + + public void Save(ref SpanWriter writer) + { + writer.WriteEnumSafe(Scene); + writer.WriteInt32(UnknownA); + writer.WriteString2(UnknownB); + writer.WriteString2(Message); + } + } + + internal enum ChatMessageScene : int + { + WaitRoom = 1, + GameRoom = 3, + Current = 99 + } +} diff --git a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/WwpaPacketFormat.cs b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/WwpaPacketFormat.cs index 24a7cd6..63d7479 100644 --- a/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/WwpaPacketFormat.cs +++ b/src/Syroot.Worms.Mgame.GameServer/Packets/WorldPartyAqua/WwpaPacketFormat.cs @@ -119,13 +119,16 @@ namespace Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua return (IPacket)Activator.CreateInstance(packets[0].type); // No unique packet found, check for matching command. - int command = reader.ReadInt32(); - packets = packets.Where(x => x.attrib.Command == command).ToList(); - if (packets.Count == 1) - return (IPacket)Activator.CreateInstance(packets[0].type); + if (!reader.IsEndOfSpan) + { + int command = reader.ReadInt32(); + packets = packets.Where(x => x.attrib.Command == command).ToList(); + if (packets.Count == 1) + return (IPacket)Activator.CreateInstance(packets[0].type); - // No unique packet found, return fallback. - reader.Position -= sizeof(int); + // No unique packet found, return fallback. + reader.Position -= sizeof(int); + } return new RawPacket { ID = id }; }