Merge branch 'general-devel' into net9-upgrade

This commit is contained in:
Luke 2025-01-29 22:03:08 +10:00
commit 3e08982e73
7 changed files with 174 additions and 19 deletions

View file

@ -27,12 +27,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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"))
{
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;
}
Dictionary<string, Assembly> _cache = new Dictionary<string, Assembly>();
System.Runtime.Loader.AssemblyLoadContext.Default.Resolving += Default_Resolving;
await StartAsync();
return await StartAsync();
/// <summary>
/// Resolves a module from the ./bin folder, either with a .dll by preference or .exe
@ -61,15 +80,16 @@ Assembly? Default_Resolving(System.Runtime.Loader.AssemblyLoadContext arg1, Asse
/// Initiates the TSAPI server.
/// </summary>
/// <remarks>This method exists so that the resolver can attach before TSAPI needs its dependencies.</remarks>
async Task StartAsync()
async Task<int> StartAsync()
{
if (args.Length > 0 && args[0].ToLower() == "plugins")
{
var items = args.ToList();
items.RemoveAt(0);
await TShockPluginManager.NugetCLI.Main(items);
return;
return 0;
}
TerrariaApi.Server.Program.Main(args);
return 0;
}