Exemple #1
0
        /// <summary> Returns whether the given rank can modify the given block. </summary>
        public static bool UsableBy(Player p, byte block)
        {
            BlockPerms      b    = List[block];
            LevelPermission perm = p.Rank;

            return((perm >= b.MinRank || b.Allowed.Contains(perm)) && !b.Disallowed.Contains(perm));
        }
Exemple #2
0
        static void SetDefaultPerms()
        {
            for (int i = 0; i < Block.Count; i++)
            {
                BlockPerms perms = new BlockPerms();
                perms.BlockID = (byte)i;
                BlockProps props = Block.Props[i];

                if (i == Block.Invalid)
                {
                    perms.MinRank = LevelPermission.Admin;
                }
                else if (props.OPBlock)
                {
                    perms.MinRank = LevelPermission.Operator;
                }
                else if (props.IsDoor || props.IsTDoor || props.oDoorIndex != Block.Invalid)
                {
                    perms.MinRank = LevelPermission.Builder;
                }
                else if (props.IsPortal || props.IsMessageBlock)
                {
                    perms.MinRank = LevelPermission.AdvBuilder;
                }
                else
                {
                    perms.MinRank = DefaultPerm(i);
                }
                List[i] = perms;
            }
        }
Exemple #3
0
        /// <summary> Creates a copy of this instance. </summary>
        public BlockPerms Copy()
        {
            BlockPerms perms = new BlockPerms();

            perms.BlockID    = BlockID;
            perms.MinRank    = MinRank;
            perms.Allowed    = new List <LevelPermission>(Allowed);
            perms.Disallowed = new List <LevelPermission>(Disallowed);
            return(perms);
        }
Exemple #4
0
        /// <summary> Sets the permissions for the given block. </summary>
        public static void Set(BlockID b, LevelPermission min,
                               List <LevelPermission> allowed, List <LevelPermission> disallowed)
        {
            BlockPerms perms = List[b];

            if (perms == null)
            {
                List[b] = new BlockPerms(b, min, allowed, disallowed);
            }
            else
            {
                perms.Init(min, allowed, disallowed);
            }
        }
Exemple #5
0
        static void ProcessLines(string[] lines)
        {
            string[] args = new string[4];
            foreach (string line in lines)
            {
                if (line.Length == 0 || line[0] == '#')
                {
                    continue;
                }
                // Format is - Name/ID : Lowest : Disallow : Allow
                line.Replace(" ", "").FixedSplit(args, ':');

                byte block;
                if (!byte.TryParse(args[0], out block))
                {
                    block = Block.Byte(args[0]);
                }
                if (block == Block.Invalid)
                {
                    continue;
                }

                BlockPerms perms = new BlockPerms();
                perms.BlockID = block;
                try {
                    perms.MinRank = (LevelPermission)int.Parse(args[1]);
                    string disallowRaw = args[2], allowRaw = args[3];

                    perms.Allowed    = CommandPerms.ExpandPerms(allowRaw);
                    perms.Disallowed = CommandPerms.ExpandPerms(disallowRaw);
                } catch {
                    Logger.Log(LogType.Warning, "Hit an error on the block " + line);
                    continue;
                }
                List[perms.BlockID] = perms;
            }
        }
Exemple #6
0
        public BlockPerms Copy()
        {
            BlockPerms copy = new BlockPerms(ID, 0, null, null);

            CopyTo(copy); return(copy);
        }