Esempio n. 1
0
 /// <inheritdoc />
 public override void Attach()
 {
     MyFileSystem.ExePath = Path.Combine(_filesystemManager.TorchDirectory, "DedicatedServer64");
     MyFileSystem.Init("Content", Torch.Config.InstancePath);
     //Initializes saves path. Why this isn't in Init() we may never know.
     MyFileSystem.InitUserSpecific(null);
 }
        static void RunInternal()
        {
            MyFileSystem.InitUserSpecific(null);

            VRageRender.MyRenderProxy.Initialize(MySandboxGame.IsDedicated ? (IMyRender) new MyNullRender() : new MyDX9Render());
            VRageRender.MyRenderProxy.IS_OFFICIAL = MyFinalBuildConstants.IS_OFFICIAL;

            using (MySteamService steamService = new MySteamService(MySandboxGame.IsDedicated, MyPerServerSettings.AppId))
            {
                if (!steamService.HasGameServer)
                {
                    MyLog.Default.WriteLineAndConsole("Steam service is not running! Please reinstall dedicated server.");
                    return;
                }

                VRageGameServices services = new VRageGameServices(steamService);

                using (MySandboxGame game = new MySandboxGame(services, Environment.GetCommandLineArgs().Skip(1).ToArray()))
                {
                    VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                    VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

                    game.Run();
                }

                if (MySandboxGame.IsConsoleVisible)
                {
                    Console.WriteLine("Server stopped, press any key to close this window");
                    Console.ReadKey(false);
                }
            }
        }
        public SpaceEngineersCore()
        {
            var    contentPath  = ToolboxUpdater.GetApplicationContentPath();
            string userDataPath = SpaceEngineersConsts.BaseLocalPath.DataPath;

            MyFileSystem.Reset();
            MyFileSystem.Init(contentPath, userDataPath);

            MyLog.Default        = MySandboxGame.Log;
            MySandboxGame.Config = new MyConfig("SpaceEngineers.cfg"); // TODO: Is specific to SE, not configurable to ME.
            MySandboxGame.Config.Load();

            MyFileSystem.InitUserSpecific(null);

            SpaceEngineersGame.SetupPerGameSettings();

            VRageRender.MyRenderProxy.Initialize(new MyNullRender());
            // We create a whole instance of MySandboxGame!
            MySandboxGame gameTemp = new MySandboxGame(null);

            // creating MySandboxGame will reset the CurrentUICulture, so I have to reapply it.
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfoByIetfLanguageTag(GlobalSettings.Default.LanguageCode);
            SpaceEngineersApi.LoadLocalization();

            _stockDefinitions = new SpaceEngineersResources();
            _stockDefinitions.LoadDefinitions();
            _manageDeleteVoxelList = new List <string>();
        }
Esempio n. 4
0
        public void InitMyFileSystem(string instanceName = "", bool reset = true)
        {
            string contentPath  = Path.Combine(new FileInfo(MyFileSystem.ExePath).Directory.FullName, "Content");
            string userDataPath = Instance.GetUserDataPath(instanceName);

            if (reset)
            {
                MyFileSystem.Reset( );
            }
            else
            {
                try
                {
                    if (!string.IsNullOrWhiteSpace(MyFileSystem.ContentPath))
                    {
                        return;
                    }
                    if (!string.IsNullOrWhiteSpace(MyFileSystem.UserDataPath))
                    {
                        return;
                    }
                }
                catch (Exception)
                {
                    //Do nothing
                }
            }

            MyFileSystem.Init(contentPath, userDataPath);
            MyFileSystem.InitUserSpecific(null);

            m_instanceName = instanceName;
        }
