示例#1
0
        /// <summary>
        /// Loads the data.
        /// </summary>
        private void LoadData()
        {
            int block1 = -1;

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMinerGame::LoadData", ref block1);
            MyMwcLog.WriteLine("MyMinerGame.LoadData() - START");
            MyMwcLog.IncreaseIndent();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyPerformanceTimer.LoadData");
            MyPerformanceTimer.LoadData();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVoxelFiles.LoadData");
            MyVoxelFiles.LoadData();
            // Not using now
            //MyClientServer.LoadData();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyAudio.LoadData");
            MyAudio.LoadData();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyGuiManager.LoadData");
            MyGuiManager.LoadData();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyGameplayCheats.LoadData");
            MyGameplayCheats.LoadData();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyMinerGame.LoadData() - END");
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(block1);
        }
示例#2
0
        /// <summary>
        /// Unloads the data.
        /// </summary>
        private void UnloadData()
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMinerGame::UnloadData");
            MyMwcLog.WriteLine("MyMinerGame.UnloadData() - START");
            MyMwcLog.IncreaseIndent();

            // TODO: Unload data probably not necessery because all data are loaded at start and dies at the end. No partial unload.

            //  We must unload XACT sounds here, not in the background thread, because on Windows XP every XACT sound loaded in
            //  not-main thread is then not player (I can't hear it).
            MyAudio.UnloadData();

            MyGameplayCheats.UnloadData();

            // Not using now
            //MyClientServer.UnloadData();
            MyPerformanceTimer.UnloadData();

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyMinerGame.UnloadData() - END");
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
示例#3
0
        //  Main method
        static void Main(string[] args)
        {
            if (args.Contains("-report"))
            {
                MyErrorReporter.Report(args[1], args[2], "SE", MyErrorReporter.APP_ERROR_MESSAGE);
                return;
            }

            if (MyFakes.ENABLE_CONNECT_COMMAND_LINE && args.Contains("+connect"))
            {
                int index = args.ToList().IndexOf("+connect");
                if ((index + 1) < args.Length)
                {
                    if (IPAddressExtensions.TryParseEndpoint(args[index + 1], out MySandboxGame.ConnectToServer))
                    {
                        Console.WriteLine("Space engineers " + MyFinalBuildConstants.APP_VERSION_STRING);
                        Console.WriteLine("Obfuscated: " + MyObfuscation.Enabled + ", Platform: " + (Environment.Is64BitProcess ? " 64-bit" : " 32-bit"));
                        Console.WriteLine("Connecting to: " + args[index + 1]);
                    }
                }
            }

            MySingleProgramInstance spi = new MySingleProgramInstance(MyFileSystem.MainAssemblyName);

            if (spi.IsSingleInstance == false)
            {
                MyErrorReporter.ReportAppAlreadyRunning("Space Engineers");
                return;
            }

            MyInitializer.InvokeBeforeRun(
                AppId,
                "SpaceEngineers",
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SpaceEngineers"));

            MyInitializer.InitCheckSum();

            if (!args.Contains("-nosplash"))
            {
                InitSplashScreen();
            }

            // This won't crash with BadFormatExpection when 64-bit game started as 32-bit process, it will show message
            // Will uncomment when it's possible to test it
            if (!Environment.Is64BitProcess && AssemblyExtensions.TryGetArchitecture("SteamSDK.dll") == ProcessorArchitecture.Amd64)
            {
                string text = "Space Engineers cannot be started in 64-bit mode, ";
                text += "because 64-bit version of .NET framework is not available or is broken." + Environment.NewLine + Environment.NewLine;
                text += "Do you want to open website with more information about this particular issue?" + Environment.NewLine + Environment.NewLine;
                text += "Press Yes to open website with info" + Environment.NewLine;
                text += "Press No to run in 32-bit mode (smaller potential of Space Engineers!)" + Environment.NewLine;
                text += "Press Cancel to close this dialog";

                var result = Sandbox.MyMessageBox.Show(IntPtr.Zero, text, ".NET Framework 64-bit error", Sandbox.MessageBoxOptions.YesNoCancel);
                if (result == MessageBoxResult.Yes)
                {
                    MyBrowserHelper.OpenInternetBrowser("http://www.spaceengineersgame.com/64-bit-start-up-issue.html");
                }
                else if (result == MessageBoxResult.No)
                {
                    var    entry  = Assembly.GetEntryAssembly().Location;
                    string x86Exe = Path.Combine(new FileInfo(entry).Directory.Parent.FullName, "Bin", Path.GetFileName(entry));

                    ProcessStartInfo pi = new ProcessStartInfo();
                    pi.FileName         = x86Exe;
                    pi.WorkingDirectory = Path.GetDirectoryName(x86Exe);
                    pi.Arguments        = "-fallback";
                    pi.UseShellExecute  = false;
                    pi.WindowStyle      = ProcessWindowStyle.Normal;
                    var p = Process.Start(pi);
                }
                return;
            }


            if (MyFakes.DETECT_LEAKS)
            {
                //Slow down
                SharpDX.Configuration.EnableObjectTracking = true;
                //SharpDX.Diagnostics.ObjectTracker.OnObjectCreated += new SharpDX.Diagnostics.ObjectTracker.ComObjectDelegate(OnResourceCreated);
                //SharpDX.Diagnostics.ObjectTracker.OnObjectReleased += new SharpDX.Diagnostics.ObjectTracker.ComObjectDelegate(OnResourceDestroyed);
                //SharpDX.Diagnostics.ObjectTracker.OnObjectTrack += new SharpDX.Diagnostics.ObjectTracker.ComObjectDelegate(OnObjectTrack);
                //SharpDX.Diagnostics.ObjectTracker.OnObjectUnTrack += new SharpDX.Diagnostics.ObjectTracker.ComObjectDelegate(OnObjectUnTrack);
            }

            RunInternal(args);

            if (MyFakes.DETECT_LEAKS)
            {
                var o = SharpDX.Diagnostics.ObjectTracker.FindActiveObjects();
                System.Diagnostics.Debug.Assert(o.Count == 0, "Unreleased DX objects!");
                Console.WriteLine(SharpDX.Diagnostics.ObjectTracker.ReportActiveObjects());
            }

#if PROFILING
            MyPerformanceTimer.WriteToLog();
#endif
            MyInitializer.InvokeAfterRun();
        }
示例#4
0
        //  Main method
        static void Main(string[] args)
        {
#if XB1
            XB1Interface.XB1Interface.Init();
            MyAssembly.Init();
#endif
            SpaceEngineersGame.SetupBasicGameInfo();

            m_startup = new MyCommonProgramStartup(args);
            if (m_startup.PerformReporting())
            {
                return;
            }
            m_startup.PerformAutoconnect();
#if !XB1
            if (!m_startup.CheckSingleInstance())
            {
                return;
            }
#endif // !XB1
            var appDataPath = m_startup.GetAppDataPath();
            MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName, appDataPath);
            MyInitializer.InitCheckSum();
            m_startup.InitSplashScreen();
            if (!m_startup.Check64Bit())
            {
                return;
            }

            m_startup.DetectSharpDxLeaksBeforeRun();
            using (MySteamService steamService = new MySteamService(MySandboxGame.IsDedicated, AppId))
            {
                m_renderer = null;
                SpaceEngineersGame.SetupPerGameSettings();
                SpaceEngineersGame.SetupRender();

                try
                {
                    InitializeRender();
                }
                catch (MyRenderException ex)
                {
#if !XB1
                    MessageBox.Show(ex.Message);
#else // XB1
                    System.Diagnostics.Debug.Assert(false, "InitializeRender failed");
#endif // XB1
                    return;
                }

                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyProgram.Init");

                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MySteam.Init()");
                if (!m_startup.CheckSteamRunning(steamService))
                {
                    return;
                }
                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("new MySandboxGame()");

                VRageGameServices services = new VRageGameServices(steamService);

                if (!MySandboxGame.IsDedicated)
                {
                    MyFileSystem.InitUserSpecific(steamService.UserId.ToString());
                }

                using (SpaceEngineersGame game = new SpaceEngineersGame(services, args))
                {
                    VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                    VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                    game.Run(disposeSplashScreen: m_startup.DisposeSplashScreen);
                }
            }
            m_startup.DetectSharpDxLeaksAfterRun();

#if PROFILING
            MyPerformanceTimer.WriteToLog();
#endif
            MyInitializer.InvokeAfterRun();
        }