Esempio n. 1
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);
        }
Esempio n. 2
0
 public static void SaveSettings(Level lvl)
 {
     if (lvl.IsMuseum)
     {
         return;               // museums do not save properties
     }
     lock (lvl.savePropsLock) {
         string propsPath = LevelInfo.PropertiesPath(lvl.MapName);
         LevelConfig.Save(propsPath, lvl.Config, lvl.name);
     }
 }
Esempio n. 3
0
        public static void CopyLevel(string src, string dst)
        {
            File.Copy(LevelInfo.LevelPath(src), LevelInfo.LevelPath(dst));
            if (File.Exists(LevelInfo.PropertiesPath(src)))
            {
                File.Copy(LevelInfo.PropertiesPath(src),
                          LevelInfo.PropertiesPath(dst));
            }

            if (File.Exists("blockdefs/lvl_" + src + ".json"))
            {
                File.Copy("blockdefs/lvl_" + src + ".json",
                          "blockdefs/lvl_" + dst + ".json");
            }
            CopyDatabaseTables(src, dst);
        }
Esempio n. 4
0
        public static void LoadMetadata(Level lvl)
        {
            try {
                string propsPath    = LevelInfo.PropertiesPath(lvl.MapName);
                bool   propsExisted = LevelConfig.Load(propsPath, lvl.Config);

                if (propsExisted)
                {
                    lvl.setPhysics(lvl.Config.Physics);
                }
                else
                {
                    Logger.Log(LogType.ConsoleMessage, ".properties file for level {0} was not found.", lvl.MapName);
                }

                // Backwards compatibility for older levels which had .env files.
                string envPath = "levels/level properties/" + lvl.MapName + ".env";
                LevelConfig.Load(envPath, lvl.Config);
            } catch (Exception e) {
                Logger.LogError(e);
            }
            lvl.BlockDB.Cache.Enabled = lvl.Config.UseBlockDB;

            BlockDefinition[] defs = BlockDefinition.Load(false, lvl);
            for (int i = 0; i < defs.Length; i++)
            {
                if (defs[i] == null)
                {
                    continue;
                }
                lvl.UpdateCustomBlock((byte)i, defs[i]);
            }

            lvl.UpdateBlockProps();
            lvl.UpdateBlockHandlers();
        }
Esempio n. 5
0
 public static void SaveSettings(Level lvl)
 {
     lock (lvl.savePropsLock)
         LvlProperties.Save(lvl, LevelInfo.PropertiesPath(lvl.name));
 }