Esempio n. 5
0
        public SpaceEngineersCore()
        {
            var    contentPath  = ToolboxUpdater.GetApplicationContentPath();
            string userDataPath = SpaceEngineersConsts.BaseLocalPath.DataPath;

            MyFileSystem.Reset();
            MyFileSystem.Init(contentPath, userDataPath);

            MyLog.Default        = MySandboxGame.Log;
            MySandboxGame.Config = new MyConfig("SpaceEngineers.cfg"); // TODO: Is specific to SE, not configurable to ME.
            MySandboxGame.Config.Load();

            MyFileSystem.InitUserSpecific(null);

            SpaceEngineersGame.SetupPerGameSettings();

            VRageRender.MyRenderProxy.Initialize(new MyNullRender());
            // We create a whole instance of MySandboxGame!
            // If this is causing an exception, then there is a missing dependency.
            MySandboxGame gameTemp = new MySandboxGame(new string[] { "-skipintro" });

            // creating MySandboxGame will reset the CurrentUICulture, so I have to reapply it.
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfoByIetfLanguageTag(GlobalSettings.Default.LanguageCode);
            SpaceEngineersApi.LoadLocalization();
            MyStorageBase.UseStorageCache = false;

            #region MySession creation

            // Replace the private constructor on MySession, so we can create it without getting involed with Havok and other depdancies.
            var keenStart = typeof(Sandbox.Game.World.MySession).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(MySyncLayer), typeof(bool) }, null);
            var ourStart  = typeof(SEToolbox.Interop.MySession).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(MySyncLayer), typeof(bool) }, null);
            ReflectionUtil.ReplaceMethod(ourStart, keenStart);

            // Create an empty instance of MySession for use by low level code.
            Sandbox.Game.World.MySession mySession = ReflectionUtil.ConstructPrivateClass <Sandbox.Game.World.MySession>(new Type[0], new object[0]);
            ReflectionUtil.ConstructField(mySession, "m_sessionComponents"); // Required as the above code doesn't populate it during ctor of MySession.
            mySession.Settings = new MyObjectBuilder_SessionSettings {
                EnableVoxelDestruction = true
            };

            VRage.MyVRage.Init(new ToolboxPlatform());

            // change for the Clone() method to use XML cloning instead of Protobuf because of issues with MyObjectBuilder_CubeGrid.Clone()
            ReflectionUtil.SetFieldValue(typeof(VRage.ObjectBuilders.MyObjectBuilderSerializer), "ENABLE_PROTOBUFFERS_CLONING", false);

            // Assign the instance back to the static.
            Sandbox.Game.World.MySession.Static = mySession;

            Sandbox.Game.GameSystems.MyHeightMapLoadingSystem.Static = new MyHeightMapLoadingSystem();
            Sandbox.Game.GameSystems.MyHeightMapLoadingSystem.Static.LoadData();

            #endregion

            _stockDefinitions = new SpaceEngineersResources();
            _stockDefinitions.LoadDefinitions();
            _manageDeleteVoxelList = new List <string>();
        }
Esempio n. 6
0
        public void LoadInstance(string path, bool validate = true)
        {
            Log.Info($"Loading instance {path}");

            if (validate)
            {
                ValidateInstance(path);
            }

            MyFileSystem.Reset();
            MyFileSystem.Init("Content", path);
            //Initializes saves path. Why this isn't in Init() we may never know.
            MyFileSystem.InitUserSpecific(null);

            var configPath = Path.Combine(path, CONFIG_NAME);

            if (!File.Exists(configPath))
            {
                Log.Error($"Failed to load dedicated config at {path}");
                return;
            }

            var config = new MyConfigDedicated <MyObjectBuilder_SessionSettings>(configPath);

            config.Load(configPath);

            DedicatedConfig = new ConfigDedicatedViewModel(config);

            var worldFolders = Directory.EnumerateDirectories(Path.Combine(Torch.Config.InstancePath, "Saves"));

            foreach (var f in worldFolders)
            {
                try
                {
                    if (!string.IsNullOrEmpty(f) && File.Exists(Path.Combine(f, "Sandbox.sbc")))
                    {
                        DedicatedConfig.Worlds.Add(new WorldViewModel(f));
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("Failed to load world at path: " + f);
                    continue;
                }
            }

            if (DedicatedConfig.Worlds.Count == 0)
            {
                Log.Warn($"No worlds found in the current instance {path}.");
                return;
            }

            SelectWorld(DedicatedConfig.LoadWorld ?? DedicatedConfig.Worlds.First().WorldPath, false);

            InstanceLoaded?.Invoke(DedicatedConfig);
        }
Esempio n. 7
0
        public void InitMyFileSystem(string instanceName = "")
        {
            string contentPath  = Path.Combine(new FileInfo(MyFileSystem.ExePath).Directory.FullName, "Content");
            string userDataPath = SandboxGameAssemblyWrapper.Instance.GetUserDataPath(instanceName);

            MyFileSystem.Reset();
            MyFileSystem.Init(contentPath, userDataPath);
            MyFileSystem.InitUserSpecific((string)null);

            string debugContentPath  = MyFileSystem.ContentPath;
            string debugUserDataPath = MyFileSystem.UserDataPath;
        }
Esempio n. 8
0
        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();
        }
