Example #1
0
        static bool LoadOfflineLevel(Player p, string map)
        {
            string      propsPath = LevelInfo.PropsPath(map);
            LevelConfig cfg       = new LevelConfig();

            cfg.Load(propsPath);

            if (!cfg.LoadOnGoto)
            {
                p.Message("Level \"{0}\" cannot be loaded using %T/Goto.", map);
                return(false);
            }

            AccessController visitAccess = new LevelAccessController(cfg, map, true);
            bool             skip        = p.summonedMap != null && p.summonedMap.CaselessEq(map);
            LevelPermission  plRank      = skip ? LevelPermission.Nobody : p.Rank;

            if (!visitAccess.CheckDetailed(p, plRank))
            {
                return(false);
            }

            LevelActions.Load(p, map, false);
            Level lvl = LevelInfo.FindExact(map);

            if (lvl != null)
            {
                return(GotoLevel(p, lvl));
            }

            p.Message("Level \"{0}\" failed to be auto-loaded.", map);
            return(false);
        }
Example #2
0
        static bool LoadOfflineLevel(Player p, string name)
        {
            string      propsPath = LevelInfo.PropertiesPath(name);
            LevelConfig cfg       = new LevelConfig();

            LevelConfig.Load(propsPath, cfg);

            if (!cfg.LoadOnGoto)
            {
                Player.Message(p, "Level \"{0}\" cannot be loaded using %T/Goto.", name);
                return(false);
            }

            LevelAccessController visitAccess = new LevelAccessController(cfg, name, true);
            bool ignorePerms = p.summonedMap != null && p.summonedMap.CaselessEq(name);

            if (!visitAccess.CheckDetailed(p, ignorePerms))
            {
                return(false);
            }

            CmdLoad.LoadLevel(p, name, true);
            Level lvl = LevelInfo.FindExact(name);

            if (lvl != null)
            {
                return(GotoLevel(p, lvl));
            }

            Player.Message(p, "Level \"{0}\" failed to be auto-loaded.", name);
            return(false);
        }
Example #3
0
        public static bool Check(Player p, LevelPermission plRank, string map, string action, out LevelConfig cfg)
        {
            Level lvl; cfg = GetConfig(map, out lvl);

            if (p.IsConsole)
            {
                return(true);
            }
            if (lvl != null)
            {
                return(Check(p, plRank, lvl, action));
            }

            AccessController visit = new LevelAccessController(cfg, map, true);
            AccessController build = new LevelAccessController(cfg, map, false);

            if (!visit.CheckDetailed(p, plRank) || !build.CheckDetailed(p, plRank))
            {
                p.Message("Hence, you cannot {0}.", action); return(false);
            }
            return(true);
        }