fCraft.Config.ApplyConfig C# (CSharp) Method

ApplyConfig() private method

private ApplyConfig ( ) : void
return void
        internal void ApplyConfig() {
            // TODO: logging settings
            //Logger.Threshold = (LogLevel)Enum.Parse( typeof( LogLevel ), settings["LogThreshold"] );

            // chat colors
            Color.Sys = Color.Parse( settings["SystemMessageColor"] );
            Color.Say = Color.Parse( settings["SayColor"] );
            Color.Help = Color.Parse( settings["HelpColor"] );

            // default class
            if( classes.ParseClass( settings["DefaultClass"] ) != null ) {
                classes.defaultClass = classes.ParseClass( settings["DefaultClass"] );
            } else {
                classes.defaultClass = classes.lowestClass;
                Log( "Config.ParseConfig: No default player class defined; assuming that the lowest rank ({0}) is the default.",
                            LogType.Warning, classes.defaultClass.name );
            }

            Player.spamChatCount = GetInt( "AntispamMessageCount" );
            Player.spamChatTimer = GetInt( "AntispamInterval" );
            Player.spamBlockCount = GetInt( "AntigriefBlockCount" );
            Player.spamBlockTimer = GetInt( "AntigriefInterval" );
            Player.muteDuration = TimeSpan.FromSeconds( GetInt( "AntispamMuteDuration" ) );

            Server.maxUploadSpeed = GetInt("UploadBandwidth");
            Server.maxSessionPacketsPerTick = GetInt("BlockUpdateThrottling" );
            world.ticksPerSecond = 1000 / GetInt( "TickInterval" );
        }

Usage Example

Example #1
0
        public bool Init()
        {
            log.Init("fCraft.log");
            if (!config.Load("config.xml"))
            {
                return(false);
            }
            config.ApplyConfig();
            config.Save("config.xml");

            // allocate player list
            players = new Player[config.GetInt("MaxPlayers") + 1];
            tasks.Init();

            // load player DB
            db.Load();
            bans.Load();

            return(true);
        }