Esempio n. 9
0
        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());
            }
        }
Esempio n. 10
0
        //internal static readonly string AppName = "SpaceEngineersDedicated";


        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        //[STAThread]
        public static void Start <T>() where T : MyObjectBuilder_SessionSettings, new()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            SelectInstanceForm selectionForm;
            ConfigForm <T>     configForm;

            var isService   = false;
            var serviceName = "";
            var serviceData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), MyPerServerSettings.GameDSName);
            var contentPath = Path.Combine(new FileInfo(MyFileSystem.ExePath).Directory.FullName, "Content");

            do
            {
                selectionForm = new SelectInstanceForm(serviceData, MyPerServerSettings.GameDSName + ".exe");
                Application.Run(selectionForm);

                if (selectionForm.DialogResult == DialogResult.OK)
                {
                    if (selectionForm.SelectedInstance != null)
                    {
                        isService   = true;
                        serviceName = selectionForm.SelectedInstance.InstanceName;

                        MyFileSystem.Init(contentPath, Path.Combine(serviceData, serviceName));
                        MyFileSystem.InitUserSpecific(null);
                    }
                    else
                    {
                        isService   = false;
                        serviceName = "";

                        MyFileSystem.Init(contentPath, Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), MyPerServerSettings.GameDSName));
                        MyFileSystem.InitUserSpecific(null);
                    }
                }
                else
                {
                    break;
                }

                MySandboxGame.Config          = new MyConfig(MyPerServerSettings.GameNameSafe + ".cfg");
                MySandboxGame.ConfigDedicated = new MyConfigDedicated <T>(MyPerServerSettings.GameNameSafe + "-Dedicated.cfg");

                configForm = new ConfigForm <T>(isService, serviceName);
                Application.Run(configForm);
            }while (configForm.HasToExit);
        }
Esempio n. 11
0
        public void LoadInstance(string path, bool validate = true)
        {
            if (validate)
            {
                ValidateInstance(path);
            }

            MyFileSystem.Reset();
            MyFileSystem.ExePath = Path.Combine(_filesystemManager.TorchDirectory, "DedicatedServer64");
            MyFileSystem.Init("Content", path);
            //Initializes saves path. Why this isn't in Init() we may never know.
            MyFileSystem.InitUserSpecific(null);

            var configPath = Path.Combine(path, CONFIG_NAME);

            if (!File.Exists(configPath))
            {
                Log.Error($"Failed to load dedicated config at {path}");
                return;
            }

            var config = new MyConfigDedicated <MyObjectBuilder_SessionSettings>(configPath);

            config.Load(configPath);

            DedicatedConfig = new ConfigDedicatedViewModel(config);
            var worldFolders = Directory.EnumerateDirectories(Path.Combine(Torch.Config.InstancePath, "Saves"));

            foreach (var f in worldFolders)
            {
                DedicatedConfig.WorldPaths.Add(f);
            }

            if (DedicatedConfig.WorldPaths.Count == 0)
            {
                Log.Warn($"No worlds found in the current instance {path}.");
                return;
            }

            ImportWorldConfig();

            /*
             * if (string.IsNullOrEmpty(DedicatedConfig.LoadWorld))
             * {
             *  Log.Warn("No world specified, importing first available world.");
             *  SelectWorld(DedicatedConfig.WorldPaths[0], false);
             * }*/
        }
