Skip to content

Commit 5d51d7f

Browse files
committed
Use static hook for dedserv init test
1 parent 7e568db commit 5d51d7f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

OTAPI.Server.Launcher/Program.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ static void Program_OnLaunched(object sender, EventArgs e)
157157
Console.WriteLine($"Hooks.Item.MechSpawn x={args.X}, y={args.Y}, type={args.Type}, num={args.Num}, num2={args.Num2}, num3={args.Num3}");
158158
};
159159

160-
On.Terraria.Main.DedServ += Main_DedServ;
161-
162160
On.Terraria.RemoteClient.Update += (orig, rc) =>
163161
{
164162
//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)
178176
Console.WriteLine("Main invoked");
179177
}
180178

181-
static void Main_DedServ(On.Terraria.Main.orig_DedServ orig, Terraria.Main self)
179+
static void Main_DedServ(object sender, HookEvents.Terraria.Main.DedServEventArgs e)
182180
{
183181
Console.WriteLine($"Server init process successful");
184182

185-
if (!Environment.GetCommandLineArgs().Any(x => x.ToLower() == "-test-init"))
186-
orig(self);
183+
if (Environment.GetCommandLineArgs().Any(x => x.ToLower() == "-test-init"))
184+
e.ContinueExecution = false;
187185
}
188186

187+
HookEvents.Terraria.Main.DedServ += Main_DedServ;
189188
HookEvents.Terraria.Program.LaunchGame += Program_LaunchGame;
190189
if (RuntimeInformation.ProcessArchitecture != Architecture.Arm64)
191190
{

0 commit comments

Comments
 (0)