Skip to content

Update TSAPI for Terraria 1.4.6.0 (OTAPI 3.3.15) - #286

Open
KRWCLASSIC wants to merge 1 commit into
Pryaxis:general-develfrom
KRWCLASSIC:terraria-1.4.6
Open

KRWCLASSIC wants to merge 1 commit into
Pryaxis:general-develfrom
KRWCLASSIC:terraria-1.4.6

Conversation

@KRWCLASSIC

Copy link
Copy Markdown

Updates TSAPI for Terraria 1.4.6.0 (depends on the OTAPI PR): bumps OTAPI to 3.3.15, adds packet 165, and fixes the RemoteClient / connection acceptance changes.

@magaflaca

magaflaca commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Found two issues while testing this on Windows and Linux:

ServerLeave never fires on 1.4.6

In 1.4.6 IsActive is Status == ConnStatus.Active, but Reset() only runs once the client is already Terminated. So ServerLeave is never invoked and TShock doesn't clean up the player or save SSC data on leave.

 // TerrariaServerAPI/TerrariaApi.Server/Hooking/ServerHooks.cs
-if (client.IsActive)
+if (client.Status != RemoteClient.ConnStatus.Free)
 {
     _hookManager.InvokeServerLeave(client.Id);
 }

Server crashes if GNS_Wrapper can't load

If the native or one of its deps is missing (e.g. an old OpenSSL on the host), GNS_API.Startup() throws DllNotFoundException and the server dies. Probing the library at startup and setting Netplay.UseGNS = false with a warning keeps the server up on TCP only. Fix: magaflaca@0299712


Btw, I think dont need #284 in 1.4.6 cause PendingTermination was removed in this PR.


Update on the ServerLeave fix above: checking Status != Free in Reset makes it fire, but too late. 1.4.6 calls ApproveTermination() before Reset(), and that sets State = 0, so TShock's InsertPlayerData returns early (State < Complete) and SSC inventories are never saved on leave. Firing ServerLeave from ApproveTermination instead keeps the state intact, like 1.4.5.8: magaflaca@ddd66f2

Tested (SSC inventory saved and restored on relog) and confirmed working on another server running SSC.

Thanks kobo_pace for testing in this too.

@SignatureBeef SignatureBeef left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick review - has some stray changes, but I welcome termination changes...nice.
That said the change to OnConnectionAccepted likely needs more work, as well as an improved PR description as to why its removed - would go a long way for others when considering for merging.

@@ -1,4 +1,4 @@
using OTAPI;
using OTAPI;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strays?

_hookManager = hookManager;

HookEvents.Terraria.NetMessage.greetPlayer += OnGreetPlayer;
HookEvents.Terraria.Netplay.OnConnectionAccepted += OnConnectionAccepted;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OnConnectionAccepted likely needs to go now as well, right? Since vanilla has changed how this works entirely - but an explanation of why this was removed would have been great.

@@ -1,4 +1,4 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more unneeded changed lines?

<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="9.0.0" />
<PackageReference Include="OTAPI.Upcoming" Version="3.3.14" />
<PackageReference Include="OTAPI.Upcoming" Version="3.3.15" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When addressing the others, can you bump to 3.3.18 while you're at it?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants