Example #1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        private static void Main(string[] args)
        {
            try
            {
                var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
                Directory.SetCurrentDirectory(new Uri(cwd).LocalPath);
                using (Stream stream = new FileStream("version.txt", FileMode.Open))
                    using (StreamReader reader = new StreamReader(stream))
                        Commit = reader.ReadToEnd();
                Commit = Commit.Trim();
            }
            catch (Exception) { }
            System.Net.ServicePointManager.ServerCertificateValidationCallback = SSLCallback;
#if CREATE_CRASH_LOGS
            try
#endif
#if !DEBUG
            try
#endif
            {
                Thread.CurrentThread.CurrentCulture   = System.Globalization.CultureInfo.InvariantCulture;
                Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;
                //fbDeprofiler.DeProfiler.Load();
                using (DwarfGame game = new DwarfGame())
                {
                    foreach (var arg in args)
                    {
                        if (arg == "--test-save")
                        {
                            game.DoSaveLoadtest();
                        }
                    }
                    game.Run();
                }

                SignalShutdown();
            }
#if CREATE_CRASH_LOGS
            catch (Exception exception)
            {
                WriteExceptionLog(exception);
            }
#endif
#if !DEBUG
            catch (Exception exception)
            {
                SDL2.SDL.SDL_ShowSimpleMessageBox(SDL2.SDL.SDL_MessageBoxFlags.SDL_MESSAGEBOX_ERROR, "Unhandled Exception!", String.Format("An unhandled exception occurred in DwarfCorp. This has been reported to Completely Fair Games LLC.\n {0}", exception.ToString()), IntPtr.Zero);
                WriteExceptionLog(exception);
            }
#endif
        }