static void Main(string[] args) { // - check for update // - launcher & user setup // - game setup // - game launch // - enjoy CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Log.Start(LogTypes.All); CUOEnviroment.GameThread = Thread.CurrentThread; CUOEnviroment.GameThread.Name = "CUO_MAIN_THREAD"; #if !DEBUG AppDomain.CurrentDomain.UnhandledException += (s, e) => { StringBuilder sb = new StringBuilder(); sb.AppendLine("######################## [START LOG] ########################"); #if DEV_BUILD sb.AppendLine($"ClassicUO [DEV_BUILD] - {CUOEnviroment.Version}"); #else sb.AppendLine($"ClassicUO [STANDARD_BUILD] - {CUOEnviroment.Version}"); #endif sb.AppendLine($"OS: {Environment.OSVersion.Platform} x{(Environment.Is64BitOperatingSystem ? "64" : "86")}"); sb.AppendLine($"Thread: {Thread.CurrentThread.Name}"); sb.AppendLine(); sb.AppendLine($"Protocol: {Client.Protocol}"); sb.AppendLine($"ClientFeatures: {World.ClientFeatures.Flags}"); sb.AppendLine($"ClientLockedFeatures: {World.ClientLockedFeatures.Flags}"); sb.AppendLine($"ClientVersion: {Client.Version}"); sb.AppendLine(); sb.AppendFormat("Exception:\n{0}\n", e.ExceptionObject); sb.AppendLine("######################## [END LOG] ########################"); sb.AppendLine(); sb.AppendLine(); Log.Panic(e.ExceptionObject.ToString()); string path = Path.Combine(CUOEnviroment.ExecutablePath, "Logs"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } using (LogFile crashfile = new LogFile(path, "crash.txt")) { crashfile.WriteAsync(sb.ToString()).RunSynchronously(); } }; #endif #if DEV_BUILD Updater updater = new Updater(); if (updater.Check()) { return; } #endif ReadSettingsFromArgs(args); if (!_skipUpdates) { if (CheckUpdate(args)) { return; } } //Environment.SetEnvironmentVariable("FNA_GRAPHICS_FORCE_GLDEVICE", "ModernGLDevice"); Environment.SetEnvironmentVariable("FNA_GRAPHICS_ENABLE_HIGHDPI", CUOEnviroment.IsHighDPI ? "1" : "0"); Environment.SetEnvironmentVariable("FNA_OPENGL_BACKBUFFER_SCALE_NEAREST", "1"); Environment.SetEnvironmentVariable("FNA_OPENGL_FORCE_COMPATIBILITY_PROFILE", "1"); Environment.SetEnvironmentVariable(SDL.SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + Path.Combine(CUOEnviroment.ExecutablePath, "Data", "Plugins")); string globalSettingsPath = Settings.GetSettingsFilepath(); if ((!Directory.Exists(Path.GetDirectoryName(globalSettingsPath)) || !File.Exists(globalSettingsPath))) { // settings specified in path does not exists, make new one { // TODO: Settings.GlobalSettings.Save(); return; } } Settings.GlobalSettings = ConfigurationResolver.Load <Settings>(globalSettingsPath); ReadSettingsFromArgs(args); // still invalid, cannot load settings if (Settings.GlobalSettings == null) { Settings.GlobalSettings = new Settings(); Settings.GlobalSettings.Save(); } if (!CUOEnviroment.IsUnix) { string libsPath = Path.Combine(CUOEnviroment.ExecutablePath, "libs", Environment.Is64BitProcess ? "x64" : "x86"); SetDllDirectory(libsPath); } if (string.IsNullOrWhiteSpace(Settings.GlobalSettings.UltimaOnlineDirectory)) { Settings.GlobalSettings.UltimaOnlineDirectory = CUOEnviroment.ExecutablePath; } Client.Run(); Log.Trace("Closing..."); }