Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect invalid TShock installations #2882

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions TShockLauncher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,38 @@ You should have received a copy of the GNU General Public License
using System.Reflection;
using TShockPluginManager;

// On occasion, users have been seen extracting TShock into their client installation directory -- this is of course incorrect, and is known
// to cause issues. Let's attempt to catch this before anything happens (specifically, before Terraria assemblies are resolved) and prevent
// TShock from launching.
if (File.Exists("TerrariaServer.exe"))
Copy link
Contributor

Choose a reason for hiding this comment

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

😅 I forgot to mention the .exe part is windows-specific. should it take into account other OSes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the exe part is not windows-specific, it also exists on Linux... and I'd assume Mac

Copy link
Member

Choose a reason for hiding this comment

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

At least vanilla and TShock 4 are both using Mono - and they are just regular assembly and extension doesn't matters much. This doesn't work for tModLoader, but who would do that tho?

{
Console.ForegroundColor = ConsoleColor.Red;
Console.Error.WriteLine("A \"TerrariaServer.exe\" file has been found in the current working directory.");
Console.Error.WriteLine(
"This indicates either installation into a Terraria client directory, or installation into a legacy (TShock 4 or older) TShock directory.");
Console.Error.WriteLine(
"TShock is never to be installed inside a Terraria client directory. You should instead extract your TShock installation into it's own directory.");
Console.Error.WriteLine(
"If you are updating a legacy TShock installation, please follow the following documentation to update: https://ikebukuro.tshock.co/#/?id=upgrading-from-tshock-4");
Console.Error.WriteLine("The launcher will now exit.");
Console.ResetColor();
return 1;
}

if (args.Length > 0 && args[0].ToLower() == "plugins")
{
var items = args.ToList();
items.RemoveAt(0);
await NugetCLI.Main(items);
return;
return 0;
}


Dictionary<string, Assembly> _cache = new Dictionary<string, Assembly>();

System.Runtime.Loader.AssemblyLoadContext.Default.Resolving += Default_Resolving;

Start();
return Start();

/// <summary>
/// Resolves a module from the ./bin folder, either with a .dll by preference or .exe
Expand Down Expand Up @@ -70,7 +88,8 @@ You should have received a copy of the GNU General Public License
/// Initiates the TSAPI server.
/// </summary>
/// <remarks>This method exists so that the resolver can attach before TSAPI needs its dependencies.</remarks>
void Start()
int Start()
{
TerrariaApi.Server.Program.Main(args);
return 0;
}
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Use past tense when adding new entries; sign your name off when you add or chang
* Fixed /help, /me, and /p commands can't work in non-English languages. (@ACaiCat)
* Added a hook `AccountHooks.AccountGroupUpdate`, which is called when you change the user group. (@AgaSpace)
* * Ensured `TSPlayer.PlayerData` is non-null whilst syncing loadouts. (@drunderscore)
* * Detected invalid installations, by checking for a file named `TerrariaServer.exe`. (@drunderscore)
* This made the two most common installation mistakes (extracting into the Terraria client directory, and extracting TShock 5 or newer into a TShock 4 or older install) prompt the user with a more useful diagnostic, rather than (likely) crashing moments later.

## TShock 5.2.1
* Updated `TSPlayer.GodMode`. (@AgaSpace)
Expand Down
Loading