Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/general-devel' into net9-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
SignatureBeef committed Jan 3, 2025
2 parents e6c5ceb + f205e2f commit d597325
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 0 deletions.
16 changes: 16 additions & 0 deletions TerrariaServerAPI/TerrariaApi.Server/Hooking/GameHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ private static void OnUpdate(Terraria.Main instance, HookEvents.Terraria.Main.Up

private static void OnHardmodeTileUpdate(object sender, Hooks.WorldGen.HardmodeTileUpdateEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (_hookManager.InvokeGameHardmodeTileUpdate(e.X, e.Y, e.Type))
{
e.Result = HookResult.Cancel;
Expand All @@ -43,6 +47,10 @@ private static void OnHardmodeTileUpdate(object sender, Hooks.WorldGen.HardmodeT

private static void OnHardmodeTilePlace(object sender, Hooks.WorldGen.HardmodeTilePlaceEventArgs e)
{
if (e.Result == HardmodeTileUpdateResult.Cancel)
{
return;
}
if (_hookManager.InvokeGameHardmodeTileUpdate(e.X, e.Y, e.Type))
{
e.Result = HardmodeTileUpdateResult.Cancel;
Expand All @@ -64,6 +72,10 @@ private static void OnStartServer(object? sender, HookEvents.Terraria.Netplay.St

private static void OnItemMechSpawn(object sender, Hooks.Item.MechSpawnEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (!_hookManager.InvokeGameStatueSpawn(e.Num2, e.Num3, e.Num, (int)(e.X / 16f), (int)(e.Y / 16f), e.Type, false))
{
e.Result = HookResult.Cancel;
Expand All @@ -72,6 +84,10 @@ private static void OnItemMechSpawn(object sender, Hooks.Item.MechSpawnEventArgs

private static void OnNpcMechSpawn(object sender, Hooks.NPC.MechSpawnEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (!_hookManager.InvokeGameStatueSpawn(e.Num2, e.Num3, e.Num, (int)(e.X / 16f), (int)(e.Y / 16f), e.Type, true))
{
e.Result = HookResult.Cancel;
Expand Down
4 changes: 4 additions & 0 deletions TerrariaServerAPI/TerrariaApi.Server/Hooking/ItemHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ private static void OnSetDefaults(Item item, HookEvents.Terraria.Item.SetDefault

private static void OnQuickStack(object sender, Hooks.Chest.QuickStackEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (_hookManager.InvokeItemForceIntoChest(Main.chest[e.ChestIndex], e.Item, Main.player[e.PlayerId]))
{
e.Result = HookResult.Cancel;
Expand Down
16 changes: 16 additions & 0 deletions TerrariaServerAPI/TerrariaApi.Server/Hooking/NetHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ static void OnBroadcastChatMessage(object? sender, HookEvents.Terraria.Chat.Chat

static void OnSendData(object sender, Hooks.NetMessage.SendDataEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (e.Event == HookEvent.Before)
{
var msgType = e.MsgType;
Expand Down Expand Up @@ -108,6 +112,10 @@ ref args.packet

static void OnReceiveData(object sender, Hooks.MessageBuffer.GetDataEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (!Enum.IsDefined(typeof(PacketTypes), (int)e.PacketId))
{
e.Result = HookResult.Cancel;
Expand Down Expand Up @@ -138,6 +146,10 @@ static void OnGreetPlayer(object? sender, HookEvents.Terraria.NetMessage.greetPl

static void OnSendBytes(object sender, Hooks.NetMessage.SendBytesEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (_hookManager.InvokeNetSendBytes(Netplay.Clients[e.RemoteClient], e.Data, e.Offset, e.Size))
{
e.Result = HookResult.Cancel;
Expand All @@ -146,6 +158,10 @@ static void OnSendBytes(object sender, Hooks.NetMessage.SendBytesEventArgs e)

static void OnNameCollision(object sender, Hooks.MessageBuffer.NameCollisionEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (_hookManager.InvokeNetNameCollision(e.Player.whoAmI, e.Player.name))
{
e.Result = HookResult.Cancel;
Expand Down
12 changes: 12 additions & 0 deletions TerrariaServerAPI/TerrariaApi.Server/Hooking/NpcHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ static void OnTransform(NPC npc, HookEvents.Terraria.NPC.TransformEventArgs args

static void OnSpawn(object sender, Hooks.NPC.SpawnEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
var index = e.Index;
if (_hookManager.InvokeNpcSpawn(ref index))
{
Expand All @@ -79,6 +83,10 @@ static void OnSpawn(object sender, Hooks.NPC.SpawnEventArgs e)

static void OnDropLoot(object sender, Hooks.NPC.DropLootEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (e.Event == HookEvent.Before)
{
var Width = e.Width;
Expand Down Expand Up @@ -126,6 +134,10 @@ ref reverseLookup

static void OnBossBagItem(object sender, Hooks.NPC.BossBagEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
var Width = e.Width;
var Height = e.Height;
var Type = e.Type;
Expand Down
4 changes: 4 additions & 0 deletions TerrariaServerAPI/TerrariaApi.Server/Hooking/ServerHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ static void Main_startDedInput(object? sender, HookEvents.Terraria.Main.startDed

static void OnProcess(object sender, Hooks.Main.CommandProcessEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (_hookManager.InvokeServerCommand(e.Command))
{
e.Result = HookResult.Cancel;
Expand Down
4 changes: 4 additions & 0 deletions TerrariaServerAPI/TerrariaApi.Server/Hooking/WiringHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public static void AttachTo(HookManager hookManager)

static void OnAnnouncementBox(object sender, Hooks.Wiring.AnnouncementBoxEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (_hookManager.InvokeWireTriggerAnnouncementBox(Wiring.CurrentUser, e.X, e.Y, e.SignId, Main.sign[e.SignId].text))
{
e.Result = HookResult.Cancel;
Expand Down
8 changes: 8 additions & 0 deletions TerrariaServerAPI/TerrariaApi.Server/Hooking/WorldHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public static void AttachTo(HookManager hookManager)

static void OnPressurePlate(object sender, Hooks.Collision.PressurePlateEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (e.Entity is NPC npc)
{
if (_hookManager.InvokeNpcTriggerPressurePlate(npc, e.X, e.Y))
Expand Down Expand Up @@ -60,6 +64,10 @@ private static void WorldGen_StartHardmode(object? sender, HookEvents.Terraria.W

static void OnDropMeteor(object sender, Hooks.WorldGen.MeteorEventArgs e)
{
if (e.Result == HookResult.Cancel)
{
return;
}
if (_hookManager.InvokeWorldMeteorDrop(e.X, e.Y))
{
e.Result = HookResult.Cancel;
Expand Down

0 comments on commit d597325

Please sign in to comment.