diff --git a/.gitignore b/.gitignore index a9b9e57c4..a0bf66daf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Distribution Files /Distribution/ModernUO /Distribution/ModernUO.* +/Distribution/Server +/Distribution/Server.* /Distribution/Assemblies /Distribution/bsdtar /Distribution/Configuration/antimacro.json @@ -19,6 +21,7 @@ /Distribution/*.dylib /Distribution/*.so /Distribution/*.dll +/Distribution/*.exe /Distribution/runtimes /Distribution/nohup.out /Distribution/ref diff --git a/ModernUO.sln b/ModernUO.sln index d46c956ba..779005fbe 100644 --- a/ModernUO.sln +++ b/ModernUO.sln @@ -10,6 +10,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server.Tests", "Projects\Se EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UOContent.Tests", "Projects\UOContent.Tests\UOContent.Tests.csproj", "{3C4797F9-603E-44EF-8E8C-9275CC9EA74B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application", "Projects\Application\Application.csproj", "{E9849FA1-D4F5-4D68-A36B-249F4CB4E374}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Analyze|Any CPU = Analyze|Any CPU @@ -41,6 +43,12 @@ Global {3C4797F9-603E-44EF-8E8C-9275CC9EA74B}.Debug|Any CPU.Build.0 = Debug|Any CPU {3C4797F9-603E-44EF-8E8C-9275CC9EA74B}.Release|Any CPU.ActiveCfg = Release|Any CPU {3C4797F9-603E-44EF-8E8C-9275CC9EA74B}.Release|Any CPU.Build.0 = Release|Any CPU + {E9849FA1-D4F5-4D68-A36B-249F4CB4E374}.Analyze|Any CPU.ActiveCfg = Analyze|Any CPU + {E9849FA1-D4F5-4D68-A36B-249F4CB4E374}.Analyze|Any CPU.Build.0 = Analyze|Any CPU + {E9849FA1-D4F5-4D68-A36B-249F4CB4E374}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E9849FA1-D4F5-4D68-A36B-249F4CB4E374}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E9849FA1-D4F5-4D68-A36B-249F4CB4E374}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E9849FA1-D4F5-4D68-A36B-249F4CB4E374}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Projects/Application/Application.cs b/Projects/Application/Application.cs new file mode 100644 index 000000000..28964f02f --- /dev/null +++ b/Projects/Application/Application.cs @@ -0,0 +1,23 @@ +ο»Ώusing System.Diagnostics; +using System.Reflection; +using System.Threading; + +namespace Server; + +public class Application +{ + public static void Main(string[] args) + { + bool profiling = false; + + foreach (var a in args) + { + if (a.InsensitiveEquals("-profile")) + { + profiling = true; + } + } + + Core.Setup(profiling, Assembly.GetEntryAssembly(), Process.GetCurrentProcess()); + } +} diff --git a/Projects/Application/Application.csproj b/Projects/Application/Application.csproj new file mode 100644 index 000000000..997beb53e --- /dev/null +++ b/Projects/Application/Application.csproj @@ -0,0 +1,20 @@ +ο»Ώ + + Exe + MUO.ico + Server.Application + ModernUO + + ModernUO Server + ..\..\Distribution + 0.0.0 + Debug;Release;Analyze + Server + + + + + false + + + diff --git a/Projects/Server/MUO.ico b/Projects/Application/MUO.ico similarity index 100% rename from Projects/Server/MUO.ico rename to Projects/Application/MUO.ico diff --git a/Projects/Server.Tests/Fixtures/ServerFixture.cs b/Projects/Server.Tests/Fixtures/ServerFixture.cs index 2cbd5b5ce..38b4a4c97 100644 --- a/Projects/Server.Tests/Fixtures/ServerFixture.cs +++ b/Projects/Server.Tests/Fixtures/ServerFixture.cs @@ -1,5 +1,7 @@ using System; +using System.Diagnostics; using System.Reflection; +using System.Threading; namespace Server.Tests; @@ -8,14 +10,14 @@ internal class ServerFixture : IDisposable // Global setup static ServerFixture() { - Core.Assembly = Assembly.GetExecutingAssembly(); // Server.Tests.dll + Core.ApplicationAssembly = Assembly.GetExecutingAssembly(); // Server.Tests.dll // Load Configurations ServerConfiguration.Load(true); // Load an empty assembly list into the resolver ServerConfiguration.AssemblyDirectories.Add(Core.BaseDirectory); - AssemblyHandler.LoadAssemblies(new[]{ "ModernUO.dll" }); + AssemblyHandler.LoadAssemblies(["Server.dll"]); Core.LoopContext = new EventLoopContext(); Core.Expansion = Expansion.EJ; diff --git a/Projects/Server.Tests/Server.Tests.csproj b/Projects/Server.Tests/Server.Tests.csproj index 00fa89268..dc1d85f1d 100644 --- a/Projects/Server.Tests/Server.Tests.csproj +++ b/Projects/Server.Tests/Server.Tests.csproj @@ -2,6 +2,7 @@ false Debug;Release;Analyze + Server.Tests @@ -10,9 +11,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/Projects/Server/Main.cs b/Projects/Server/Main.cs index 9aa73b501..d245ebcb1 100644 --- a/Projects/Server/Main.cs +++ b/Projects/Server/Main.cs @@ -45,9 +45,7 @@ public static class Core private static bool _profiling; private static long _profileStart; private static long _profileTime; -#nullable enable private static bool? _isRunningFromXUnit; -#nullable restore private static int _itemCount; private static int _mobileCount; @@ -114,6 +112,7 @@ public static class Core public static TimeSpan ProfileTime => TimeSpan.FromTicks(_profileStart > 0 ? _profileTime + (Stopwatch.GetTimestamp() - _profileStart) : _profileTime); + public static Assembly ApplicationAssembly { get; set; } public static Assembly Assembly { get; set; } // Assembly file version @@ -177,10 +176,6 @@ public static class Core public static double AverageCPS => _cyclesPerSecond.Average(); - public static bool MultiProcessor { get; private set; } - - public static int ProcessorCount { get; private set; } - public static string BaseDirectory { get @@ -189,7 +184,7 @@ public static class Core { try { - _baseDirectory = Assembly.Location; + _baseDirectory = ApplicationAssembly.Location; if (_baseDirectory.Length > 0) { @@ -312,7 +307,7 @@ public static class Core _restartOnKill = restart; } - private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.IsTerminating ? "Error:" : "Warning:"); Console.WriteLine(e.ExceptionObject); @@ -378,23 +373,32 @@ public static class Core if (restart) { - if (IsWindows) + try { - Process.Start("dotnet", Assembly.Location); - } - else - { - var process = new Process + logger.Information("Restarting"); + if (IsWindows) { - StartInfo = new ProcessStartInfo + Process.Start("dotnet", ApplicationAssembly.Location); + } + else + { + var process = new Process { - FileName = "dotnet", - Arguments = Assembly.Location, - UseShellExecute = true - } - }; + StartInfo = new ProcessStartInfo + { + FileName = "dotnet", + Arguments = ApplicationAssembly.Location, + UseShellExecute = true + } + }; - process.Start(); + process.Start(); + } + logger.Information("Restart done"); + } + catch (Exception e) + { + logger.Error(e, "Restart failed"); } } @@ -417,39 +421,22 @@ public static class Core } } - public static void Main(string[] args) + public static void Setup(bool profiling, Assembly applicationAssembly, Process process) { - Console.OutputEncoding = Encoding.UTF8; + Process = process; + ApplicationAssembly = applicationAssembly; + Assembly = Assembly.GetAssembly(typeof(Core)); + Thread = Thread.CurrentThread; + LoopContext = new EventLoopContext(); + SynchronizationContext.SetSynchronizationContext(LoopContext); + Profiling = profiling; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; AppDomain.CurrentDomain.AssemblyResolve += AssemblyHandler.AssemblyResolver; - LoopContext = new EventLoopContext(); - - SynchronizationContext.SetSynchronizationContext(LoopContext); - - foreach (var a in args) - { - if (a.InsensitiveEquals("-profile")) - { - Profiling = true; - } - } - - Thread = Thread.CurrentThread; - Process = Process.GetCurrentProcess(); - Assembly = Assembly.GetEntryAssembly(); - - if (Assembly == null) - { - throw new Exception("Assembly entry is missing."); - } - - if (Thread != null) - { - Thread.Name = "Core Thread"; - } + Console.OutputEncoding = Encoding.UTF8; + Thread.Name = "Core Thread"; if (BaseDirectory.Length > 0) { @@ -476,13 +463,6 @@ public static class Core ".TrimMultiline()); Utility.PopColor(); - ProcessorCount = Environment.ProcessorCount; - - if (ProcessorCount > 1) - { - MultiProcessor = true; - } - Console.CancelKeyPress += Console_CancelKeyPressed; ServerConfiguration.Load(); @@ -496,11 +476,6 @@ public static class Core logger.Information("Running with arguments: {Args}", s); } - if (MultiProcessor) - { - logger.Information($"Optimizing for {{ProcessorCount}} processor{(ProcessorCount == 1 ? "" : "s")}", ProcessorCount); - } - var assemblyPath = Path.Join(BaseDirectory, AssembliesConfiguration); // Load UOContent.dll diff --git a/Projects/Server/Server.csproj b/Projects/Server/Server.csproj old mode 100755 new mode 100644 index 927dafc05..486691d19 --- a/Projects/Server/Server.csproj +++ b/Projects/Server/Server.csproj @@ -1,15 +1,12 @@ - Exe - MUO.ico - Server.Core - ModernUO - - ModernUO Server + ModernUO Core ..\..\Distribution 0.0.0 Debug;Release;Analyze + Server + Server @@ -32,6 +29,7 @@ + diff --git a/Projects/UOContent.Tests/Fixtures/ServerFixture.cs b/Projects/UOContent.Tests/Fixtures/ServerFixture.cs index 351e7555b..a78941054 100644 --- a/Projects/UOContent.Tests/Fixtures/ServerFixture.cs +++ b/Projects/UOContent.Tests/Fixtures/ServerFixture.cs @@ -2,48 +2,46 @@ using System; using System.Reflection; using Server.Misc; -namespace Server.Tests +namespace Server.Tests; + +internal class ServerFixture : IDisposable { - internal class ServerFixture : IDisposable + // Global setup + static ServerFixture() { - // Global setup - static ServerFixture() - { - Core.Assembly = Assembly.GetExecutingAssembly(); - Core.LoopContext = new EventLoopContext(); - Core.Expansion = Expansion.EJ; + Core.ApplicationAssembly = Assembly.GetExecutingAssembly(); + Core.LoopContext = new EventLoopContext(); + Core.Expansion = Expansion.EJ; - // Load Configurations - ServerConfiguration.Load(true); + // Load Configurations + ServerConfiguration.Load(true); - // Load UOContent.dll into the type resolver - ServerConfiguration.AssemblyDirectories.Add(Core.BaseDirectory); - var assembles = new [] { "ModernUO.dll", "UOContent.dll" }; - AssemblyHandler.LoadAssemblies(assembles); + // Load UOContent.dll into the type resolver + ServerConfiguration.AssemblyDirectories.Add(Core.BaseDirectory); + AssemblyHandler.LoadAssemblies(["Server.dll", "UOContent.dll"]); - // Load Skills - SkillsInfo.Configure(); + // Load Skills + SkillsInfo.Configure(); - // Configure / Initialize - TestMapDefinitions.ConfigureTestMapDefinitions(); + // Configure / Initialize + TestMapDefinitions.ConfigureTestMapDefinitions(); - // Configure the world - World.Configure(); + // Configure the world + World.Configure(); - Timer.Init(0); + Timer.Init(0); - // Configure Races - RaceDefinitions.Configure(); + // Configure Races + RaceDefinitions.Configure(); - // Load the world - World.Load(); + // Load the world + World.Load(); - World.ExitSerializationThreads(); - } + World.ExitSerializationThreads(); + } - public void Dispose() - { - Timer.Init(0); - } + public void Dispose() + { + Timer.Init(0); } } diff --git a/Projects/UOContent.Tests/Tests/Accounting/Security/PasswordProtectionTest.cs b/Projects/UOContent.Tests/Tests/Accounting/Security/PasswordProtectionTest.cs index 10e747cb0..7b99f1996 100644 --- a/Projects/UOContent.Tests/Tests/Accounting/Security/PasswordProtectionTest.cs +++ b/Projects/UOContent.Tests/Tests/Accounting/Security/PasswordProtectionTest.cs @@ -3,20 +3,20 @@ using Server.Accounting; using Server.Accounting.Security; using Xunit; -namespace Server.Tests.Accounting.Security -{ - public class PasswordProtectionTest - { - private const string plainPassword = "hello-good-sir"; +namespace Server.Tests.Accounting.Security; - [Theory] - [InlineData(typeof(Argon2PasswordProtection), null)] - [InlineData(typeof(PBKDF2PasswordProtection), null)] - [InlineData(typeof(HashAlgorithmPasswordProtection), "MD5")] - [InlineData(typeof(HashAlgorithmPasswordProtection), "SHA1")] - [InlineData(typeof(HashAlgorithmPasswordProtection), "SHA2")] - public void TestValidates(Type protectionType, string algorithmType) - { +public class PasswordProtectionTest +{ + private const string plainPassword = "hello-good-sir"; + + [Theory] + [InlineData(typeof(Argon2PasswordProtection), null)] + [InlineData(typeof(PBKDF2PasswordProtection), null)] + [InlineData(typeof(HashAlgorithmPasswordProtection), "MD5")] + [InlineData(typeof(HashAlgorithmPasswordProtection), "SHA1")] + [InlineData(typeof(HashAlgorithmPasswordProtection), "SHA2")] + public void TestValidates(Type protectionType, string algorithmType) + { IPasswordProtection passwordProtection; if (protectionType == typeof(HashAlgorithmPasswordProtection)) { @@ -42,14 +42,14 @@ namespace Server.Tests.Accounting.Security Assert.True(passwordProtection.ValidatePassword(encryptedPassword, plainPassword)); } - [Theory] - [InlineData(typeof(Argon2PasswordProtection), null)] - [InlineData(typeof(PBKDF2PasswordProtection), null)] - [InlineData(typeof(HashAlgorithmPasswordProtection), "MD5")] - [InlineData(typeof(HashAlgorithmPasswordProtection), "SHA1")] - [InlineData(typeof(HashAlgorithmPasswordProtection), "SHA2")] - public void TestPasswordDoesNotValidate(Type protectionType, string algorithmType) - { + [Theory] + [InlineData(typeof(Argon2PasswordProtection), null)] + [InlineData(typeof(PBKDF2PasswordProtection), null)] + [InlineData(typeof(HashAlgorithmPasswordProtection), "MD5")] + [InlineData(typeof(HashAlgorithmPasswordProtection), "SHA1")] + [InlineData(typeof(HashAlgorithmPasswordProtection), "SHA2")] + public void TestPasswordDoesNotValidate(Type protectionType, string algorithmType) + { IPasswordProtection passwordProtection; if (protectionType == typeof(HashAlgorithmPasswordProtection)) { @@ -74,5 +74,4 @@ namespace Server.Tests.Accounting.Security Assert.False(passwordProtection.ValidatePassword(encryptedPassword, "Not the same password")); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Engines/Chat/ChatPacketTests.cs b/Projects/UOContent.Tests/Tests/Engines/Chat/ChatPacketTests.cs index c1d0230e9..7ecb91c62 100644 --- a/Projects/UOContent.Tests/Tests/Engines/Chat/ChatPacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Engines/Chat/ChatPacketTests.cs @@ -3,15 +3,15 @@ using Server.Tests; using Server.Tests.Network; using Xunit; -namespace UOContent.Tests +namespace UOContent.Tests; + +public class ChatPacketTests { - public class ChatPacketTests + [Theory] + [InlineData(null, 100, "some param", "some other param")] + [InlineData("ENU", 200, "a third param", "another param")] + public void TestSendChatMessage(string lang, int number, string param1, string param2) { - [Theory] - [InlineData(null, 100, "some param", "some other param")] - [InlineData("ENU", 200, "a third param", "another param")] - public void TestSendChatMessage(string lang, int number, string param1, string param2) - { var expected = new ChatMessagePacket(lang, number, param1, param2).Compile(); var ns = PacketTestUtilities.CreateTestNetState(); @@ -20,5 +20,4 @@ namespace UOContent.Tests var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Engines/Chat/Packets.cs b/Projects/UOContent.Tests/Tests/Engines/Chat/Packets.cs index e3ed863d8..58c872652 100644 --- a/Projects/UOContent.Tests/Tests/Engines/Chat/Packets.cs +++ b/Projects/UOContent.Tests/Tests/Engines/Chat/Packets.cs @@ -1,11 +1,11 @@ using Server.Network; -namespace Server.Engines.Chat +namespace Server.Engines.Chat; + +public sealed class ChatMessagePacket : Packet { - public sealed class ChatMessagePacket : Packet + public ChatMessagePacket(string lang, int number, string param1, string param2) : base(0xB2) { - public ChatMessagePacket(string lang, int number, string param1, string param2) : base(0xB2) - { param1 ??= string.Empty; param2 ??= string.Empty; @@ -25,5 +25,4 @@ namespace Server.Engines.Chat Stream.WriteBigUniNull(param1); Stream.WriteBigUniNull(param2); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Engines/Help/HelpTopic.cs b/Projects/UOContent.Tests/Tests/Engines/Help/HelpTopic.cs index 0e571838c..235fb5c69 100644 --- a/Projects/UOContent.Tests/Tests/Engines/Help/HelpTopic.cs +++ b/Projects/UOContent.Tests/Tests/Engines/Help/HelpTopic.cs @@ -1,9 +1,9 @@ -namespace Server.Network +namespace Server.Network; + +public class DisplayHelpTopic : Packet { - public class DisplayHelpTopic : Packet + public DisplayHelpTopic(int topicID, bool display) : base(0xBF) { - public DisplayHelpTopic(int topicID, bool display) : base(0xBF) - { EnsureCapacity(11); Stream.Write((short)0x17); @@ -11,5 +11,4 @@ namespace Server.Network Stream.Write(topicID); Stream.Write(display); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Engines/Help/TestHelpTopicPacket.cs b/Projects/UOContent.Tests/Tests/Engines/Help/TestHelpTopicPacket.cs index b51afa5a7..feca1c09a 100644 --- a/Projects/UOContent.Tests/Tests/Engines/Help/TestHelpTopicPacket.cs +++ b/Projects/UOContent.Tests/Tests/Engines/Help/TestHelpTopicPacket.cs @@ -4,15 +4,15 @@ using Server.Tests; using Server.Tests.Network; using Xunit; -namespace UOContent.Tests +namespace UOContent.Tests; + +public class TestHelpTopicPacket { - public class TestHelpTopicPacket + [Theory] + [InlineData(HelpTopic.Healing, false)] + [InlineData(HelpTopic.EmptyingBowl, true)] + public void TestDisplayHelpTopic(int topic, bool display) { - [Theory] - [InlineData(HelpTopic.Healing, false)] - [InlineData(HelpTopic.EmptyingBowl, true)] - public void TestDisplayHelpTopic(int topic, bool display) - { var expected = new DisplayHelpTopic(topic, display).Compile(); var ns = PacketTestUtilities.CreateTestNetState(); @@ -21,5 +21,4 @@ namespace UOContent.Tests var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Engines/ML Quests/Packets.cs b/Projects/UOContent.Tests/Tests/Engines/ML Quests/Packets.cs index 0c723a547..8fd383e19 100644 --- a/Projects/UOContent.Tests/Tests/Engines/ML Quests/Packets.cs +++ b/Projects/UOContent.Tests/Tests/Engines/ML Quests/Packets.cs @@ -1,28 +1,27 @@ using Server.Network; -namespace Server.Engines.MLQuests +namespace Server.Engines.MLQuests; + +public sealed class RaceChanger : Packet { - public sealed class RaceChanger : Packet + public RaceChanger(bool female, Race targetRace) : base(0xBF) { - public RaceChanger(bool female, Race targetRace) : base(0xBF) - { EnsureCapacity(7); Stream.Write((short)0x2A); Stream.Write((byte)(female ? 1 : 0)); Stream.Write((byte)(targetRace.RaceID + 1)); } - } +} - public sealed class CloseRaceChanger : Packet +public sealed class CloseRaceChanger : Packet +{ + public CloseRaceChanger() : base(0xBF) { - public CloseRaceChanger() : base(0xBF) - { EnsureCapacity(7); Stream.Write((short)0x2A); Stream.Write((byte)0); Stream.Write((byte)0xFF); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Engines/Party/Packets.cs b/Projects/UOContent.Tests/Tests/Engines/Party/Packets.cs index e4601e651..ddda0685c 100644 --- a/Projects/UOContent.Tests/Tests/Engines/Party/Packets.cs +++ b/Projects/UOContent.Tests/Tests/Engines/Party/Packets.cs @@ -1,11 +1,11 @@ using Server.Network; -namespace Server.Engines.PartySystem +namespace Server.Engines.PartySystem; + +public sealed class PartyEmptyList : Packet { - public sealed class PartyEmptyList : Packet + public PartyEmptyList(Serial m) : base(0xBF) { - public PartyEmptyList(Serial m) : base(0xBF) - { EnsureCapacity(7); Stream.Write((short)0x0006); @@ -13,12 +13,12 @@ namespace Server.Engines.PartySystem Stream.Write((byte)0); Stream.Write(m); } - } +} - public sealed class PartyMemberList : Packet +public sealed class PartyMemberList : Packet +{ + public PartyMemberList(Party p) : base(0xBF) { - public PartyMemberList(Party p) : base(0xBF) - { EnsureCapacity(7 + p.Count * 4); Stream.Write((short)0x0006); @@ -30,12 +30,12 @@ namespace Server.Engines.PartySystem Stream.Write(p[i].Mobile.Serial); } } - } +} - public sealed class PartyRemoveMember : Packet +public sealed class PartyRemoveMember : Packet +{ + public PartyRemoveMember(Serial removed, Party p) : base(0xBF) { - public PartyRemoveMember(Serial removed, Party p) : base(0xBF) - { EnsureCapacity(11 + p.Count * 4); Stream.Write((short)0x0006); @@ -49,12 +49,12 @@ namespace Server.Engines.PartySystem Stream.Write(p[i].Mobile.Serial); } } - } +} - public sealed class PartyTextMessage : Packet +public sealed class PartyTextMessage : Packet +{ + public PartyTextMessage(bool toAll, Serial from, string text) : base(0xBF) { - public PartyTextMessage(bool toAll, Serial from, string text) : base(0xBF) - { text ??= ""; EnsureCapacity(12 + text.Length * 2); @@ -64,17 +64,16 @@ namespace Server.Engines.PartySystem Stream.Write(from); Stream.WriteBigUniNull(text); } - } +} - public sealed class PartyInvitation : Packet +public sealed class PartyInvitation : Packet +{ + public PartyInvitation(Serial leader) : base(0xBF) { - public PartyInvitation(Serial leader) : base(0xBF) - { EnsureCapacity(10); Stream.Write((short)0x0006); Stream.Write((byte)0x07); Stream.Write(leader); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Engines/Party/PartyPacketTests.cs b/Projects/UOContent.Tests/Tests/Engines/Party/PartyPacketTests.cs index 95b4b5b06..a61a729b8 100644 --- a/Projects/UOContent.Tests/Tests/Engines/Party/PartyPacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Engines/Party/PartyPacketTests.cs @@ -4,13 +4,13 @@ using Server.Tests; using Server.Tests.Network; using Xunit; -namespace UOContent.Tests +namespace UOContent.Tests; + +public class PartyPacketTests : IClassFixture { - public class PartyPacketTests : IClassFixture + [Fact] + public void TestPartyEmptyList() { - [Fact] - public void TestPartyEmptyList() - { Serial m = (Serial)0x1024u; var expected = new PartyEmptyList(m).Compile(); @@ -22,9 +22,9 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Fact] - public void TestPartyRemoveMember() - { + [Fact] + public void TestPartyRemoveMember() + { var leader = new Mobile((Serial)0x1024u); leader.DefaultMobileInit(); @@ -43,9 +43,9 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Fact] - public void TestPartyMemberList() - { + [Fact] + public void TestPartyMemberList() + { var leader = new Mobile((Serial)0x1024u); leader.DefaultMobileInit(); @@ -64,11 +64,11 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void TestPartyTextMessage(bool toAll) - { + [Theory] + [InlineData(true)] + [InlineData(false)] + public void TestPartyTextMessage(bool toAll) + { Serial serial = (Serial)0x1024u; var text = "[Party] Stuff Happens"; @@ -81,9 +81,9 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Fact] - public void TestPartyInvitation() - { + [Fact] + public void TestPartyInvitation() + { Serial m = (Serial)0x1024u; var expected = new PartyInvitation(m).Compile(); @@ -94,5 +94,4 @@ namespace UOContent.Tests var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Engines/Veteran Rewards/Character Statue Maker/CharacterStatuePacketTests.cs b/Projects/UOContent.Tests/Tests/Engines/Veteran Rewards/Character Statue Maker/CharacterStatuePacketTests.cs index 6d31b85ab..42f43b207 100644 --- a/Projects/UOContent.Tests/Tests/Engines/Veteran Rewards/Character Statue Maker/CharacterStatuePacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Engines/Veteran Rewards/Character Statue Maker/CharacterStatuePacketTests.cs @@ -5,14 +5,14 @@ using Server.Tests; using Server.Tests.Network; using Xunit; -namespace UOContent.Tests +namespace UOContent.Tests; + +public class CharacterStatuePacketTests { - public class CharacterStatuePacketTests + [Theory] + [InlineData(0x1024u, 1, 100, 200)] + public void TestSendStatueAnimation(uint s, int status, int anim, int frame) { - [Theory] - [InlineData(0x1024u, 1, 100, 200)] - public void TestSendStatueAnimation(uint s, int status, int anim, int frame) - { var expected = new UpdateStatueAnimation((Serial)s, status, anim, frame).Compile(); var ns = PacketTestUtilities.CreateTestNetState(); @@ -21,5 +21,4 @@ namespace UOContent.Tests var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Engines/Veteran Rewards/Character Statue Maker/Packets.cs b/Projects/UOContent.Tests/Tests/Engines/Veteran Rewards/Character Statue Maker/Packets.cs index 8cc0b4b50..a98e69cbc 100644 --- a/Projects/UOContent.Tests/Tests/Engines/Veteran Rewards/Character Statue Maker/Packets.cs +++ b/Projects/UOContent.Tests/Tests/Engines/Veteran Rewards/Character Statue Maker/Packets.cs @@ -1,9 +1,9 @@ -namespace Server.Network +namespace Server.Network; + +public class UpdateStatueAnimation : Packet { - public class UpdateStatueAnimation : Packet + public UpdateStatueAnimation(Serial serial, int status, int animation, int frame) : base(0xBF, 17) { - public UpdateStatueAnimation(Serial serial, int status, int animation, int frame) : base(0xBF, 17) - { Stream.Write((short)0x11); Stream.Write((short)0x19); Stream.Write((byte)0x5); @@ -16,5 +16,4 @@ namespace Server.Network Stream.Write((byte)0); Stream.Write((byte)frame); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Items/Books/BookPacketTests.cs b/Projects/UOContent.Tests/Tests/Items/Books/BookPacketTests.cs index 2cb865293..65ebb162b 100644 --- a/Projects/UOContent.Tests/Tests/Items/Books/BookPacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Items/Books/BookPacketTests.cs @@ -5,24 +5,24 @@ using Server.Tests; using Server.Tests.Network; using Xunit; -namespace UOContent.Tests +namespace UOContent.Tests; + +public class TestBook : BaseBook { - public class TestBook : BaseBook + public TestBook(int itemID, int pageCount = 20, bool writable = true) : base(itemID, pageCount, writable) { - public TestBook(int itemID, int pageCount = 20, bool writable = true) : base(itemID, pageCount, writable) - { } - public TestBook(int itemID, string title, string author, int pageCount, bool writable) : base(itemID, title, author, pageCount, writable) - { + public TestBook(int itemID, string title, string author, int pageCount, bool writable) : base(itemID, title, author, pageCount, writable) + { } - public TestBook(int itemID, bool writable) : base(itemID, writable) - { + public TestBook(int itemID, bool writable) : base(itemID, writable) + { } - public TestBook(Serial serial) : base(serial) - { + public TestBook(Serial serial) : base(serial) + { Pages = new BookPageInfo[20]; for (var i = 0; i < Pages.Length; ++i) @@ -30,14 +30,14 @@ namespace UOContent.Tests Pages[i] = new BookPageInfo(); } } - } +} - public class BookPacketTests : IClassFixture +public class BookPacketTests : IClassFixture +{ + [Theory] + [InlineData("πŸ…΅πŸ…°πŸ…½πŸ…²πŸ†ˆ πŸ†ƒπŸ…΄πŸ†‡πŸ†ƒ Author", "πŸ…΅πŸ…°πŸ…½πŸ…²πŸ†ˆ πŸ†ƒπŸ…΄πŸ†‡πŸ†ƒ Title")] + public void TestBookCover(string author, string title) { - [Theory] - [InlineData("πŸ…΅πŸ…°πŸ…½πŸ…²πŸ†ˆ πŸ†ƒπŸ…΄πŸ†‡πŸ†ƒ Author", "πŸ…΅πŸ…°πŸ…½πŸ…²πŸ†ˆ πŸ†ƒπŸ…΄πŸ†‡πŸ†ƒ Title")] - public void TestBookCover(string author, string title) - { var m = new Mobile((Serial)0x1); m.DefaultMobileInit(); @@ -53,9 +53,9 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Fact] - public void TestBookContent() - { + [Fact] + public void TestBookContent() + { var m = new Mobile((Serial)0x1); m.DefaultMobileInit(); @@ -89,5 +89,4 @@ namespace UOContent.Tests var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Items/Books/Packets.cs b/Projects/UOContent.Tests/Tests/Items/Books/Packets.cs index aca4013c2..c098729c6 100644 --- a/Projects/UOContent.Tests/Tests/Items/Books/Packets.cs +++ b/Projects/UOContent.Tests/Tests/Items/Books/Packets.cs @@ -1,12 +1,12 @@ using Server.Items; using Server.Text; -namespace Server.Network +namespace Server.Network; + +public sealed class BookPageDetails : Packet { - public sealed class BookPageDetails : Packet + public BookPageDetails(BaseBook book) : base(0x66) { - public BookPageDetails(BaseBook book) : base(0x66) - { EnsureCapacity(256); Stream.Write(book.Serial); @@ -28,12 +28,12 @@ namespace Server.Network } } } - } +} - public sealed class BookHeader : Packet +public sealed class BookHeader : Packet +{ + public BookHeader(Mobile from, BaseBook book) : base(0xD4) { - public BookHeader(Mobile from, BaseBook book) : base(0xD4) - { var title = book.Title ?? ""; var author = book.Author ?? ""; @@ -55,5 +55,4 @@ namespace Server.Network Stream.Write(authorBuffer, 0, authorBuffer.Length); Stream.Write((byte)0); // terminate } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Items/Bulletin Boards/BulletinBoardPacketTests.cs b/Projects/UOContent.Tests/Tests/Items/Bulletin Boards/BulletinBoardPacketTests.cs index 6f53b1278..cf2719d89 100644 --- a/Projects/UOContent.Tests/Tests/Items/Bulletin Boards/BulletinBoardPacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Items/Bulletin Boards/BulletinBoardPacketTests.cs @@ -5,17 +5,17 @@ using Server.Tests; using Server.Tests.Network; using Xunit; -namespace UOContent.Tests +namespace UOContent.Tests; + +[Collection("Sequential Tests")] +public class BulletinBoardPacketTests : IClassFixture { - [Collection("Sequential Tests")] - public class BulletinBoardPacketTests : IClassFixture + [Theory] + [InlineData("Test Name")] + [InlineData(null)] + [InlineData("πŸ…΅πŸ…°πŸ…½πŸ…²πŸ†ˆ πŸ†ƒπŸ…΄πŸ†‡πŸ†ƒ")] + public void TestSendBBDisplayBoard(string boardName) { - [Theory] - [InlineData("Test Name")] - [InlineData(null)] - [InlineData("πŸ…΅πŸ…°πŸ…½πŸ…²πŸ†ˆ πŸ†ƒπŸ…΄πŸ†‡πŸ†ƒ")] - public void TestSendBBDisplayBoard(string boardName) - { var bb = new TestBulletinBoard(0x234) { BoardName = boardName }; var expected = new BBDisplayBoard(bb).Compile(); @@ -27,15 +27,15 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Theory] - [InlineData("The Subject", false, "First Line", "Second Line", "Third Line")] - [InlineData("", false, "")] - [InlineData("πŸ…΅πŸ…°πŸ…½πŸ…²πŸ†ˆ πŸ†ƒπŸ…΄πŸ†‡πŸ†ƒ", false, "First Line", "Second Line")] - [InlineData("The Subject", true, "First Line", "Second Line", "Third Line")] - [InlineData("", true, "")] - [InlineData("πŸ…΅πŸ…°πŸ…½πŸ…²πŸ†ˆ πŸ†ƒπŸ…΄πŸ†‡πŸ†ƒ", true, "First Line", "Second Line")] - public void TestSendBBHeaderMessage(string subject, bool content, params string[] lines) - { + [Theory] + [InlineData("The Subject", false, "First Line", "Second Line", "Third Line")] + [InlineData("", false, "")] + [InlineData("πŸ…΅πŸ…°πŸ…½πŸ…²πŸ†ˆ πŸ†ƒπŸ…΄πŸ†‡πŸ†ƒ", false, "First Line", "Second Line")] + [InlineData("The Subject", true, "First Line", "Second Line", "Third Line")] + [InlineData("", true, "")] + [InlineData("πŸ…΅πŸ…°πŸ…½πŸ…²πŸ†ˆ πŸ†ƒπŸ…΄πŸ†‡πŸ†ƒ", true, "First Line", "Second Line")] + public void TestSendBBHeaderMessage(string subject, bool content, params string[] lines) + { var poster = new Mobile((Serial)0x1024u) { Name = "Kamron" }; poster.DefaultMobileInit(); @@ -53,16 +53,15 @@ namespace UOContent.Tests var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); } - } - - internal class TestBulletinBoard : BaseBulletinBoard - { - public TestBulletinBoard(int itemID) : base(itemID) - { - } - - public TestBulletinBoard(Serial serial) : base(serial) - { - } - } } + +internal class TestBulletinBoard : BaseBulletinBoard +{ + public TestBulletinBoard(int itemID) : base(itemID) + { + } + + public TestBulletinBoard(Serial serial) : base(serial) + { + } +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Items/Games/Mahjong/MahjongPacketTests.cs b/Projects/UOContent.Tests/Tests/Items/Games/Mahjong/MahjongPacketTests.cs index d1ced2d71..d5e230c68 100644 --- a/Projects/UOContent.Tests/Tests/Items/Games/Mahjong/MahjongPacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Items/Games/Mahjong/MahjongPacketTests.cs @@ -4,14 +4,14 @@ using Server.Tests; using Server.Tests.Network; using Xunit; -namespace UOContent.Tests +namespace UOContent.Tests; + +[Collection("Sequential Tests")] +public class MahjongPacketTests : IClassFixture { - [Collection("Sequential Tests")] - public class MahjongPacketTests : IClassFixture + [Fact] + public void TestMahjongJoinGame() { - [Fact] - public void TestMahjongJoinGame() - { Serial game = (Serial)0x1024u; var expected = new MahjongJoinGame(game).Compile(); @@ -23,11 +23,11 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void TestMahjongPlayersInfo(bool showScores) - { + [Theory] + [InlineData(true)] + [InlineData(false)] + public void TestMahjongPlayersInfo(bool showScores) + { var m = new Mobile((Serial)0x1); m.DefaultMobileInit(); @@ -43,13 +43,13 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Theory] - [InlineData(true, true)] - [InlineData(true, false)] - [InlineData(false, true)] - [InlineData(false, false)] - public void TestMahjongGeneralInfo(bool showScores, bool spectatorVision) - { + [Theory] + [InlineData(true, true)] + [InlineData(true, false)] + [InlineData(false, true)] + [InlineData(false, false)] + public void TestMahjongGeneralInfo(bool showScores, bool spectatorVision) + { var game = new MahjongGame { ShowScores = showScores, SpectatorVision = spectatorVision}; var expected = new MahjongGeneralInfo(game).Compile(); @@ -61,11 +61,11 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void TestMahjongTilesInfo(bool spectatorVision) - { + [Theory] + [InlineData(true)] + [InlineData(false)] + public void TestMahjongTilesInfo(bool spectatorVision) + { var m = new Mobile((Serial)0x1); m.DefaultMobileInit(); @@ -81,11 +81,11 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void TestMahjongTileInfo(bool spectatorVision) - { + [Theory] + [InlineData(true)] + [InlineData(false)] + public void TestMahjongTileInfo(bool spectatorVision) + { var m = new Mobile((Serial)0x1); m.DefaultMobileInit(); @@ -101,9 +101,9 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Fact] - public void TestMahjongRelieve() - { + [Fact] + public void TestMahjongRelieve() + { Serial game = (Serial)0x1024u; var expected = new MahjongRelieve(game).Compile(); @@ -114,5 +114,4 @@ namespace UOContent.Tests var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Items/Games/Mahjong/Packets.cs b/Projects/UOContent.Tests/Tests/Items/Games/Mahjong/Packets.cs index c7c817279..6e9f83a80 100644 --- a/Projects/UOContent.Tests/Tests/Items/Games/Mahjong/Packets.cs +++ b/Projects/UOContent.Tests/Tests/Items/Games/Mahjong/Packets.cs @@ -1,24 +1,24 @@ using System.IO; using Server.Network; -namespace Server.Engines.Mahjong +namespace Server.Engines.Mahjong; + +public sealed class MahjongJoinGame : Packet { - public sealed class MahjongJoinGame : Packet + public MahjongJoinGame(Serial game) : base(0xDA) { - public MahjongJoinGame(Serial game) : base(0xDA) - { EnsureCapacity(9); Stream.Write(game); Stream.Write((byte)0); Stream.Write((byte)0x19); } - } +} - public sealed class MahjongPlayersInfo : Packet +public sealed class MahjongPlayersInfo : Packet +{ + public MahjongPlayersInfo(MahjongGame game, Mobile to) : base(0xDA) { - public MahjongPlayersInfo(MahjongGame game, Mobile to) : base(0xDA) - { var players = game.Players; EnsureCapacity(11 + 45 * players.Seats); @@ -86,12 +86,12 @@ namespace Server.Engines.Mahjong Stream.Write((byte)n); } } - } +} - public sealed class MahjongGeneralInfo : Packet +public sealed class MahjongGeneralInfo : Packet +{ + public MahjongGeneralInfo(MahjongGame game) : base(0xDA) { - public MahjongGeneralInfo(MahjongGame game) : base(0xDA) - { EnsureCapacity(13); Stream.Write(game.Serial); @@ -114,12 +114,12 @@ namespace Server.Engines.Mahjong Stream.Write((short)game.WallBreakIndicator.Position.Y); Stream.Write((short)game.WallBreakIndicator.Position.X); } - } +} - public sealed class MahjongTilesInfo : Packet +public sealed class MahjongTilesInfo : Packet +{ + public MahjongTilesInfo(MahjongGame game, Mobile to) : base(0xDA) { - public MahjongTilesInfo(MahjongGame game, Mobile to) : base(0xDA) - { var tiles = game.Tiles; var players = game.Players; @@ -162,12 +162,12 @@ namespace Server.Engines.Mahjong Stream.Write(tile.Flipped ? (byte)0x10 : (byte)0x0); } } - } +} - public sealed class MahjongTileInfo : Packet +public sealed class MahjongTileInfo : Packet +{ + public MahjongTileInfo(MahjongTile tile, Mobile to) : base(0xDA) { - public MahjongTileInfo(MahjongTile tile, Mobile to) : base(0xDA) - { var game = tile.Game; var players = game.Players; @@ -205,17 +205,16 @@ namespace Server.Engines.Mahjong Stream.Write(tile.Flipped ? (byte)0x10 : (byte)0x0); } - } +} - public sealed class MahjongRelieve : Packet +public sealed class MahjongRelieve : Packet +{ + public MahjongRelieve(Serial game) : base(0xDA) { - public MahjongRelieve(Serial game) : base(0xDA) - { EnsureCapacity(9); Stream.Write(game); Stream.Write((byte)0); Stream.Write((byte)0x1A); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Items/Maps/Packets.cs b/Projects/UOContent.Tests/Tests/Items/Maps/Packets.cs index ae5a9fb63..5198abcbf 100644 --- a/Projects/UOContent.Tests/Tests/Items/Maps/Packets.cs +++ b/Projects/UOContent.Tests/Tests/Items/Maps/Packets.cs @@ -1,11 +1,11 @@ using Server.Network; -namespace Server.Items +namespace Server.Items; + +public sealed class MapDetails : Packet { - public sealed class MapDetails : Packet + public MapDetails(MapItem map) : base(0x90, 19) { - public MapDetails(MapItem map) : base(0x90, 19) - { Stream.Write(map.Serial); Stream.Write((short)0x139D); Stream.Write((short)map.Bounds.Start.X); @@ -15,12 +15,12 @@ namespace Server.Items Stream.Write((short)map.Width); Stream.Write((short)map.Height); } - } +} - public sealed class MapDetailsNew : Packet +public sealed class MapDetailsNew : Packet +{ + public MapDetailsNew(MapItem map) : base(0xF5, 21) { - public MapDetailsNew(MapItem map) : base(0xF5, 21) - { Stream.Write(map.Serial); Stream.Write((short)0x139D); Stream.Write((short)map.Bounds.Start.X); @@ -31,38 +31,37 @@ namespace Server.Items Stream.Write((short)map.Height); Stream.Write((short)(map.Facet?.MapID ?? 0)); } - } +} - public class MapCommand : Packet +public class MapCommand : Packet +{ + public MapCommand(MapItem map, int command, int number, int x, int y) : base(0x56, 11) { - public MapCommand(MapItem map, int command, int number, int x, int y) : base(0x56, 11) - { Stream.Write(map.Serial); Stream.Write((byte)command); Stream.Write((byte)number); Stream.Write((short)x); Stream.Write((short)y); } - } - - public sealed class MapDisplay : MapCommand - { - public MapDisplay(MapItem map) : base(map, 5, 0, 0, 0) - { - } - } - - public sealed class MapAddPin : MapCommand - { - public MapAddPin(MapItem map, Point2D point) : base(map, 1, 0, point.X, point.Y) - { - } - } - - public sealed class MapSetEditable : MapCommand - { - public MapSetEditable(MapItem map, bool editable) : base(map, 7, editable ? 1 : 0, 0, 0) - { - } - } } + +public sealed class MapDisplay : MapCommand +{ + public MapDisplay(MapItem map) : base(map, 5, 0, 0, 0) + { + } +} + +public sealed class MapAddPin : MapCommand +{ + public MapAddPin(MapItem map, Point2D point) : base(map, 1, 0, point.X, point.Y) + { + } +} + +public sealed class MapSetEditable : MapCommand +{ + public MapSetEditable(MapItem map, bool editable) : base(map, 7, editable ? 1 : 0, 0, 0) + { + } +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Items/Maps/TestMapItemPackets.cs b/Projects/UOContent.Tests/Tests/Items/Maps/TestMapItemPackets.cs index bdd3a755d..67e1a6188 100644 --- a/Projects/UOContent.Tests/Tests/Items/Maps/TestMapItemPackets.cs +++ b/Projects/UOContent.Tests/Tests/Items/Maps/TestMapItemPackets.cs @@ -5,16 +5,16 @@ using Server.Tests; using Server.Tests.Network; using Xunit; -namespace UOContent.Tests +namespace UOContent.Tests; + +[Collection("Sequential Tests")] +public class TestMapItemPackets : IClassFixture { - [Collection("Sequential Tests")] - public class TestMapItemPackets : IClassFixture + [Theory] + [InlineData(ProtocolChanges.NewCharacterList)] + [InlineData(ProtocolChanges.None)] + public void TestSendMapDetails(ProtocolChanges changes) { - [Theory] - [InlineData(ProtocolChanges.NewCharacterList)] - [InlineData(ProtocolChanges.None)] - public void TestSendMapDetails(ProtocolChanges changes) - { var mapItem = new MapItem(Map.Trammel); var ns = PacketTestUtilities.CreateTestNetState(); @@ -28,13 +28,13 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Theory] - [InlineData(5, 0, 0, 0)] - [InlineData(1, 0, 100, 200)] - [InlineData(7, 1, 0, 0)] - [InlineData(7, 0, 0, 0)] - public void TestSendMapCommand(int command, int number, int x, int y) - { + [Theory] + [InlineData(5, 0, 0, 0)] + [InlineData(1, 0, 100, 200)] + [InlineData(7, 1, 0, 0)] + [InlineData(7, 0, 0, 0)] + public void TestSendMapCommand(int command, int number, int x, int y) + { var mapItem = new MapItem(Map.Trammel); var expected = new MapCommand(mapItem, command, number, x, y).Compile(); @@ -45,5 +45,4 @@ namespace UOContent.Tests var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Items/Misc/Corpses/CorpsePacketTests.cs b/Projects/UOContent.Tests/Tests/Items/Misc/Corpses/CorpsePacketTests.cs index e6388d10f..874574f19 100644 --- a/Projects/UOContent.Tests/Tests/Items/Misc/Corpses/CorpsePacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Items/Misc/Corpses/CorpsePacketTests.cs @@ -5,14 +5,14 @@ using Server.Tests; using Server.Tests.Network; using Xunit; -namespace UOContent.Tests +namespace UOContent.Tests; + +[Collection("Sequential Tests")] +public class CorpsePacketTests : IClassFixture { - [Collection("Sequential Tests")] - public class CorpsePacketTests : IClassFixture + [Fact] + public void TestCorpseEquipPacket() { - [Fact] - public void TestCorpseEquipPacket() - { var m = new Mobile((Serial)0x1); m.DefaultMobileInit(); @@ -30,11 +30,11 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Theory] - [InlineData(ProtocolChanges.None)] - [InlineData(ProtocolChanges.ContainerGridLines)] - public void TestCorpseContainerPacket(ProtocolChanges changes) - { + [Theory] + [InlineData(ProtocolChanges.None)] + [InlineData(ProtocolChanges.ContainerGridLines)] + public void TestCorpseContainerPacket(ProtocolChanges changes) + { var m = new Mobile((Serial)0x1); m.DefaultMobileInit(); @@ -53,5 +53,4 @@ namespace UOContent.Tests var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Items/Misc/Corpses/Packets.cs b/Projects/UOContent.Tests/Tests/Items/Misc/Corpses/Packets.cs index 35def09c6..725203c8a 100644 --- a/Projects/UOContent.Tests/Tests/Items/Misc/Corpses/Packets.cs +++ b/Projects/UOContent.Tests/Tests/Items/Misc/Corpses/Packets.cs @@ -1,12 +1,12 @@ using System.IO; using Server.Items; -namespace Server.Network +namespace Server.Network; + +public sealed class CorpseEquip : Packet { - public sealed class CorpseEquip : Packet + public CorpseEquip(Mobile beholder, Corpse beheld) : base(0x89) { - public CorpseEquip(Mobile beholder, Corpse beheld) : base(0x89) - { var list = beheld.EquipItems; var count = list.Count; @@ -49,13 +49,13 @@ namespace Server.Network Stream.Write((byte)Layer.Invalid); } - } +} - public sealed class CorpseContent : Packet +public sealed class CorpseContent : Packet +{ + public CorpseContent(Mobile beholder, Corpse beheld) + : base(0x3C) { - public CorpseContent(Mobile beholder, Corpse beheld) - : base(0x3C) - { var items = beheld.EquipItems; var count = items.Count; @@ -127,13 +127,13 @@ namespace Server.Network Stream.Seek(pos, SeekOrigin.Begin); Stream.Write((ushort)written); } - } +} - public sealed class CorpseContent6017 : Packet +public sealed class CorpseContent6017 : Packet +{ + public CorpseContent6017(Mobile beholder, Corpse beheld) + : base(0x3C) { - public CorpseContent6017(Mobile beholder, Corpse beheld) - : base(0x3C) - { var items = beheld.EquipItems; var count = items.Count; @@ -208,5 +208,4 @@ namespace Server.Network Stream.Seek(pos, SeekOrigin.Begin); Stream.Write((ushort)written); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Items/Weapons/Abilities/WeaponAbilityPacketTests.cs b/Projects/UOContent.Tests/Tests/Items/Weapons/Abilities/WeaponAbilityPacketTests.cs index 13b1e8944..ecc1b4115 100644 --- a/Projects/UOContent.Tests/Tests/Items/Weapons/Abilities/WeaponAbilityPacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Items/Weapons/Abilities/WeaponAbilityPacketTests.cs @@ -3,17 +3,17 @@ using Server.Tests; using Server.Tests.Network; using Xunit; -namespace UOContent.Tests +namespace UOContent.Tests; + +public class WeaponAbilityPacketTests { - public class WeaponAbilityPacketTests + [Theory] + [InlineData(0, true)] + [InlineData(0, false)] + [InlineData(100, true)] + [InlineData(1000, false)] + public void TestSpecialAbility(int abilityId, bool active) { - [Theory] - [InlineData(0, true)] - [InlineData(0, false)] - [InlineData(100, true)] - [InlineData(1000, false)] - public void TestSpecialAbility(int abilityId, bool active) - { var expected = new ToggleSpecialAbility(abilityId, active).Compile(); var ns = PacketTestUtilities.CreateTestNetState(); @@ -23,9 +23,9 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Fact] - public void TestClearAbility() - { + [Fact] + public void TestClearAbility() + { var expected = new ClearWeaponAbility().Compile(); var ns = PacketTestUtilities.CreateTestNetState(); @@ -34,5 +34,4 @@ namespace UOContent.Tests var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Items/Weapons/Abilities/WeaponAbilityPackets.cs b/Projects/UOContent.Tests/Tests/Items/Weapons/Abilities/WeaponAbilityPackets.cs index f44593af0..5a8592f08 100644 --- a/Projects/UOContent.Tests/Tests/Items/Weapons/Abilities/WeaponAbilityPackets.cs +++ b/Projects/UOContent.Tests/Tests/Items/Weapons/Abilities/WeaponAbilityPackets.cs @@ -1,11 +1,11 @@ using Server.Network; -namespace UOContent.Tests +namespace UOContent.Tests; + +public sealed class ToggleSpecialAbility : Packet { - public sealed class ToggleSpecialAbility : Packet + public ToggleSpecialAbility(int abilityID, bool active) : base(0xBF) { - public ToggleSpecialAbility(int abilityID, bool active) : base(0xBF) - { EnsureCapacity(7); Stream.Write((short)0x25); @@ -13,17 +13,16 @@ namespace UOContent.Tests Stream.Write((short)abilityID); Stream.Write(active); } - } +} - public sealed class ClearWeaponAbility : Packet +public sealed class ClearWeaponAbility : Packet +{ + public static readonly Packet Instance = SetStatic(new ClearWeaponAbility()); + + public ClearWeaponAbility() : base(0xBF) { - public static readonly Packet Instance = SetStatic(new ClearWeaponAbility()); - - public ClearWeaponAbility() : base(0xBF) - { EnsureCapacity(5); Stream.Write((short)0x21); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Multis/Boats/Packets.cs b/Projects/UOContent.Tests/Tests/Multis/Boats/Packets.cs index a838ffd6a..1dcd9adf4 100644 --- a/Projects/UOContent.Tests/Tests/Multis/Boats/Packets.cs +++ b/Projects/UOContent.Tests/Tests/Multis/Boats/Packets.cs @@ -5,16 +5,16 @@ using Server.Items; using Server.Multis; using Server.Network; -namespace UOContent.Tests +namespace UOContent.Tests; + +public sealed class MoveBoatHS : Packet { - public sealed class MoveBoatHS : Packet + public MoveBoatHS( + Mobile beholder, BaseBoat boat, Direction d, + int speed, PooledRefList ents, int xOffset, + int yOffset + ) : base(0xF6) { - public MoveBoatHS( - Mobile beholder, BaseBoat boat, Direction d, - int speed, PooledRefList ents, int xOffset, - int yOffset - ) : base(0xF6) - { EnsureCapacity(3 + 15 + ents.Count * 10); Stream.Write(boat.Serial); @@ -40,12 +40,12 @@ namespace UOContent.Tests Stream.Seek(16, SeekOrigin.Begin); Stream.Write((short)count); } - } +} - public sealed class DisplayBoatHS : Packet +public sealed class DisplayBoatHS : Packet +{ + public DisplayBoatHS(Mobile beholder, BaseBoat boat) : base(0xF7) { - public DisplayBoatHS(Mobile beholder, BaseBoat boat) : base(0xF7) - { var ents = boat.GetMovingEntities(true); EnsureCapacity(3 + 2 + 5 * 26); @@ -128,5 +128,4 @@ namespace UOContent.Tests Stream.Seek(3, SeekOrigin.Begin); Stream.Write((short)count); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Multis/Houses/HousePacketTests.cs b/Projects/UOContent.Tests/Tests/Multis/Houses/HousePacketTests.cs index 1fbdfc9fb..66d36bbd8 100644 --- a/Projects/UOContent.Tests/Tests/Multis/Houses/HousePacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Multis/Houses/HousePacketTests.cs @@ -6,14 +6,14 @@ using Server.Tests; using Server.Tests.Network; using Xunit; -namespace UOContent.Tests +namespace UOContent.Tests; + +public class HousePacketTests { - public class HousePacketTests + [Theory] + [InlineData(0x1001u)] + public void TestBeginHouseCustomization(uint serial) { - [Theory] - [InlineData(0x1001u)] - public void TestBeginHouseCustomization(uint serial) - { var expected = new BeginHouseCustomization((Serial)serial).Compile(); var ns = PacketTestUtilities.CreateTestNetState(); @@ -23,10 +23,10 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Theory] - [InlineData(0x1001u)] - public void TestEndHouseCustomization(uint serial) - { + [Theory] + [InlineData(0x1001u)] + public void TestEndHouseCustomization(uint serial) + { var expected = new EndHouseCustomization((Serial)serial).Compile(); var ns = PacketTestUtilities.CreateTestNetState(); @@ -36,11 +36,11 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Theory] - [InlineData(0x1001u, 0)] - [InlineData(0x1001u, 100)] - public void TestDesignStateGeneral(uint serial, int revision) - { + [Theory] + [InlineData(0x1001u, 0)] + [InlineData(0x1001u, 100)] + public void TestDesignStateGeneral(uint serial, int revision) + { var expected = new DesignStateGeneral((Serial)serial, revision).Compile(); var ns = PacketTestUtilities.CreateTestNetState(); @@ -50,9 +50,9 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Fact] - public void TestHouseDesignStateDetailed() - { + [Fact] + public void TestHouseDesignStateDetailed() + { Serial serial = (Serial)0x40000001; var revision = 10; var tiles = new MultiTileEntry[250]; @@ -76,5 +76,4 @@ namespace UOContent.Tests AssertThat.Equal(actual, expected); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Network/Packets/ArrowPacketTests.cs b/Projects/UOContent.Tests/Tests/Network/Packets/ArrowPacketTests.cs index f6e7c76ad..0f1b01b39 100644 --- a/Projects/UOContent.Tests/Tests/Network/Packets/ArrowPacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Network/Packets/ArrowPacketTests.cs @@ -1,13 +1,13 @@ using Server.Network; using Xunit; -namespace Server.Tests.Network +namespace Server.Tests.Network; + +public class ArrowPacketTests { - public class ArrowPacketTests + [Fact] + public void TestCancelArrow() { - [Fact] - public void TestCancelArrow() - { var expected = new CancelArrow().Compile(); var ns = PacketTestUtilities.CreateTestNetState(); @@ -17,12 +17,12 @@ namespace Server.Tests.Network AssertThat.Equal(result, expected); } - [Theory] - [InlineData(0, 0)] - [InlineData(100, 10)] - [InlineData(100000, 100000)] - public void TestSetArrow(int x, int y) - { + [Theory] + [InlineData(0, 0)] + [InlineData(100, 10)] + [InlineData(100000, 100000)] + public void TestSetArrow(int x, int y) + { var expected = new SetArrow(x, y).Compile(); var ns = PacketTestUtilities.CreateTestNetState(); @@ -32,12 +32,12 @@ namespace Server.Tests.Network AssertThat.Equal(result, expected); } - [Theory] - [InlineData(0, 0)] - [InlineData(100, 10)] - [InlineData(100000, 100000)] - public void TestCancelArrowHS(int x, int y) - { + [Theory] + [InlineData(0, 0)] + [InlineData(100, 10)] + [InlineData(100000, 100000)] + public void TestCancelArrowHS(int x, int y) + { Serial serial = (Serial)0x1024; var expected = new CancelArrowHS(x, y, serial).Compile(); @@ -50,12 +50,12 @@ namespace Server.Tests.Network AssertThat.Equal(result, expected); } - [Theory] - [InlineData(0, 0)] - [InlineData(100, 10)] - [InlineData(100000, 100000)] - public void TestSetArrowHS(int x, int y) - { + [Theory] + [InlineData(0, 0)] + [InlineData(100, 10)] + [InlineData(100000, 100000)] + public void TestSetArrowHS(int x, int y) + { Serial serial = (Serial)0x1024; var expected = new SetArrowHS(x, y, serial).Compile(); @@ -67,5 +67,4 @@ namespace Server.Tests.Network var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Network/Packets/ArrowPackets.cs b/Projects/UOContent.Tests/Tests/Network/Packets/ArrowPackets.cs index 88d0a9762..5fea8c156 100644 --- a/Projects/UOContent.Tests/Tests/Network/Packets/ArrowPackets.cs +++ b/Projects/UOContent.Tests/Tests/Network/Packets/ArrowPackets.cs @@ -1,44 +1,43 @@ -namespace Server.Network +namespace Server.Network; + +public sealed class CancelArrow : Packet { - public sealed class CancelArrow : Packet + public CancelArrow() : base(0xBA, 6) { - public CancelArrow() : base(0xBA, 6) - { Stream.Write((byte)0); Stream.Write((short)-1); Stream.Write((short)-1); } - } - - public sealed class SetArrow : Packet - { - public SetArrow(int x, int y) : base(0xBA, 6) - { - Stream.Write((byte)1); - Stream.Write((short)x); - Stream.Write((short)y); - } - } - - public sealed class CancelArrowHS : Packet - { - public CancelArrowHS(int x, int y, Serial s) : base(0xBA, 10) - { - Stream.Write((byte)0); - Stream.Write((short)x); - Stream.Write((short)y); - Stream.Write(s); - } - } - - public sealed class SetArrowHS : Packet - { - public SetArrowHS(int x, int y, Serial s) : base(0xBA, 10) - { - Stream.Write((byte)1); - Stream.Write((short)x); - Stream.Write((short)y); - Stream.Write(s); - } - } } + +public sealed class SetArrow : Packet +{ + public SetArrow(int x, int y) : base(0xBA, 6) + { + Stream.Write((byte)1); + Stream.Write((short)x); + Stream.Write((short)y); + } +} + +public sealed class CancelArrowHS : Packet +{ + public CancelArrowHS(int x, int y, Serial s) : base(0xBA, 10) + { + Stream.Write((byte)0); + Stream.Write((short)x); + Stream.Write((short)y); + Stream.Write(s); + } +} + +public sealed class SetArrowHS : Packet +{ + public SetArrowHS(int x, int y, Serial s) : base(0xBA, 10) + { + Stream.Write((byte)1); + Stream.Write((short)x); + Stream.Write((short)y); + Stream.Write(s); + } +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/Tests/Network/Packets/BuffIconPacketTests.cs b/Projects/UOContent.Tests/Tests/Network/Packets/BuffIconPacketTests.cs index 27ce71404..71aa2fa10 100644 --- a/Projects/UOContent.Tests/Tests/Network/Packets/BuffIconPacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Network/Packets/BuffIconPacketTests.cs @@ -5,15 +5,15 @@ using Server.Tests; using Server.Tests.Network; using Xunit; -namespace UOContent.Tests +namespace UOContent.Tests; + +public class BuffIconPacketTests { - public class BuffIconPacketTests + [Theory] + [InlineData(0x1024u, BuffIcon.Clumsy, 500100, 300200, "123456", 8000)] + [InlineData(0x2048u, BuffIcon.Disguised, 500102, 300203, null, 9000)] + public void TestAddBuffIcon(uint mob, BuffIcon iconID, int titleCliloc, int secondaryCliloc, string args, int ts) { - [Theory] - [InlineData(0x1024u, BuffIcon.Clumsy, 500100, 300200, "123456", 8000)] - [InlineData(0x2048u, BuffIcon.Disguised, 500102, 300203, null, 9000)] - public void TestAddBuffIcon(uint mob, BuffIcon iconID, int titleCliloc, int secondaryCliloc, string args, int ts) - { var timeSpan = new TimeSpan(ts); var expected = new AddBuffPacket( (Serial)mob, iconID, titleCliloc, secondaryCliloc, args, timeSpan @@ -26,9 +26,9 @@ namespace UOContent.Tests AssertThat.Equal(result, expected); } - [Fact] - public void TestRemoveBuffIcon() - { + [Fact] + public void TestRemoveBuffIcon() + { Serial m = (Serial)0x1024; var buffIcon = BuffIcon.Disguised; var expected = new RemoveBuffPacket(m, buffIcon).Compile(); @@ -39,5 +39,4 @@ namespace UOContent.Tests var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); } - } -} +} \ No newline at end of file diff --git a/Projects/UOContent.Tests/UOContent.Tests.csproj b/Projects/UOContent.Tests/UOContent.Tests.csproj index 43dc83913..c3b0faf3c 100644 --- a/Projects/UOContent.Tests/UOContent.Tests.csproj +++ b/Projects/UOContent.Tests/UOContent.Tests.csproj @@ -10,9 +10,8 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + - diff --git a/Projects/UOContent/Misc/CrashGuard.cs b/Projects/UOContent/Misc/CrashGuard.cs index a775297b8..e2245fd04 100644 --- a/Projects/UOContent/Misc/CrashGuard.cs +++ b/Projects/UOContent/Misc/CrashGuard.cs @@ -49,7 +49,8 @@ namespace Server.Misc if (RestartServer) { - Restart(e); + e.Close = true; + Core.Kill(true); } } @@ -60,23 +61,6 @@ namespace Server.Misc Email.SendCrashEmail(filePath); } - private static void Restart(ServerCrashedEventArgs e) - { - logger.Information("Restarting"); - - try - { - Process.Start(Core.Assembly.Location, Core.Arguments); - logger.Information("Restart done"); - - e.Close = true; - } - catch - { - logger.Error("Restart failed"); - } - } - private static void DirectoryCopy(string sourceDirName, string destDirName) { // Get the subdirectories for the specified directory. diff --git a/Projects/UOContent/UOContent.csproj b/Projects/UOContent/UOContent.csproj index bcc97b991..880cc8318 100644 --- a/Projects/UOContent/UOContent.csproj +++ b/Projects/UOContent/UOContent.csproj @@ -10,7 +10,8 @@ - + + @@ -24,10 +25,11 @@ - - - + + + + diff --git a/SPONSORS.md b/SPONSORS.md index 2bc0b53c0..315169097 100644 --- a/SPONSORS.md +++ b/SPONSORS.md @@ -10,7 +10,7 @@ Thank you to all of our generous sponsors that make ModernUO possible. We greatly appreciate the support! Use one of the following platforms below: #### GitHub -[Github Sponsors | ModernUO](https://github.com/sponsors/modernuo) +[Github Sponsors | ModernUO](https://github.com/sponsors/modernuo) #### Patreon [Patreon | ModernUO](https://muo.gg/patreon) diff --git a/publish.cmd b/publish.cmd index dc13d26c2..93f2345ae 100755 --- a/publish.cmd +++ b/publish.cmd @@ -39,8 +39,8 @@ dotnet clean --verbosity quiet echo dotnet restore --force-evaluate --source https://api.nuget.org/v3/index.json dotnet restore --force-evaluate --source https://api.nuget.org/v3/index.json -echo dotnet publish %config% %os%-%arch% --no-restore --self-contained=false -o Distribution\Assemblies Projects\UOContent\UOContent.csproj -dotnet publish %config% %os%-%arch% --no-restore --self-contained=false -o Distribution\Assemblies Projects\UOContent\UOContent.csproj +echo dotnet publish %config% %os%-%arch% --no-restore --self-contained=false -o Distribution Projects\Application\Application.csproj +dotnet publish %config% %os%-%arch% --no-restore --self-contained=false -o Distribution Projects\Application\Application.csproj echo Generating serialization migration schema... dotnet tool run ModernUOSchemaGenerator -- ModernUO.sln diff --git a/publish.sh b/publish.sh index eabf6e09f..72bde37fe 100755 --- a/publish.sh +++ b/publish.sh @@ -36,8 +36,8 @@ dotnet clean --verbosity quiet echo dotnet restore --force-evaluate --source https://api.nuget.org/v3/index.json dotnet restore --force-evaluate --source https://api.nuget.org/v3/index.json -echo dotnet publish ${config} ${os}-${arch} --no-restore --self-contained=false -o Distribution/Assemblies Projects/UOContent/UOContent.csproj -dotnet publish ${config} ${os}-${arch} --no-restore --self-contained=false -o Distribution/Assemblies Projects/UOContent/UOContent.csproj +echo dotnet publish ${config} ${os}-${arch} --no-restore --self-contained=false -o Distribution Projects/Application/Application.csproj +dotnet publish ${config} ${os}-${arch} --no-restore --self-contained=false -o Distribution Projects/Application/Application.csproj echo Generating serialization migration schema... dotnet tool run ModernUOSchemaGenerator -- ModernUO.sln diff --git a/version.json b/version.json index 4190f0de5..43964a515 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "0.13.3" + "version": "0.13.4" }