Skip to content

Commit

Permalink
Migrate UpdateConnectedClients to static hook
Browse files Browse the repository at this point in the history
  • Loading branch information
SignatureBeef committed Jan 26, 2025
1 parent b89b305 commit d712022
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,24 @@ public static void AttachTo(HookManager hookManager)
HookEvents.Terraria.Netplay.OnConnectionAccepted += OnConnectionAccepted;
HookEvents.Terraria.Chat.ChatHelper.BroadcastChatMessage += OnBroadcastChatMessage;
HookEvents.Terraria.Net.NetManager.SendData += OnSendNetData;
On.Terraria.Netplay.UpdateConnectedClients += OnUpdateConnectedClients;
HookEvents.Terraria.Netplay.UpdateConnectedClients += OnUpdateConnectedClients;

Hooks.NetMessage.SendData += OnSendData;
Hooks.NetMessage.SendBytes += OnSendBytes;
Hooks.MessageBuffer.GetData += OnReceiveData;
Hooks.MessageBuffer.NameCollision += OnNameCollision;
}

static void OnUpdateConnectedClients(On.Terraria.Netplay.orig_UpdateConnectedClients orig)
static void OnUpdateConnectedClients(object? sender, HookEvents.Terraria.Netplay.UpdateConnectedClientsEventArgs args)

Check warning on line 34 in TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs

View workflow job for this annotation

GitHub Actions / MacOS

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 34 in TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs

View workflow job for this annotation

GitHub Actions / MacOS

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 34 in TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs

View workflow job for this annotation

GitHub Actions / Ubuntu

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 34 in TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs

View workflow job for this annotation

GitHub Actions / Ubuntu

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 34 in TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs

View workflow job for this annotation

GitHub Actions / Windows

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 34 in TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs

View workflow job for this annotation

GitHub Actions / Windows

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
if (!args.ContinueExecution) return;
args.ContinueExecution = false;
args.OriginalMethod();
if (ServerApi.ForceUpdate)
{
orig();
if (ServerApi.ForceUpdate)
{
Terraria.Netplay.HasClients = true;
}
Terraria.Netplay.HasClients = true;
}
}

static void OnBroadcastChatMessage(object? sender, HookEvents.Terraria.Chat.ChatHelper.BroadcastChatMessageEventArgs args)

Check warning on line 45 in TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs

View workflow job for this annotation

GitHub Actions / MacOS

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 45 in TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs

View workflow job for this annotation

GitHub Actions / MacOS

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 45 in TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs

View workflow job for this annotation

GitHub Actions / Ubuntu

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 45 in TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs

View workflow job for this annotation

GitHub Actions / Ubuntu

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 45 in TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs

View workflow job for this annotation

GitHub Actions / Windows

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 45 in TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs

View workflow job for this annotation

GitHub Actions / Windows

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
Expand Down

0 comments on commit d712022

Please sign in to comment.