Example #1
0
 public void UpdateClientEnforcements(CoreSettings.ServerSettings data)
 {
     Core.Enforcement   = data;
     Core.ClientWaiting = false;
     GenerateBlockDmgMap();
     GenerateAmmoDmgMap();
 }
Example #2
0
        private void RebuildConfig(CoreSettings.ServerSettings oldSettings)
        {
            var oldAmmoModifers  = oldSettings.AmmoModifers;
            var oldBlockModifers = oldSettings.BlockModifers;
            var oldShipSizes     = oldSettings.ShipSizes;
            var oldSleep         = oldSettings.ServerSleepSupport;
            var oldOptimize      = oldSettings.ServerOptimizations;
            var oldFocusDist     = oldSettings.MinHudFocusDistance;
            var oldDisableAi     = oldSettings.DisableAi;

            Core.Enforcement = new CoreSettings.ServerSettings {
                Version = Session.ServerCfgVersion
            };

            if (oldAmmoModifers != null)
            {
                Core.Enforcement.AmmoModifers = oldAmmoModifers;
            }

            if (oldBlockModifers != null)
            {
                Core.Enforcement.BlockModifers = oldBlockModifers;
            }

            if (oldShipSizes != null)
            {
                Core.Enforcement.ShipSizes = oldShipSizes;
            }

            Core.Enforcement.ServerSleepSupport = oldSleep;

            Core.Enforcement.ServerOptimizations = oldOptimize;
            Core.Enforcement.MinHudFocusDistance = oldFocusDist;
            Core.Enforcement.DisableAi           = oldDisableAi;
        }
Example #3
0
        public void InitSettings()
        {
            if (MyAPIGateway.Utilities.FileExistsInGlobalStorage(Session.ClientCfgName))
            {
                var writer  = MyAPIGateway.Utilities.ReadFileInGlobalStorage(Session.ClientCfgName);
                var xmlData = MyAPIGateway.Utilities.SerializeFromXML <CoreSettings.ClientSettings>(writer.ReadToEnd());
                writer.Dispose();

                if (xmlData?.Version == Session.ClientCfgVersion)
                {
                    Core.ClientConfig = xmlData;
                    Core.Session.UiInput.ActionKey       = Core.Session.KeyMap[xmlData.ActionKey];
                    Core.Session.UiInput.MouseButtonMenu = Core.Session.MouseMap[xmlData.MenuButton];
                }
                else
                {
                    WriteNewClientCfg();
                }
            }
            else
            {
                WriteNewClientCfg();
            }

            if (Core.Session.IsServer)
            {
                if (MyAPIGateway.Utilities.FileExistsInWorldStorage(Session.ServerCfgName, typeof(CoreSettings.ServerSettings)))
                {
                    var writer = MyAPIGateway.Utilities.ReadFileInWorldStorage(Session.ServerCfgName, typeof(CoreSettings.ServerSettings));

                    CoreSettings.ServerSettings xmlData = null;

                    try { xmlData = MyAPIGateway.Utilities.SerializeFromXML <CoreSettings.ServerSettings>(writer.ReadToEnd()); }
                    catch (Exception e) { writer.Dispose(); }

                    writer.Dispose();

                    if (xmlData?.Version == Session.ServerCfgVersion)
                    {
                        Core.Enforcement = xmlData;
                        CorruptionCheck(true);
                    }
                    else
                    {
                        GenerateConfig(xmlData);
                    }
                }
                else
                {
                    GenerateConfig();
                }


                GenerateBlockDmgMap();
                GenerateAmmoDmgMap();
            }
        }
Example #4
0
        private void GenerateConfig(CoreSettings.ServerSettings oldSettings = null)
        {
            if (oldSettings != null)
            {
                RebuildConfig(oldSettings);
            }
            else
            {
                Core.Enforcement = new CoreSettings.ServerSettings {
                    Version = Session.ServerCfgVersion
                }
            };

            CorruptionCheck();
            SaveServerCfg();
        }