Esempio n. 12
0
        public SpaceEngineersCore()
        {
            var    contentPath  = ToolboxUpdater.GetApplicationContentPath();
            string userDataPath = SpaceEngineersConsts.BaseLocalPath.DataPath;

            MyFileSystem.ExePath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(FastResourceLock)).Location);

            MyLog.Default = MySandboxGame.Log;
            SpaceEngineersGame.SetupBasicGameInfo();
            _startup = new MyCommonProgramStartup(new string[] { });

            //var appDataPath = _startup.GetAppDataPath();
            //MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName + "SEToolbox", appDataPath);
            //MyInitializer.InitCheckSum();

            MyFileSystem.Reset();
            MyFileSystem.Init(contentPath, userDataPath);

            // This will start the Steam Service, and Steam will think SE is running.
            // TODO: we don't want to be doing this all the while SEToolbox is running,
            // perhaps a once off during load to fetch of mods then disconnect/Dispose.
            _steamService = MySteamGameService.Create(MySandboxGame.IsDedicated, AppId);
            MyServiceManager.Instance.AddService(_steamService);

            IMyUGCService serviceInstance = MySteamUgcService.Create(AppId, _steamService);

            MyServiceManager.Instance.AddService(serviceInstance);

            MyFileSystem.InitUserSpecific(_steamService.UserId.ToString()); // This sets the save file/path to load games from.
            //MyFileSystem.InitUserSpecific(null);
            //SpaceEngineersWorkshop.MySteam.Dispose();

            MySandboxGame.Config = new MyConfig("SpaceEngineers.cfg"); // TODO: Is specific to SE, not configurable to ME.
            MySandboxGame.Config.Load();

            SpaceEngineersGame.SetupPerGameSettings();

            VRage.MyVRage.Init(new ToolboxPlatform());
            VRage.MyVRage.Platform.Init();

            MySandboxGame.InitMultithreading();

            VRageRender.MyRenderProxy.Initialize(new MyNullRender());

            // We create a whole instance of MySandboxGame!
            // If this is causing an exception, then there is a missing dependency.
            MySandboxGame gameTemp = new DerivedGame(new string[] { "-skipintro" });

            // creating MySandboxGame will reset the CurrentUICulture, so I have to reapply it.
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfoByIetfLanguageTag(GlobalSettings.Default.LanguageCode);
            SpaceEngineersApi.LoadLocalization();
            MyStorageBase.UseStorageCache = false;

            // Create an empty instance of MySession for use by low level code.
            var mySession = (Sandbox.Game.World.MySession)FormatterServices.GetUninitializedObject(typeof(Sandbox.Game.World.MySession));

            // Required as the above code doesn't populate it during ctor of MySession.
            ReflectionUtil.ConstructField(mySession, "m_creativeTools");
            ReflectionUtil.ConstructField(mySession, "m_sessionComponents");
            ReflectionUtil.ConstructField(mySession, "m_sessionComponentsForUpdate");

            mySession.Settings = new MyObjectBuilder_SessionSettings {
                EnableVoxelDestruction = true
            };

            // change for the Clone() method to use XML cloning instead of Protobuf because of issues with MyObjectBuilder_CubeGrid.Clone()
            ReflectionUtil.SetFieldValue(typeof(VRage.ObjectBuilders.MyObjectBuilderSerializer), "ENABLE_PROTOBUFFERS_CLONING", false);

            // Assign the instance back to the static.
            Sandbox.Game.World.MySession.Static = mySession;

            var heightMapLoadingSystem = new MyHeightMapLoadingSystem();

            mySession.RegisterComponent(heightMapLoadingSystem, heightMapLoadingSystem.UpdateOrder, heightMapLoadingSystem.Priority);
            heightMapLoadingSystem.LoadData();

            _stockDefinitions = new SpaceEngineersResources();
            _stockDefinitions.LoadDefinitions();
            _manageDeleteVoxelList = new List <string>();
        }
