Beispiel #1
0
        internal static void ApplyConfig()
        {
            Logger.SplittingType = (LogSplittingType)Enum.Parse(typeof(LogSplittingType), Settings[ConfigKey.LogMode], true);
            Logger.MarkLogStart();

            Player.RelayAllUpdates = GetBool(ConfigKey.RelayAllBlockUpdates);
            if (GetBool(ConfigKey.NoPartialPositionUpdates))
            {
                Session.FullPositionUpdateInterval = 0;
            }
            else
            {
                Session.FullPositionUpdateInterval = Session.FullPositionUpdateIntervalDefault;
            }

            // chat colors
            Color.Sys          = Color.Parse(Settings[ConfigKey.SystemMessageColor]);
            Color.Say          = Color.Parse(Settings[ConfigKey.SayColor]);
            Color.Help         = Color.Parse(Settings[ConfigKey.HelpColor]);
            Color.Announcement = Color.Parse(Settings[ConfigKey.AnnouncementColor]);
            Color.PM           = Color.Parse(Settings[ConfigKey.PrivateMessageColor]);
            Color.IRC          = Color.Parse(Settings[ConfigKey.IRCMessageColor]);
            Color.Me           = Color.Parse(Settings[ConfigKey.MeColor]);
            Color.Warning      = Color.Parse(Settings[ConfigKey.WarningColor]);

            // default class
            if (!ConfigKey.DefaultRank.IsBlank())
            {
                if (RankManager.ParseRank(Settings[ConfigKey.DefaultRank]) != null)
                {
                    RankManager.DefaultRank = RankManager.ParseRank(Settings[ConfigKey.DefaultRank]);
                }
                else
                {
                    RankManager.DefaultRank = RankManager.LowestRank;
                    Logger.Log("Config.ApplyConfig: Could not parse DefaultRank; assuming that the lowest rank ({0}) is the default.",
                               LogType.Warning, RankManager.DefaultRank.Name);
                }
            }
            else
            {
                RankManager.DefaultRank = RankManager.LowestRank;
            }

            // antispam
            Player.SpamChatCount    = GetInt(ConfigKey.AntispamMessageCount);
            Player.SpamChatTimer    = GetInt(ConfigKey.AntispamInterval);
            Player.AutoMuteDuration = TimeSpan.FromSeconds(GetInt(ConfigKey.AntispamMuteDuration));

            // scheduler settings
            Server.MaxUploadSpeed   = GetInt(ConfigKey.UploadBandwidth);
            Server.PacketsPerSecond = GetInt(ConfigKey.BlockUpdateThrottling);
            Server.TicksPerSecond   = 1000 / (float)GetInt(ConfigKey.TickInterval);

            // rank to patrol
            World.RankToPatrol = RankManager.ParseRank(ConfigKey.PatrolledRank.GetString());

            // IRC delay
            IRC.SendDelay = GetInt(ConfigKey.IRCDelay);

            BuildingCommands.MaxUndoCount = GetInt(ConfigKey.MaxUndo);

            if (!Paths.IgnoreMapPathConfigKey && GetString(ConfigKey.MapPath).Length > 0)
            {
                if (Paths.TestDirectory("MapPath", GetString(ConfigKey.MapPath), true))
                {
                    Paths.MapPath = Path.GetFullPath(GetString(ConfigKey.MapPath));
                    Logger.Log("Maps are stored at: {0}", LogType.SystemActivity, Paths.MapPath);
                }
            }

            AutoRankManager.CheckAutoRankSetting();
        }
Beispiel #2
0
        void Init(object sender, EventArgs args)
        {
            Server.InitLibrary(Environment.GetCommandLineArgs());
            Config.Load(false, false);

            rankList = RankManager.Ranks.Select(r => r.Prefix + r.Name).ToArray();
            cFromRank.Items.AddRange(rankList);
            cToRank.Items.AddRange(rankList);

            using (LogRecorder recorder = new LogRecorder()) {
                AutoRankManager.Init();
                if (recorder.HasMessages)
                {
                    MessageBox.Show(recorder.MessageString, "Loading autorank.xml...");
                }
            }

            if (AutoRankManager.HasCriteria)
            {
                foreach (Criterion crit in AutoRankManager.Criteria)
                {
                    ActionNode newNode = new ActionNode {
                        Action   = ActionType.Automatic,
                        FromRank = crit.FromRank,
                        ToRank   = crit.ToRank
                    };

                    if (crit.Condition is ConditionAND)
                    {
                        newNode.Op = GroupNodeType.AND;
                    }
                    else if (crit.Condition is ConditionOR)
                    {
                        newNode.Op = GroupNodeType.OR;
                    }
                    else if (crit.Condition is ConditionNAND)
                    {
                        newNode.Op = GroupNodeType.NAND;
                    }
                    else if (crit.Condition is ConditionNOR)
                    {
                        newNode.Op = GroupNodeType.NOR;
                    }
                    else
                    {
                        throw new FormatException();
                    }

                    foreach (Condition subCondition in crit.Condition.Conditions)
                    {
                        ImportCondition(newNode, subCondition);
                    }
                    treeData.Nodes.Add(newNode);
                    newNode.UpdateLabel();
                }
            }
            else
            {
                treeData.Nodes.Add(new ActionNode());
            }
            treeData.ExpandAll();
            treeData.SelectedNode = treeData.Nodes[0];
        }