From 7a7e63b40e9d5908893a14f799e1c1622bacbb80 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 25 Jul 2026 21:24:23 +0000 Subject: [PATCH] Declare the parameter type enum where both packet structs see it An enum which is declared inside a packet is generated as a nested type of its struct. The ref struct of the same packet is generated into another file and refers to the enum by its plain name, so it didn't compile. Declare it next to the other shared enums instead, which puts it into the namespace - that's also where CharacterStatus lives, which is used by a structure of another packet in the same way. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01MSpK6jkyF8ZS5nYXyGwYxA (cherry picked from commit 33703647e97d9fb13680086d0366f8200fe2865a) --- .../RemoteView/ChatCommandListViewPlugIn.cs | 8 ++-- .../ServerToClient/ServerToClientPackets.cs | 21 +++++++++ .../ServerToClient/ServerToClientPackets.xml | 44 +++++++++---------- .../ChatCommandPacketTest.cs | 8 ++-- 4 files changed, 50 insertions(+), 31 deletions(-) diff --git a/src/GameServer/RemoteView/ChatCommandListViewPlugIn.cs b/src/GameServer/RemoteView/ChatCommandListViewPlugIn.cs index b095dd5..1c93027 100644 --- a/src/GameServer/RemoteView/ChatCommandListViewPlugIn.cs +++ b/src/GameServer/RemoteView/ChatCommandListViewPlugIn.cs @@ -85,16 +85,16 @@ public class ChatCommandListViewPlugIn : IChatCommandListViewPlugIn return connection.SendAsync(Write); } - private static ChatCommandInfo.ChatCommandParameterType GetParameterType(string typeName) + private static ChatCommandParameterType GetParameterType(string typeName) { return typeName switch { - nameof(Boolean) => ChatCommandInfo.ChatCommandParameterType.Boolean, + nameof(Boolean) => ChatCommandParameterType.Boolean, nameof(Byte) or nameof(SByte) or nameof(Int16) or nameof(UInt16) or nameof(Int32) or nameof(UInt32) - or nameof(Int64) or nameof(UInt64) => ChatCommandInfo.ChatCommandParameterType.Number, - _ => ChatCommandInfo.ChatCommandParameterType.Text, + or nameof(Int64) or nameof(UInt64) => ChatCommandParameterType.Number, + _ => ChatCommandParameterType.Text, }; } } diff --git a/src/Network/Packets/ServerToClient/ServerToClientPackets.cs b/src/Network/Packets/ServerToClient/ServerToClientPackets.cs index 8ab4fe4..054452e 100644 --- a/src/Network/Packets/ServerToClient/ServerToClientPackets.cs +++ b/src/Network/Packets/ServerToClient/ServerToClientPackets.cs @@ -31730,3 +31730,24 @@ public readonly struct ScoreEntry White = 7, } + /// + /// The kind of value which a chat command parameter expects. + /// + public enum ChatCommandParameterType + { + /// + /// The parameter expects a text. + /// + Text = 0, + + /// + /// The parameter expects a number. + /// + Number = 1, + + /// + /// The parameter expects a 0 or a 1. + /// + Boolean = 2, + } + diff --git a/src/Network/Packets/ServerToClient/ServerToClientPackets.xml b/src/Network/Packets/ServerToClient/ServerToClientPackets.xml index 9646bb3..5ee31db 100644 --- a/src/Network/Packets/ServerToClient/ServerToClientPackets.xml +++ b/src/Network/Packets/ServerToClient/ServerToClientPackets.xml @@ -11345,29 +11345,6 @@ - - - ChatCommandParameterType - The kind of value which a chat command parameter expects. - - - Text - The parameter expects a text. - 0 - - - Number - The parameter expects a number. - 1 - - - Boolean - The parameter expects a 0 or a 1. - 2 - - - - @@ -11938,5 +11915,26 @@ + + ChatCommandParameterType + The kind of value which a chat command parameter expects. + + + Text + The parameter expects a text. + 0 + + + Number + The parameter expects a number. + 1 + + + Boolean + The parameter expects a 0 or a 1. + 2 + + + diff --git a/tests/MUnique.OpenMU.Tests/ChatCommandPacketTest.cs b/tests/MUnique.OpenMU.Tests/ChatCommandPacketTest.cs index ae01dd3..effb27d 100644 --- a/tests/MUnique.OpenMU.Tests/ChatCommandPacketTest.cs +++ b/tests/MUnique.OpenMU.Tests/ChatCommandPacketTest.cs @@ -37,18 +37,18 @@ public class ChatCommandPacketTest group.Name = "Group"; group.ShortName = "group"; group.IsRequired = true; - group.Type = ChatCommandInfo.ChatCommandParameterType.Number; + group.Type = ChatCommandParameterType.Number; var ancient = written[1]; ancient.Name = "Ancient"; ancient.ShortName = "anc"; ancient.ValidValues = "0|1|2"; - ancient.Type = ChatCommandInfo.ChatCommandParameterType.Number; + ancient.Type = ChatCommandParameterType.Number; var skill = written[2]; skill.Name = "Skill"; skill.ShortName = "sk"; - skill.Type = ChatCommandInfo.ChatCommandParameterType.Boolean; + skill.Type = ChatCommandParameterType.Boolean; var read = new ChatCommandInfoRef(data); @@ -73,7 +73,7 @@ public class ChatCommandPacketTest Assert.That(read[1].IsRequired, Is.False); Assert.That(read[2].Name, Is.EqualTo("Skill")); - Assert.That(read[2].Type, Is.EqualTo(ChatCommandInfo.ChatCommandParameterType.Boolean)); + Assert.That(read[2].Type, Is.EqualTo(ChatCommandParameterType.Boolean)); } ///