Esempio n. 13
0
        // 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();
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        public void FindType()
        {
            Type ivms = typeof(VRage.Game.ModAPI.IMyVoxelMaps);

            var binPath = @"D:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin";

            var assemblyFiles = Directory.GetFiles(binPath /*GlobalSettings.Default.SEBinPath*/, "*.dll");

            _spaceEngineersAssemblies = assemblyFiles.Select(f => Path.GetFileName(f)).ToList();

            Type      baseType      = typeof(Sandbox.Definitions.MyDefinitionManager);
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.AssemblyResolve += currentDomain_AssemblyResolve;
            currentDomain.ReflectionOnlyAssemblyResolve += currentDomain_ReflectionOnlyAssemblyResolve;

            currentDomain.TypeResolve += currentDomain_TypeResolve;
            try
            {
                MyFileSystem.Reset();
                MyFileSystem.Init(@"C:\Program Files (x86)\Steam\SteamApps\common\SpaceEngineers\Content", Environment.ExpandEnvironmentVariables(@"%AppData%\SpaceEngineers"));
                MyFileSystem.InitUserSpecific((string)null);

                // #########################
                // MySandboxGame (obsfcated) has to be created in memory to be able to load Voxel Material Definitions.
                // Without the Voxel Material Definitions, you cannot use the IMyStorage to load an asteroid.
                // So, this is a pointless waste of effort to try and use the in game code.
                // #########################

                Sandbox.Definitions.MyDefinitionManager.Static.LoadData(new List <MyObjectBuilder_Checkpoint.ModItem>());
                var materials = Sandbox.Definitions.MyDefinitionManager.Static.GetVoxelMaterialDefinitions();

                //DictionaryValuesReader<string, MyVoxelMaterialDefinition>;
                //var dict = materials as Dictionary<string, MyVoxelMaterialDefinition>;


                //var matx = Sandbox.Definitions.MyDefinitionManager.Static.m_definitions.m_voxelMaterialsByName;
                var xz = Sandbox.Definitions.MyDefinitionManager.Static.GetDefaultVoxelMaterialDefinition();

                //var tt = ass2.GetType("Sandbox.ModAPI.IMyVoxelMaps");
                //var ass = System.Reflection.Assembly.ReflectionOnlyLoad("Sandbox.Game");
                var ass = baseType.Assembly;

                //               ass.GetType();
                //var modules = ass.GetModules(false);
                //var types = modules[0].GetTypes();
                var types = ass.GetTypes();

                var myVoxelMapsType = types.Where(p => ivms.IsAssignableFrom(p)).First();
                var myVoxelMaps     = Activator.CreateInstance(myVoxelMapsType) as VRage.Game.ModAPI.IMyVoxelMaps;

                //5BCAC68007431E61367F5B2CF24E2D6F.5217D2CFAB7CCD6299A3F53DAEE1DEB1
                //public static 6922E99EC72C10627AA239B8167BF7DC A109856086C45CF523B23AFCDDB82F43(byte[] 06D95B424FC4150954FF019440A547AE)
                var filename = @"C:\Program Files (x86)\Steam\SteamApps\common\SpaceEngineers\Content\VoxelMaps\Arabian_Border_7.vx2";

                byte[] buffer  = File.ReadAllBytes(filename);
                var    storage = myVoxelMaps.CreateStorage(buffer);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 16
0
        public bool LoadGame(string seBinPath, string userDataPath, string savePath)
        {
            if (!Directory.Exists(seBinPath))
            {
                return(false);
            }

            if (!Directory.Exists(savePath))
            {
                return(false);
            }

            if (!savePath.StartsWith(userDataPath, StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            string contentPath = Path.GetFullPath(Path.Combine(seBinPath, @"..\Content"));

            MyFileSystem.Reset();
            MyFileSystem.Init(contentPath, userDataPath);

            MyLog.Default        = MySandboxGame.Log;
            MySandboxGame.Config = new MyConfig("SpaceEngineers.cfg"); // TODO: Is specific to SE, not configurable to ME.
            MySandboxGame.Config.Load();

            MyFileSystem.InitUserSpecific(null);

            SpaceEngineersGame.SetupPerGameSettings();

            VRageRender.MyRenderProxy.Initialize(new MyNullRender());
            // We create a whole instance of MySandboxGame!
            // If this is causing an exception, then there is a missing dependency.
            MySandboxGame gameTemp = new MySandboxGame(null);

            #region Game Localization

            // creating MySandboxGame will reset the CurrentUICulture, so I have to reapply it.
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfoByIetfLanguageTag(GlobalSettings.Default.LanguageCode);

            var culture          = System.Threading.Thread.CurrentThread.CurrentUICulture;
            var languageTag      = culture.IetfLanguageTag;
            var localizationPath = Path.Combine(contentPath, @"Data\Localization");
            var codes            = languageTag.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
            var maincode         = codes.Length > 0 ? codes[0] : null;
            var subcode          = codes.Length > 1 ? codes[1] : null;
            MyTexts.Clear();
            MyTexts.LoadTexts(localizationPath, maincode, subcode);

            #endregion

            MyStorageBase.UseStorageCache = false;

            #region MySession creation

            // Replace the private constructor on MySession, so we can create it without getting involed with Havok and other depdancies.
            var keenStart = typeof(Sandbox.Game.World.MySession).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(MySyncLayer), typeof(bool) }, null);
            var ourStart  = typeof(EconomyConfigurationEditor.Interop.MySession).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(MySyncLayer), typeof(bool) }, null);
            ReflectionUtil.ReplaceMethod(ourStart, keenStart);

            // Create an empty instance of MySession for use by low level code.
            Sandbox.Game.World.MySession mySession = ReflectionUtil.ConstructPrivateClass <Sandbox.Game.World.MySession>(new Type[0], new object[0]);
            ReflectionUtil.ConstructField(mySession, "m_sessionComponents"); // Required as the above code doesn't populate it during ctor of MySession.
            mySession.Settings = new MyObjectBuilder_SessionSettings {
                EnableVoxelDestruction = true
            };

            // Assign the instance back to the static.
            Sandbox.Game.World.MySession.Static = mySession;

            Sandbox.Game.GameSystems.MyHeightMapLoadingSystem.Static = new MyHeightMapLoadingSystem();
            Sandbox.Game.GameSystems.MyHeightMapLoadingSystem.Static.LoadData();

            #endregion

            #region Load Sandbox

            var filename = Path.Combine(savePath, SpaceEngineersConsts.SandBoxCheckpointFilename);

            MyObjectBuilder_Checkpoint checkpoint;
            string errorInformation;
            bool   compressedCheckpointFormat;
            bool   snapshot = false;
            bool   retVal   = SpaceEngineersApi.TryReadSpaceEngineersFile <MyObjectBuilder_Checkpoint>(filename, out checkpoint, out compressedCheckpointFormat, out errorInformation, snapshot);

            if (!retVal)
            {
                return(false);
            }

            #endregion

            MyDefinitionManager.Static.PrepareBaseDefinitions();
            MyDefinitionManager.Static.LoadData(checkpoint.Mods);
            var MaterialIndex = new Dictionary <string, byte>();

            return(true);
        }
