From 5d51d7f77df8b2309515b9c5d598f2808a3b87e7 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 28 Dec 2024 20:56:48 +1000 Subject: [PATCH] Use static hook for dedserv init test --- OTAPI.Server.Launcher/Program.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/OTAPI.Server.Launcher/Program.cs b/OTAPI.Server.Launcher/Program.cs index 4752af12..cc6dcdeb 100644 --- a/OTAPI.Server.Launcher/Program.cs +++ b/OTAPI.Server.Launcher/Program.cs @@ -157,8 +157,6 @@ static void Program_OnLaunched(object sender, EventArgs e) Console.WriteLine($"Hooks.Item.MechSpawn x={args.X}, y={args.Y}, type={args.Type}, num={args.Num}, num2={args.Num2}, num3={args.Num3}"); }; - On.Terraria.Main.DedServ += Main_DedServ; - On.Terraria.RemoteClient.Update += (orig, rc) => { //Console.WriteLine($"RemoteClient.Update: HOOK ID#{rc.Id} IsActive:{rc.IsActive},PT:{rc.PendingTermination}"); @@ -178,14 +176,15 @@ static void Main_ctor(On.Terraria.Main.orig_ctor orig, Terraria.Main self) Console.WriteLine("Main invoked"); } -static void Main_DedServ(On.Terraria.Main.orig_DedServ orig, Terraria.Main self) +static void Main_DedServ(object sender, HookEvents.Terraria.Main.DedServEventArgs e) { Console.WriteLine($"Server init process successful"); - if (!Environment.GetCommandLineArgs().Any(x => x.ToLower() == "-test-init")) - orig(self); + if (Environment.GetCommandLineArgs().Any(x => x.ToLower() == "-test-init")) + e.ContinueExecution = false; } +HookEvents.Terraria.Main.DedServ += Main_DedServ; HookEvents.Terraria.Program.LaunchGame += Program_LaunchGame; if (RuntimeInformation.ProcessArchitecture != Architecture.Arm64) {