/// <summary> /// Start server on the current thread. /// </summary> public override void Start() { if (State != ServerState.Stopped) { throw new InvalidOperationException("Server is already running."); } Config.Save(); State = ServerState.Starting; Log.Info("Starting server."); var runInternal = typeof(DedicatedServer).GetMethod("RunInternal", BindingFlags.Static | BindingFlags.NonPublic); MySandboxGame.IsDedicated = true; Environment.SetEnvironmentVariable("SteamAppId", MyPerServerSettings.AppId.ToString()); VRage.Service.ExitListenerSTA.OnExit += delegate { MySandboxGame.Static?.Exit(); }; do { runInternal.Invoke(null, null); } while (MySandboxGame.IsReloading); MyInitializer.InvokeAfterRun(); State = ServerState.Stopped; }
protected override bool SetupBasicGameInfo() { SpaceEngineersGame.SetupBasicGameInfo(); m_startup = new MyCommonProgramStartup(m_args); var appDataPath = m_startup.GetAppDataPath(); VRage.Platform.Windows.MyVRageWindows.Init(MyPerGameSettings.BasicGameInfo.ApplicationName, MySandboxGame.Log, appDataPath, false); MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName + "ModTool", MyVRage.Platform.System.GetAppDataPath()); MyRenderProxy.Initialize((IMyRender) new MyNullRender()); MyInitializer.InitCheckSum(); if (m_startup.PerformColdStart()) { return(false); } if (!m_startup.Check64Bit()) { return(false); } m_steamService = VRage.Steam.MySteamGameService.Create(MySandboxGame.IsDedicated, AppId); MyServiceManager.Instance.AddService(m_steamService); MyServiceManager.Instance.AddService(VRage.Steam.MySteamUgcService.Create(AppId, m_steamService)); if (m_useModIO) { MyLog.Default.WriteLineAndConsole("Using mod.io service, instead of Steam."); MyServiceManager.Instance.AddService(VRage.Mod.Io.MyModIoService.Create(MySandboxGame.IsDedicated, MyServiceManager.Instance.GetService <IMyGameService>(), ModIO_GameName, ModIO_GameID, ModIO_Key, ModIO_TestGameID, ModIO_TestKey, false)); } SpaceEngineersGame.SetupPerGameSettings(); ManuallyAddDLCs(); return(true); }
public override void Init() { base.Init(); Log.Info($"Init server '{Config.InstanceName}' at '{Config.InstancePath}'"); MyFakes.ENABLE_INFINARIO = false; MyPerGameSettings.SendLogToKeen = false; MyPerServerSettings.GameName = MyPerGameSettings.GameName; MyPerServerSettings.GameNameSafe = MyPerGameSettings.GameNameSafe; MyPerServerSettings.GameDSName = MyPerServerSettings.GameNameSafe + "Dedicated"; MyPerServerSettings.GameDSDescription = "Your place for space engineering, destruction and exploring."; MySessionComponentExtDebug.ForceDisable = true; MyPerServerSettings.AppId = 244850; MyFinalBuildConstants.APP_VERSION = MyPerGameSettings.BasicGameInfo.GameVersion; MyPlugins.RegisterGameAssemblyFile(MyPerGameSettings.GameModAssembly); MyPlugins.RegisterGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModObjBuildersAssembly); MyPlugins.RegisterSandboxAssemblyFile(MyPerGameSettings.SandboxAssembly); MyPlugins.RegisterSandboxGameAssemblyFile(MyPerGameSettings.SandboxGameAssembly); MyPlugins.Load(); MyGlobalTypeMetadata.Static.Init(); MyInitializer.InvokeBeforeRun( MyPerServerSettings.AppId, MyPerServerSettings.GameDSName, InstancePath, DedicatedServer.AddDateToLog); }
void ReadPendingIsResetAfterEachRead0(ServerBootstrap sb, Bootstrap cb) { var serverInitializer = new MyInitializer(); sb.Option(ChannelOption.SoBacklog, 1024); sb.ChildHandler(serverInitializer); // start server Task <IChannel> task = sb.BindAsync(LoopbackAnyPort); Assert.True(task.Wait(DefaultTimeout), "Server bind timed out"); this.serverChannel = task.Result; Assert.NotNull(this.serverChannel.LocalAddress); var endPoint = (IPEndPoint)this.serverChannel.LocalAddress; cb.Handler(new MyInitializer()); // connect to server task = cb.ConnectAsync(endPoint); Assert.True(task.Wait(DefaultTimeout), "Connect to server timed out"); this.clientChannel = task.Result; Assert.NotNull(this.clientChannel.LocalAddress); Task writeTask = this.clientChannel.WriteAndFlushAsync(Unpooled.WrappedBuffer(new byte[1024])); Assert.True(writeTask.Wait(DefaultTimeout), "Write task timed out"); ExceptionHandler exceptionHandler = serverInitializer.ErrorHandler; Assert.True(exceptionHandler.Inactive.Wait(DefaultTimeout), "Handler inactive timed out"); Assert.Equal(1, exceptionHandler.Count); }
private void Destroy() { _game.Dispose(); _game = null; MyGameService.ShutDown(); _getVRagePluginList().Remove(_torch); MyInitializer.InvokeAfterRun(); }
private void simpleAction1_Execute(object sender, SimpleActionExecuteEventArgs e) { using (var db = new MyDbContext()) { db.Categories.RemoveRange(db.Categories); db.SaveChanges(); MyInitializer.SeedRecords(db); } View.ObjectSpace.Refresh(); }
public override void Init() { Log.Info("Initializing Torch Client"); base.Init(); if (!File.Exists("steam_appid.txt")) { Directory.SetCurrentDirectory(Path.GetDirectoryName(typeof(VRage.FastResourceLock).Assembly.Location) + "\\.."); } SpaceEngineersGame.SetupBasicGameInfo(); _startup = new MyCommonProgramStartup(RunArgs); if (_startup.PerformReporting()) { return; } _startup.PerformAutoconnect(); if (!_startup.CheckSingleInstance()) { return; } var appDataPath = _startup.GetAppDataPath(); MyInitializer.InvokeBeforeRun(APP_ID, MyPerGameSettings.BasicGameInfo.ApplicationName, appDataPath); MyInitializer.InitCheckSum(); if (!_startup.Check64Bit()) { return; } _startup.DetectSharpDxLeaksBeforeRun(); using (var mySteamService = new SteamService(Game.IsDedicated, APP_ID)) { _renderer = null; SpaceEngineersGame.SetupPerGameSettings(); OverrideMenus(); InitializeRender(); _services = new VRageGameServices(mySteamService); if (!Game.IsDedicated) { MyFileSystem.InitUserSpecific(mySteamService.UserId.ToString()); } } _startup.DetectSharpDxLeaksAfterRun(); MyInitializer.InvokeAfterRun(); }
protected override bool SetupBasicGameInfo() { MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName + "ModTool"); if (!m_startup.Check64Bit()) { return(false); } MyMedievalGame.SetupPerGameSettings(); return(true); }
public override void Init() { Directory.SetCurrentDirectory(Program.SpaceEngineersInstallAlias); MyFileSystem.ExePath = Path.Combine(Program.SpaceEngineersInstallAlias, Program.SpaceEngineersBinaries); Log.Info("Initializing Torch Client"); base.Init(); SpaceEngineersGame.SetupBasicGameInfo(); _startup = new MyCommonProgramStartup(RunArgs); if (_startup.PerformReporting()) { throw new InvalidOperationException("Torch client won't launch when started in error reporting mode"); } _startup.PerformAutoconnect(); if (!_startup.CheckSingleInstance()) { throw new InvalidOperationException("Only one instance of Space Engineers can be running at a time."); } var appDataPath = _startup.GetAppDataPath(); MyInitializer.InvokeBeforeRun(APP_ID, MyPerGameSettings.BasicGameInfo.ApplicationName, appDataPath); MyInitializer.InitCheckSum(); _startup.InitSplashScreen(); if (!_startup.Check64Bit()) { throw new InvalidOperationException("Torch requires a 64bit operating system"); } _startup.DetectSharpDxLeaksBeforeRun(); var steamService = new SteamService(Game.IsDedicated, APP_ID); MyServiceManager.Instance.AddService <IMyGameService>(steamService); _renderer = null; SpaceEngineersGame.SetupPerGameSettings(); // I'm sorry, but it's what Keen does in SpaceEngineers.MyProgram #pragma warning disable 612 SpaceEngineersGame.SetupRender(); #pragma warning restore 612 InitializeRender(); if (!_startup.CheckSteamRunning()) { throw new InvalidOperationException("Space Engineers requires steam to be running"); } if (!Game.IsDedicated) { MyFileSystem.InitUserSpecific(MyGameService.UserId.ToString()); } }
protected override bool SetupBasicGameInfo() { SpaceEngineersGame.SetupBasicGameInfo(); m_startup = new MyCommonProgramStartup(m_args); var appDataPath = m_startup.GetAppDataPath(); VRage.Platform.Windows.MyVRageWindows.Init(MyPerGameSettings.BasicGameInfo.ApplicationName, MySandboxGame.Log, appDataPath, false); MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName + "ModTool", MyVRage.Platform.System.GetAppDataPath()); MyRenderProxy.Initialize((IMyRender) new MyNullRender()); MyInitializer.InitCheckSum(); if (m_startup.PerformColdStart()) { return(false); } if (!m_startup.Check64Bit()) { return(false); } m_steamService = MySteamGameService.Create(MySandboxGame.IsDedicated, AppId); MyServiceManager.Instance.AddService(m_steamService); MyServerDiscoveryAggregator serverDiscoveryAggregator = new MyServerDiscoveryAggregator(); MySteamGameService.InitNetworking(false, m_steamService, MyPerGameSettings.BasicGameInfo.GameName, serverDiscoveryAggregator, true, true); // If user specified --modio, set that as the "default" (added first) var modioService = MyModIoService.Create(MyServiceManager.Instance.GetService <IMyGameService>(), ModIO_GameName, ModIO_GameID, ModIO_Key, ModIO_TestGameID, ModIO_TestKey, MyPlatformGameSettings.UGC_TEST_ENVIRONMENT, m_useModIO ? true : false); if (m_useModIO) { MyGameService.WorkshopService.AddAggregate(modioService); } MyGameService.WorkshopService.AddAggregate(MySteamUgcService.Create(AppId, m_steamService)); if (!m_useModIO) { MyGameService.WorkshopService.AddAggregate(modioService); } SpaceEngineersGame.SetupPerGameSettings(); ManuallyAddDLCs(); return(true); }
protected override bool SetupBasicGameInfo() { MyMedievalGame.SetupBasicGameInfo(); m_startup = new MyCommonProgramStartup(new string[] { }); var appDataPath = m_startup.GetAppDataPath(); MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName + "ModTool", appDataPath); if (!m_startup.Check64Bit()) { return(false); } m_steamService = new WorkshopTool.MySteamService(MySandboxGame.IsDedicated, AppId); MyServiceManager.Instance.AddService <IMyGameService>(m_steamService); MyMedievalGame.SetupPerGameSettings(); return(true); }
private async Task TestReadPendingIsResetAfterEachRead0(ServerBootstrap sb, Bootstrap cb) { IChannel serverChannel = null; IChannel clientChannel = null; try { MyInitializer serverInitializer = new MyInitializer(); sb.Option(ChannelOption.SoBacklog, 1024); sb.ChildHandler(serverInitializer); serverChannel = await sb.BindAsync(); cb.Handler(new MyInitializer()); clientChannel = await cb.ConnectAsync(serverChannel.LocalAddress); await clientChannel.WriteAndFlushAsync(Unpooled.WrappedBuffer(new byte[1024])); // We expect to get 2 exceptions (1 from BuggyChannelHandler and 1 from ExceptionHandler). Assert.True(serverInitializer._exceptionHandler._latch1.Wait(TimeSpan.FromSeconds(5))); // After we get the first exception, we should get no more, this is expected to timeout. Assert.False(serverInitializer._exceptionHandler._latch2.Wait(TimeSpan.FromSeconds(1)), "Encountered " + serverInitializer._exceptionHandler._count.Value + " exceptions when 1 was expected"); } finally { if (serverChannel != null) { await serverChannel.CloseAsync(); } if (clientChannel != null) { await clientChannel.CloseAsync(); } Task.WaitAll( sb.Group().ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(5)), sb.ChildGroup().ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(5)), cb.Group().ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(5))); } }
internal static void RunMain(string instanceName, string customPath, bool isService, bool showConsole = true) { var tmp = (isService) ? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), MyPerServerSettings.GameDSName, instanceName) : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), MyPerServerSettings.GameDSName); var userDataPath = string.IsNullOrEmpty(customPath) ? tmp : customPath; if (showConsole && Environment.UserInteractive) { MySandboxGame.IsConsoleVisible = true; VRage.Win32.WinApi.AllocConsole(); consoleHandler += new VRage.Win32.WinApi.ConsoleEventHandler(Handler); VRage.Win32.WinApi.SetConsoleCtrlHandler(consoleHandler, true); } VRage.Service.ExitListenerSTA.OnExit += delegate { if (MySandboxGame.Static != null) { MySandboxGame.Static.Exit(); } }; Console.WriteLine(MyPerServerSettings.GameName + " " + MyFinalBuildConstants.APP_VERSION_STRING); Console.WriteLine(String.Format("Is official: {0} {1}", MyFinalBuildConstants.IS_OFFICIAL, (MyObfuscation.Enabled ? "[O]" : "[NO]"))); Console.WriteLine("Environment.Is64BitProcess: " + Environment.Is64BitProcess); MyInitializer.InvokeBeforeRun( MyPerServerSettings.AppId, MyPerServerSettings.GameDSName, userDataPath, DedicatedServer.AddDateToLog); do { RunInternal(); } while (MySandboxGame.IsReloading); MyInitializer.InvokeAfterRun(); }
private void Create() { bool dedicated = true; Environment.SetEnvironmentVariable("SteamAppId", _appSteamId.ToString()); SpaceEngineersGame.SetupBasicGameInfo(); SpaceEngineersGame.SetupPerGameSettings(); MyFinalBuildConstants.APP_VERSION = MyPerGameSettings.BasicGameInfo.GameVersion; MySessionComponentExtDebug.ForceDisable = true; MyPerGameSettings.SendLogToKeen = false; // SpaceEngineersGame.SetupAnalytics(); //not implemented by keen.. removed in cross-play update //MyVRage.Platform.InitScripting(MyVRageScripting.Create()); _ = MyVRage.Platform.Scripting; MyFileSystem.ExePath = Path.GetDirectoryName(typeof(SpaceEngineersGame).Assembly.Location); _tweakGameSettings(); MyFileSystem.Reset(); MyInitializer.InvokeBeforeRun(_appSteamId, _appName, _userDataPath); _log.Info("Loading Dedicated Config"); // object created in SpaceEngineersGame.SetupPerGameSettings() MySandboxGame.ConfigDedicated.Load(); MyPlatformGameSettings.CONSOLE_COMPATIBLE = MySandboxGame.ConfigDedicated.ConsoleCompatibility; //Type.GetType("VRage.Steam.MySteamService, VRage.Steam").GetProperty("IsActive").GetSetMethod(true).Invoke(service, new object[] {SteamAPI.Init()}); _log.Info("Initializing network services"); var isEos = TorchBase.Instance.Config.UgcServiceType == UGCServiceType.EOS; if (isEos) { _log.Info("Running on Epic Online Services."); _log.Warn("Steam workshop will not work with current settings. Some functions might not work properly!"); } var aggregator = new MyServerDiscoveryAggregator(); MyServiceManager.Instance.AddService <IMyServerDiscovery>(aggregator); IMyGameService service; if (isEos) { service = MyEOSService.Create(); MyEOSService.InitNetworking(dedicated, "Space Engineers", service, "xyza7891A4WeGrpP85BTlBa3BSfUEABN", "ZdHZVevSVfIajebTnTmh5MVi3KPHflszD9hJB7mRkgg", "24b1cd652a18461fa9b3d533ac8d6b5b", "1958fe26c66d4151a327ec162e4d49c8", "07c169b3b641401496d352cad1c905d6", "https://retail.epicgames.com/", MyEOSService.CreatePlatform(), MySandboxGame.ConfigDedicated.VerboseNetworkLogging, Enumerable.Empty <string>(), aggregator, MyMultiplayer.Channels); var mockingInventory = new MyMockingInventory(service); MyServiceManager.Instance.AddService <IMyInventoryService>(mockingInventory); } else { service = MySteamGameService.Create(dedicated, _appSteamId); MyGameService.WorkshopService.AddAggregate(MySteamUgcService.Create(_appSteamId, service)); MySteamGameService.InitNetworking(dedicated, service, "Space Engineers", aggregator); } MyServiceManager.Instance.AddService(service); MyGameService.WorkshopService.AddAggregate(MyModIoService.Create(service, "spaceengineers", "264", "1fb4489996a5e8ffc6ec1135f9985b5b", "331", "f2b64abe55452252b030c48adc0c1f0e", MyPlatformGameSettings.UGC_TEST_ENVIRONMENT, true)); if (!isEos && !MyGameService.HasGameServer) { _log.Warn("Network service is not running! Please reinstall dedicated server."); return; } _log.Info("Initializing services"); MyServiceManager.Instance.AddService <IMyMicrophoneService>(new MyNullMicrophone()); MyNetworkMonitor.Init(); _log.Info("Services initialized"); MySandboxGame.InitMultithreading(); // MyInitializer.InitCheckSum(); // Hook into the VRage plugin system for updates. _getVRagePluginList().Add(_torch); if (!MySandboxGame.IsReloading) { MyFileSystem.InitUserSpecific(dedicated ? null : MyGameService.UserId.ToString()); } MySandboxGame.IsReloading = dedicated; // render init { IMyRender renderer = null; if (dedicated) { renderer = new MyNullRender(); } else { MyPerformanceSettings preset = MyGuiScreenOptionsGraphics.GetPreset(MyRenderPresetEnum.NORMAL); MyRenderProxy.Settings.User = MyVideoSettingsManager.GetGraphicsSettingsFromConfig(ref preset, false) .PerformanceSettings.RenderSettings; MyStringId graphicsRenderer = MySandboxGame.Config.GraphicsRenderer; if (graphicsRenderer == MySandboxGame.DirectX11RendererKey) { renderer = new MyDX11Render(new MyRenderSettings?(MyRenderProxy.Settings)); if (!renderer.IsSupported) { MySandboxGame.Log.WriteLine( "DirectX 11 renderer not supported. No renderer to revert back to."); renderer = null; } } if (renderer == null) { throw new MyRenderException( "The current version of the game requires a Dx11 card. \\n For more information please see : http://blog.marekrosa.org/2016/02/space-engineers-news-full-source-code_26.html", MyRenderExceptionEnum.GpuNotSupported); } MySandboxGame.Config.GraphicsRenderer = graphicsRenderer; } MyRenderProxy.Initialize(renderer); MyRenderProfiler.SetAutocommit(false); //This broke services? //MyRenderProfiler.InitMemoryHack("MainEntryPoint"); } // Loads object builder serializers. Intuitive, right? _log.Info("Setting up serializers"); MyPlugins.RegisterGameAssemblyFile(MyPerGameSettings.GameModAssembly); if (MyPerGameSettings.GameModBaseObjBuildersAssembly != null) { MyPlugins.RegisterBaseGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModBaseObjBuildersAssembly); } MyPlugins.RegisterGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModObjBuildersAssembly); MyPlugins.RegisterSandboxAssemblyFile(MyPerGameSettings.SandboxAssembly); MyPlugins.RegisterSandboxGameAssemblyFile(MyPerGameSettings.SandboxGameAssembly); //typeof(MySandboxGame).GetMethod("Preallocate", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, null); MyGlobalTypeMetadata.Static.Init(false); }
// 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(); }
public IActionResult Index() { MyInitializer.Seed(_context); return(View()); }
private void Create() { bool dedicated = Sandbox.Engine.Platform.Game.IsDedicated; Environment.SetEnvironmentVariable("SteamAppId", _appSteamId.ToString()); MyServiceManager.Instance.AddService <IMyGameService>(new MySteamService(dedicated, _appSteamId)); if (dedicated && !MyGameService.HasGameServer) { _log.Warn("Steam service is not running! Please reinstall dedicated server."); return; } SpaceEngineersGame.SetupBasicGameInfo(); SpaceEngineersGame.SetupPerGameSettings(); MyFinalBuildConstants.APP_VERSION = MyPerGameSettings.BasicGameInfo.GameVersion; MySessionComponentExtDebug.ForceDisable = true; MyPerGameSettings.SendLogToKeen = false; // SpaceEngineersGame.SetupAnalytics(); MyFileSystem.ExePath = Path.GetDirectoryName(typeof(SpaceEngineersGame).Assembly.Location); _tweakGameSettings(); MyFileSystem.Reset(); MyInitializer.InvokeBeforeRun(_appSteamId, _appName, _userDataPath); // MyInitializer.InitCheckSum(); // Hook into the VRage plugin system for updates. _getVRagePluginList().Add(_torch); if (!MySandboxGame.IsReloading) { MyFileSystem.InitUserSpecific(dedicated ? null : MyGameService.UserId.ToString()); } MySandboxGame.IsReloading = dedicated; // render init { IMyRender renderer = null; if (dedicated) { renderer = new MyNullRender(); } else { MyPerformanceSettings preset = MyGuiScreenOptionsGraphics.GetPreset(MyRenderQualityEnum.NORMAL); MyRenderProxy.Settings.User = MyVideoSettingsManager.GetGraphicsSettingsFromConfig(ref preset) .PerformanceSettings.RenderSettings; MyStringId graphicsRenderer = MySandboxGame.Config.GraphicsRenderer; if (graphicsRenderer == MySandboxGame.DirectX11RendererKey) { renderer = new MyDX11Render(new MyRenderSettings?(MyRenderProxy.Settings)); if (!renderer.IsSupported) { MySandboxGame.Log.WriteLine( "DirectX 11 renderer not supported. No renderer to revert back to."); renderer = null; } } if (renderer == null) { throw new MyRenderException( "The current version of the game requires a Dx11 card. \\n For more information please see : http://blog.marekrosa.org/2016/02/space-engineers-news-full-source-code_26.html", MyRenderExceptionEnum.GpuNotSupported); } MySandboxGame.Config.GraphicsRenderer = graphicsRenderer; } MyRenderProxy.Initialize(renderer); MyRenderProxy.GetRenderProfiler().SetAutocommit(false); MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint"); } // Loads object builder serializers. Intuitive, right? _log.Info("Setting up serializers"); MyPlugins.RegisterGameAssemblyFile(MyPerGameSettings.GameModAssembly); if (MyPerGameSettings.GameModBaseObjBuildersAssembly != null) { MyPlugins.RegisterBaseGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModBaseObjBuildersAssembly); } MyPlugins.RegisterGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModObjBuildersAssembly); MyPlugins.RegisterSandboxAssemblyFile(MyPerGameSettings.SandboxAssembly); MyPlugins.RegisterSandboxGameAssemblyFile(MyPerGameSettings.SandboxGameAssembly); //typeof(MySandboxGame).GetMethod("Preallocate", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, null); MyGlobalTypeMetadata.Static.Init(false); }
public Context() : base("name=ConnectionString") { var initializer = new MyInitializer(); Database.SetInitializer(initializer); }
public override void Dispose() { MyGameService.ShutDown(); _startup.DetectSharpDxLeaksAfterRun(); MyInitializer.InvokeAfterRun(); }
// 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(); }
public void TestSetUp() { MyInitializer db = new MyInitializer(); System.Data.Entity.Database.SetInitializer(db); }
// 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); } }