Esempio n. 17
0
        public SpaceEngineersCore()
        {
            var    contentPath  = ToolboxUpdater.GetApplicationContentPath();
            string userDataPath = SpaceEngineersConsts.BaseLocalPath.DataPath;

            MyFileSystem.Reset();
            MyFileSystem.Init(contentPath, userDataPath);

            MyLog.Default        = MySandboxGame.Log;
            MySandboxGame.Config = new MyConfig("SpaceEngineers.cfg"); // TODO: Is specific to SE, not configurable to ME.
            MySandboxGame.Config.Load();

            MyFileSystem.InitUserSpecific(null);

            MyFakes.ENABLE_INFINARIO = false;

            SpaceEngineersGame.SetupPerGameSettings();

            VRageRender.MyRenderProxy.Initialize(new MyNullRender());
            // We create a whole instance of MySandboxGame!
            MySandboxGame gameTemp = new MySandboxGame(null);

            // creating MySandboxGame will reset the CurrentUICulture, so I have to reapply it.
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfoByIetfLanguageTag(GlobalSettings.Default.LanguageCode);
            SpaceEngineersApi.LoadLocalization();
            MyStorageBase.UseStorageCache = false;

            try
            {
                // Replace the private constructor on MySession, so we can create it without getting involed with Havok and other depdancies.
                var keenStart = typeof(Sandbox.Game.World.MySession).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(MySyncLayer), typeof(bool) }, null);
                var ourStart  = typeof(SEToolbox.Interop.MySession).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(MySyncLayer), typeof(bool) }, null);
                ReflectionUtil.ReplaceMethod(ourStart, keenStart);


                // Create an empty instance of MySession for use by low level code.
                ConstructorInfo constructorInfo = typeof(Sandbox.Game.World.MySession).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[0], null);
                object          mySession       = constructorInfo.Invoke(new object[0]);

                // Assign the instance back to the static.
                Sandbox.Game.World.MySession.Static          = (Sandbox.Game.World.MySession)mySession;
                Sandbox.Game.World.MySession.Static.Settings = new MyObjectBuilder_SessionSettings {
                    EnableVoxelDestruction = true
                };
            }
            catch (Exception ex)
            {
                Debugger.Break();
            }

            try
            {
                Sandbox.Game.GameSystems.MyHeightMapLoadingSystem.Static = new MyHeightMapLoadingSystem();
                Sandbox.Game.GameSystems.MyHeightMapLoadingSystem.Static.LoadData();
            }
            catch (Exception ex)
            {
                Debugger.Break();
            }

            _stockDefinitions = new SpaceEngineersResources();
            _stockDefinitions.LoadDefinitions();
            _manageDeleteVoxelList = new List <string>();
        }
