public void Init(object gameInstance) { var commandLine = new CommandLine(Environment.CommandLine); Game = (MySandboxGame)gameInstance; var targetsArgumentIndex = commandLine.IndexOf("-whitelistcaches"); if (targetsArgumentIndex == -1 || targetsArgumentIndex == commandLine.Count - 1) { Game.Exit(); return; } var targetsArgument = commandLine[targetsArgumentIndex + 1]; var targets = targetsArgument.Split(';'); WriteWhitelists(targets); Game.Exit(); }
// This is mostly copied from MyProgram.Main(), with UI stripped out. protected virtual void InitSandbox(string[] args) { m_args = args; // Infinario was removed from SE in update 1.184.6, but is still in ME var infinario = typeof(MyFakes).GetField("ENABLE_INFINARIO"); if (infinario != null) { infinario.SetValue(null, false); } if (m_game != null) { m_game.Exit(); } if (!SetupBasicGameInfo()) { return; } // Init null render so profiler-enabled builds don't crash var render = new MyNullRender(); MyRenderProxy.Initialize(render); #if SE EmptyKeys.UserInterface.Engine engine = (EmptyKeys.UserInterface.Engine) new VRage.UserInterface.MyEngine(); if (System.Diagnostics.Debugger.IsAttached) { m_startup.CheckSteamRunning(); // Just give the warning message box when debugging, ignore for release } if (!Sandbox.Engine.Platform.Game.IsDedicated) { MyFileSystem.InitUserSpecific(m_steamService.UserId.ToString()); } #endif try { #if !SE MyRenderProxy.GetRenderProfiler().SetAutocommit(false); MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint"); #endif // NOTE: an assert may be thrown in debug, about missing Tutorials.sbx. Ignore it. m_game = InitGame(); // Initializing the workshop means the categories are available var initWorkshopMethod = m_game.GetType().GetMethod("InitSteamWorkshop", BindingFlags.NonPublic | BindingFlags.Instance); MyDebug.AssertRelease(initWorkshopMethod != null); if (initWorkshopMethod != null) { var parameters = initWorkshopMethod.GetParameters(); MyDebug.AssertRelease(parameters.Count() == 0); } if (initWorkshopMethod != null) { initWorkshopMethod.Invoke(m_game, null); } else { MySandboxGame.Log.WriteLineAndConsole(string.Format(Constants.ERROR_Reflection, "InitSteamWorkshop")); } } catch (Exception ex) { // This shouldn't fail, but don't stop even if it does ex.Log("WARNING: An exception occured, ignoring: "); } AuthenticateWorkshop(); }
// This is mostly copied from MyProgram.Main(), with UI stripped out. private static void InitSandbox(string instancepath) { MyFakes.ENABLE_INFINARIO = false; if (m_spacegame != null) { m_spacegame.Exit(); } SpaceEngineersGame.SetupBasicGameInfo(); m_startup = new MyCommonProgramStartup(new string[] { }); var appDataPath = m_startup.GetAppDataPath(); MyInitializer.InvokeBeforeRun(AppId_SE, MyPerGameSettings.BasicGameInfo.ApplicationName + "ModTool", appDataPath); MyInitializer.InitCheckSum(); if (!m_startup.Check64Bit()) { return; } m_steamService = new MySteamService(MySandboxGame.IsDedicated, AppId_SE); SpaceEngineersGame.SetupPerGameSettings(); if (System.Diagnostics.Debugger.IsAttached) { m_startup.CheckSteamRunning(m_steamService); // Just give the warning message box when debugging, ignore for release } VRageGameServices services = new VRageGameServices(m_steamService); if (!MySandboxGame.IsDedicated) { MyFileSystem.InitUserSpecific(m_steamService.UserId.ToString()); } try { // NOTE: an assert may be thrown in debug, about missing Tutorials.sbx. Ignore it. m_spacegame = new SpaceEngineersGame(services, null); // Initializing the workshop means the categories are available var initWorkshopMethod = typeof(SpaceEngineersGame).GetMethod("InitSteamWorkshop", BindingFlags.NonPublic | BindingFlags.Instance); MyDebug.AssertDebug(initWorkshopMethod != null); if (initWorkshopMethod != null) { var parameters = initWorkshopMethod.GetParameters(); MyDebug.AssertDebug(parameters.Count() == 0); } if (initWorkshopMethod != null) { initWorkshopMethod.Invoke(m_spacegame, null); } else { MySandboxGame.Log.WriteLineAndConsole(string.Format(Constants.ERROR_Reflection, "InitSteamWorkshop")); } } catch (Exception ex) { // This shouldn't fail, but don't stop even if it does MySandboxGame.Log.WriteLineAndConsole("An exception occured, ignoring: " + ex.Message); } }