private static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); var config = new NLog.Config.LoggingConfiguration(); var logfile = new NLog.Targets.FileTarget("logfile") { FileName = GlobalPaths.ConfigDir + "\\Launcher-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" }; config.AddRuleForAllLevels(logfile); LogManager.Configuration = config; GlobalFuncs.ReadInfoFile(GlobalPaths.ConfigDir + "\\" + GlobalPaths.InfoName); GlobalFuncs.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false); GlobalVars.ColorsLoaded = GlobalFuncs.InitColors(); if (args.Length == 0) { RunLauncher(); } else { CommandLineArguments.Arguments CommandLine = new CommandLineArguments.Arguments(args); if (CommandLine["sdk"] != null) { System.Windows.Forms.Application.Run(new NovetusSDK()); } } }
private static void Main(string[] args) { var config = new NLog.Config.LoggingConfiguration(); var logfile = new NLog.Targets.FileTarget("logfile") { FileName = GlobalPaths.ConfigDir + "\\Launcher-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" }; config.AddRule(LogLevel.Info, LogLevel.Fatal, logfile); LogManager.Configuration = config; //https://stackify.com/csharp-catch-all-exceptions/ AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) => { Logger log = LogManager.GetCurrentClassLogger(); log.Error("EXEPTION THROWN: " + (!string.IsNullOrWhiteSpace(eventArgs.Exception.Message) ? eventArgs.Exception.Message : "N/A")); log.Error("EXCEPTION INFO: " + (eventArgs.Exception != null ? eventArgs.Exception.ToString() : "N/A")); log.Error("INNER EXCEPTION: " + (eventArgs.Exception.InnerException != null ? eventArgs.Exception.InnerException.ToString() : "N/A")); log.Error("STACK TRACE: " + (!string.IsNullOrWhiteSpace(eventArgs.Exception.StackTrace) ? eventArgs.Exception.StackTrace : "N/A")); log.Error("TARGET SITE: " + (eventArgs.Exception.TargetSite != null ? eventArgs.Exception.TargetSite.ToString() : "N/A")); log.Error("FOOTPRINTS: " + (!string.IsNullOrWhiteSpace(eventArgs.Exception.GetExceptionFootprints()) ? eventArgs.Exception.GetExceptionFootprints() : "N/A")); }; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); GlobalFuncs.ReadInfoFile(GlobalPaths.ConfigDir + "\\" + GlobalPaths.InfoName); GlobalFuncs.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false); if (args.Length == 0) { switch (GlobalVars.UserConfiguration.LauncherStyle) { case Settings.UIOptions.Style.Compact: Application.Run(new LauncherFormCompact()); break; default: Application.Run(new LauncherFormExtended()); break; } } else { CommandLineArguments.Arguments CommandLine = new CommandLineArguments.Arguments(args); if (CommandLine["sdk"] != null) { Application.Run(new NovetusSDK()); } } }
static void LoadCMDArgs(string[] args) { if (args.Length > 0) { CommandLineArguments.Arguments CommandLine = new CommandLineArguments.Arguments(args); if (CommandLine["help"] != null) { LocalVars.PrintHelp = true; } if (CommandLine["no3d"] != null) { LocalVars.StartInNo3D = true; GlobalFuncs.ConsolePrint("NovetusCMD will now launch the server in No3D mode.", 4); GlobalFuncs.ConsolePrint("Launching the server without graphics enables better performance. " + "However, launching the server with no graphics may cause some elements in later clients may be disabled, such as Dialog boxes." + "This feature may also make your server unstable.", 5); } if (CommandLine["outputinfo"] != null) { GlobalVars.RequestToOutputInfo = true; } if (CommandLine["debug"] != null) { LocalVars.DebugMode = true; } if (CommandLine["script"] != null) { if (CommandLine["script"].Contains("rbxasset:") || CommandLine["script"].Contains("http:")) { GlobalPaths.AddonScriptPath = CommandLine["script"].Replace(@"\", @"\\"); GlobalFuncs.ConsolePrint("NovetusCMD detected a custom script. Loading " + GlobalPaths.AddonScriptPath, 4); } else { GlobalFuncs.ConsolePrint("NovetusCMD cannot load '" + CommandLine["script"] + "' as it doesn't use a rbxasset path or URL.", 2); } } } }
static void LoadCMDArgs(string[] args) { if (args.Length > 0) { CommandLineArguments.Arguments CommandLine = new CommandLineArguments.Arguments(args); if (CommandLine["help"] != null) { LocalVars.PrintHelp = true; } if (CommandLine["no3d"] != null) { LocalVars.StartInNo3D = true; GlobalFuncs.ConsolePrint("NovetusCMD will now launch the server in No3D mode.", 4); } if (CommandLine["outputinfo"] != null) { GlobalVars.RequestToOutputInfo = true; } if (CommandLine["debug"] != null) { LocalVars.DebugMode = true; } if (CommandLine["script"] != null) { if (CommandLine["script"].Contains("rbxasset:") || CommandLine["script"].Contains("http:")) { GlobalPaths.AddonScriptPath = CommandLine["script"].Replace(@"\", @"\\"); GlobalFuncs.ConsolePrint("NovetusCMD detected a custom script. Loading " + GlobalPaths.AddonScriptPath, 4); } else { GlobalFuncs.ConsolePrint("NovetusCMD cannot load '" + CommandLine["script"] + "' as it doesn't use a rbxasset path or URL.", 2); } } } }
static void LoadOverrideINIArgs(string[] args) { if (args.Length > 0) { CommandLineArguments.Arguments CommandLine = new CommandLineArguments.Arguments(args); if (CommandLine["upnp"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.UPnP = true; GlobalFuncs.ConsolePrint("NovetusCMD will now use UPnP for port forwarding.", 4); } if (CommandLine["webserver"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.WebServer = Convert.ToBoolean(CommandLine["webserver"]); if (GlobalVars.UserConfiguration.WebServer) { GlobalFuncs.ConsolePrint("NovetusCMD will now launch the Web Server.", 4); } else { GlobalFuncs.ConsolePrint("NovetusCMD no longer will launch the Web Server.", 4); } } if (CommandLine["map"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.Map = CommandLine["map"]; GlobalVars.UserConfiguration.MapPath = CommandLine["map"]; GlobalFuncs.ConsolePrint("NovetusCMD will now launch the server with the map " + GlobalVars.UserConfiguration.MapPath, 4); } else { GlobalFuncs.ConsolePrint("NovetusCMD will launch the server with the default map.", 4); } if (CommandLine["client"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.SelectedClient = CommandLine["client"]; } else { GlobalFuncs.ConsolePrint("NovetusCMD will launch the server with the default client.", 4); } if (CommandLine["port"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.RobloxPort = Convert.ToInt32(CommandLine["port"]); } if (CommandLine["maxplayers"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.PlayerLimit = Convert.ToInt32(CommandLine["maxplayers"]); } } }
static void LoadOverrideINIArgs(string[] args) { if (args.Length > 0) { CommandLineArguments.Arguments CommandLine = new CommandLineArguments.Arguments(args); if (CommandLine["upnp"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.UPnP = true; GlobalFuncs.ConsolePrint("NovetusCMD will now use UPnP for port forwarding.", 4); } if (CommandLine["notifications"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.ShowServerNotifications = Convert.ToBoolean(CommandLine["notifications"]); if (GlobalVars.UserConfiguration.ShowServerNotifications) { GlobalFuncs.ConsolePrint("NovetusCMD will show notifications on player join/leave.", 4); } else { GlobalFuncs.ConsolePrint("NovetusCMD will no longer show notifications on player join/leave.", 4); } } if (CommandLine["map"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.Map = CommandLine["map"]; GlobalVars.UserConfiguration.MapPath = CommandLine["map"]; GlobalFuncs.ConsolePrint("NovetusCMD will now launch the server with the map " + GlobalVars.UserConfiguration.MapPath, 4); } else { GlobalFuncs.ConsolePrint("NovetusCMD will launch the server with the map defined in the INI file.", 4); } if (CommandLine["client"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.SelectedClient = CommandLine["client"]; } else { GlobalFuncs.ConsolePrint("NovetusCMD will launch the server with the client defined in the INI file.", 4); } if (CommandLine["port"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.RobloxPort = Convert.ToInt32(CommandLine["port"]); } if (CommandLine["maxplayers"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.PlayerLimit = Convert.ToInt32(CommandLine["maxplayers"]); } if (CommandLine["serverbrowsername"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.ServerBrowserServerName = CommandLine["serverbrowsername"]; } if (CommandLine["serverbrowseraddress"] != null) { LocalVars.OverrideINI = true; GlobalVars.UserConfiguration.ServerBrowserServerAddress = CommandLine["serverbrowseraddress"]; } } }