Esempio n. 18
0
        static void RunInternal(string[] args)
        {
            using (MySteamService steamService = new MySteamService(MySandboxGame.IsDedicated, AppId))
            {
                IMyRender renderer = null;

                SpaceEngineersGame.SetupPerGameSettings();

                if (MySandboxGame.IsDedicated)
                {
                    renderer = new MyNullRender();
                }
                else if (MyFakes.ENABLE_DX11_RENDERER)
                {
                    var rendererId = MySandboxGame.Config.GraphicsRenderer;
                    if (rendererId == MySandboxGame.DirectX11RendererKey)
                    {
                        renderer = new MyDX11Render();
                        if (!renderer.IsSupported)
                        {
                            MySandboxGame.Log.WriteLine("DirectX 11 renderer not supported. Reverting to DirectX 9.");
                            renderer = null;
                        }
                    }

                    if (renderer == null)
                    {
                        renderer   = new MyDX9Render();
                        rendererId = MySandboxGame.DirectX9RendererKey;
                    }

                    MySandboxGame.Config.GraphicsRenderer = rendererId;
                }
                else
                {
                    renderer = new MyDX9Render();
                }

                MyFakes.ENABLE_PLANETS &= MySandboxGame.Config.GraphicsRenderer != MySandboxGame.DirectX9RendererKey;

                VRageRender.MyRenderProxy.Initialize(renderer);

                VRageRender.MyRenderProxy.IS_OFFICIAL = MyFinalBuildConstants.IS_OFFICIAL;
                VRageRender.MyRenderProxy.GetRenderProfiler().SetAutocommit(false);
                VRageRender.MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint");
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyProgram.Init");
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MySteam.Init()");

                if (!MySandboxGame.IsDedicated)
                {
                    if (steamService.IsActive)
                    {
                        steamService.SetNotificationPosition(MySteamService.NotificationPosition.TopLeft);

                        MySandboxGame.Log.WriteLineAndConsole("Steam.IsActive: " + steamService.IsActive);
                        MySandboxGame.Log.WriteLineAndConsole("Steam.IsOnline: " + steamService.IsOnline);
                        MySandboxGame.Log.WriteLineAndConsole("Steam.OwnsGame: " + steamService.OwnsGame);
                        MySandboxGame.Log.WriteLineAndConsole("Steam.UserId: " + steamService.UserId);
                        MySandboxGame.Log.WriteLineAndConsole("Steam.UserName: "******"[n/a]");
                        MySandboxGame.Log.WriteLineAndConsole("Steam.Branch: " + steamService.BranchName ?? "[n/a]");
                        MySandboxGame.Log.WriteLineAndConsole("Build date: " + MySandboxGame.BuildDateTime.ToString("yyyy-MM-dd hh:mm", CultureInfo.InvariantCulture));
                        MySandboxGame.Log.WriteLineAndConsole("Build version: " + MySandboxGame.BuildVersion.ToString());
                    }
                    else if (MyFinalBuildConstants.IS_OFFICIAL) //We dont need Steam only in VS
                    {
                        if (!(steamService.IsActive && steamService.OwnsGame))
                        {
                            if (MyFakes.ENABLE_RUN_WITHOUT_STEAM == false)
                            {
                                MessageBoxWrapper("Steam is not running!", "Please run this game from Steam." + Environment.NewLine + "(restart Steam if already running)");
                                return;
                            }
                        }
                    }
                    else
                    {
                        if (!(steamService.IsActive && steamService.OwnsGame))
                        {
                            if (MyFakes.ENABLE_RUN_WITHOUT_STEAM == false)
                            {
                                MessageBoxWrapper("Steam is not running!", "Game might be unstable when run without Steam!");
                            }
                        }
                    }
                }

                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

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

                VRageGameServices services = new VRageGameServices(steamService);

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

                using (MySandboxGame game = new MySandboxGame(services, args))
                {
                    VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                    VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                    game.Run(disposeSplashScreen: DisposeSplashScreen);
                }
            }
        }
Esempio n. 19
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();
        }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
        // 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);
            }
        }