Exemplo n.º 1
0
        public bool LoadConfig()
        {
            XMLConfig conf = new XMLConfig("sdtmlib");

            if (!conf.Load())
            {
                Log.Out("Could not Load SDTMLib config");
                return(false);
            }

            int    tryTickRate = 0;
            string sTickRate   = conf.Get("tickrate");

            if (sTickRate != "")
            {
                int.TryParse(sTickRate, out tryTickRate);
                if (tryTickRate > 0)
                {
                    tickRate = tryTickRate;
                }
                else
                {
                    SaveConfig();
                }
            }
            else
            {
                SaveConfig();
            }

            ChatCommandsEnabled   = conf.Get("chatcommandsenabled").ToLower() == "true" ? true : false;
            API.OverrideGamePrefs = conf.Get("overridegameprefs").ToLower() == "true" ? true : false;
            API.WebConsoleEnabled = conf.Get("webconsole_enabled").ToLower() == "true" ? true : false;
            API.WebConsolePort    = conf.Get("webconsole_port");

            if (WebConsolePort == "" || WebConsolePort == null)
            {
                WebConsolePort = GamePrefs.GetInt(EnumGamePrefs.ControlPanelPort).ToString();
            }

            if (API.OverrideGamePrefs)
            {
                string confWorldType = conf.Get("WorldType");
                string confWorldName = conf.Get("WorldName");

                if (confWorldType != "")
                {
                    SetConfig("worldtype", confWorldType, false, true);
                }

                if (confWorldName != "")
                {
                    SetConfig("worldname", confWorldName, false, true);
                }
            }


            return(true);
        }
Exemplo n.º 2
0
        public bool SaveConfig()
        {
            XMLConfig conf = new XMLConfig("sdtmlib");

            conf.Set("tickrate", tickRate.ToString());
            //conf.Set("experm_enabled", );
            conf.Set("overridegameprefs", OverrideGamePrefs.ToString());
            conf.Set("webconsole_port", WebConsolePort.ToString());
            conf.Set("webconsole_enabled", WebConsoleEnabled.ToString());
            //conf.Set ("AirdropFreq", WorldType);
            conf.Set("WorldType", WorldType);
            conf.Set("WorldName", WorldName);
            conf.Set("chatcommandsenabled", ChatCommandsEnabled?"true":"false");
            return(conf.Save());
        }