public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += UnhandledException; try { InitialiseInternals(); ServerApi.Hooks.AttachOTAPIHooks(args); // avoid any Terraria.Main calls here or the heaptile hook will not work. // this is because the hook is executed on the Terraria.Main static constructor, // and simply referencing it in this method will trigger the constructor. StartServer(args); ServerApi.DeInitialize(); } catch (Exception ex) { ServerApi.LogWriter.ServerWriteLine("Server crashed due to an unhandled exception:\n" + ex, TraceLevel.Error); } }
public static void InitialiseAPI() { try { Console.WriteLine("TerrariaAPI Version: {0} (Protocol {1} ({2}), OTAPI {3})", ServerApi.ApiVersion, Main.versionNumber2, Main.curRelease, typeof(OTAPI.Hooks).Assembly.GetName().Version ); ServerApi.Initialize(Environment.GetCommandLineArgs(), Main.instance); } catch (Exception ex) { ServerApi.LogWriter.ServerWriteLine( "Startup aborted due to an exception in the Server API initialization:\n" + ex, TraceLevel.Error); Console.ReadLine(); return; } }