public void Dispose() { #if !XB1 if (MySessionComponentExtDebug.Static != null) { MySessionComponentExtDebug.Static.Dispose(); MySessionComponentExtDebug.Static = null; } #endif // !XB1 if (MyMultiplayer.Static != null) MyMultiplayer.Static.Dispose(); if (GameRenderComponent != null) { GameRenderComponent.Dispose(); GameRenderComponent = null; } #if !XB1 // XB1_ALLINONEASSEMBLY MyPlugins.Unload(); #endif // !XB1 Parallel.Scheduler.WaitForTasksToFinish(TimeSpan.FromSeconds(10)); m_windowCreatedEvent.Dispose(); #if !XB1 if (MyFakes.ENABLE_ROSLYN_SCRIPTS) MyScriptCompiler.Static.Whitelist.Clear(); else IlChecker.Clear(); #endif Services = null; MyObjectBuilderType.UnregisterAssemblies(); MyObjectBuilderSerializer.UnregisterAssembliesAndSerializers(); }
public MySandboxGame(VRageGameServices services, string[] commandlineArgs) { ParseArgs(commandlineArgs); ProfilerShort.Begin("MySandboxGame()::constructor"); MySandboxGame.Log.WriteLine("MySandboxGame.Constructor() - START"); MySandboxGame.Log.IncreaseIndent(); Services = services; SharpDX.Configuration.EnableObjectTracking = MyCompilationSymbols.EnableSharpDxObjectTracking; UpdateThread = Thread.CurrentThread; // we want check objectbuilders, prefab's configurations, gameplay constants and building specifications ProfilerShort.Begin("Checks"); MySandboxGame.Log.WriteLine("Game dir: " + MyFileSystem.ExePath); MySandboxGame.Log.WriteLine("Content dir: " + MyFileSystem.ContentPath); ProfilerShort.BeginNextBlock("MyCustomGraphicsDeviceManagerDX"); Static = this; Console.CancelKeyPress += Console_CancelKeyPress; ProfilerShort.BeginNextBlock("InitNumberOfCores"); InitNumberOfCores(); ProfilerShort.BeginNextBlock("MyTexts.Init()"); MyLanguage.Init(); ProfilerShort.BeginNextBlock("MyGlobalTypeMetadata.Static.Init();"); MyGlobalTypeMetadata.Static.Init(); ProfilerShort.BeginNextBlock("MyDefinitionManager.LoadScenarios"); MyDefinitionManager.Static.LoadScenarios(); ProfilerShort.BeginNextBlock("MyTutorialHelper.Init"); MyTutorialHelper.Init(); ProfilerShort.BeginNextBlock("Preallocate"); Preallocate(); if (!IsDedicated) { ProfilerShort.BeginNextBlock("new MyGameRenderComponent"); GameRenderComponent = new MyGameRenderComponent(); } else { #if !XB1 ProfilerShort.BeginNextBlock("Dedicated server setup"); MySandboxGame.ConfigDedicated.Load(); //ignum //+connect 62.109.134.123:27025 IPAddress address = MyDedicatedServerOverrides.IpAddress ?? IPAddressExtensions.ParseOrAny(MySandboxGame.ConfigDedicated.IP); ushort port = (ushort)(MyDedicatedServerOverrides.Port ?? MySandboxGame.ConfigDedicated.ServerPort); IPEndPoint ep = new IPEndPoint(address, port); MyLog.Default.WriteLineAndConsole("Bind IP : " + ep.ToString()); MyDedicatedServerBase dedicatedServer = null; if (MyFakes.ENABLE_BATTLE_SYSTEM && MySandboxGame.ConfigDedicated.SessionSettings.Battle) dedicatedServer = new MyDedicatedServerBattle(ep); else dedicatedServer = new MyDedicatedServer(ep); MyMultiplayer.Static = dedicatedServer; FatalErrorDuringInit = !dedicatedServer.ServerStarted; if (FatalErrorDuringInit && !Environment.UserInteractive) { var e = new Exception("Fatal error during dedicated server init: " + dedicatedServer.ServerInitError); e.Data["Silent"] = true; throw e; } #else // XB1 System.Diagnostics.Debug.Assert(false, "No dedicated server on XB1"); #endif // XB1 } // Game tags contain game data hash, so they need to be sent after preallocation if (IsDedicated && !FatalErrorDuringInit) { (MyMultiplayer.Static as MyDedicatedServerBase).SendGameTagsToSteam(); } SessionCompatHelper = Activator.CreateInstance(MyPerGameSettings.CompatHelperType) as MySessionCompatHelper; ProfilerShort.BeginNextBlock("InitMultithreading"); InitMultithreading(); ProfilerShort.End(); if (!IsDedicated && SteamSDK.SteamAPI.Instance != null) { SteamSDK.SteamAPI.Instance.OnPingServerResponded += ServerResponded; SteamSDK.SteamAPI.Instance.OnPingServerFailedToRespond += ServerFailedToRespond; SteamSDK.Peer2Peer.ConnectionFailed += Peer2Peer_ConnectionFailed; } #if !XB1 MyMessageLoop.AddMessageHandler(MyWMCodes.GAME_IS_RUNNING_REQUEST, OnToolIsGameRunningMessage); #endif MySandboxGame.Log.DecreaseIndent(); MySandboxGame.Log.WriteLine("MySandboxGame.Constructor() - END"); ProfilerShort.End(); ProfilerShort.BeginNextBlock("InitCampaignManager"); MyCampaignManager.Static.Init(); ProfilerShort.End(); }