Example #1
0
        void LoadMainLevel()
        {
            try {
                if (LevelInfo.ExistsOffline(level))
                {
                    mainLevel        = Level.Load(level);
                    mainLevel.unload = false;
                    if (mainLevel == null)
                    {
                        if (File.Exists(LevelInfo.LevelPath(level) + ".backup"))
                        {
                            Log("Attempting to load backup of " + level + ".");
                            File.Copy(LevelInfo.LevelPath(level) + ".backup", LevelInfo.LevelPath(level), true);
                            mainLevel = Level.Load(level);
                            if (mainLevel == null)
                            {
                                Log("BACKUP FAILED!");
                                Console.ReadLine(); return;
                            }
                        }
                        else
                        {
                            Log("mainlevel not found");
                            mainLevel = new Level(level, 128, 64, 128, "flat");
                            mainLevel.Save();
                            Level.CreateLeveldb(level);
                        }
                    }
                }
                else
                {
                    Log("mainlevel not found");
                    mainLevel = new Level(level, 128, 64, 128, "flat");
                    mainLevel.Save();
                    Level.CreateLeveldb(level);
                }
                LevelInfo.Loaded.Add(mainLevel);

                // fenderrock - Make sure the level does have a physics thread
                if (mainLevel.physThread == null)
                {
                    mainLevel.StartPhysics();
                }
            } catch (Exception e) {
                ErrorLog(e);
            }
        }
Example #2
0
        static bool GotoMap(Player p, string name, bool ignorePerms)
        {
            Level lvl = LevelInfo.FindExact(name);

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

            if (Server.AutoLoad)
            {
                // First try exactly matching unloaded levels
                if (LevelInfo.ExistsOffline(name))
                {
                    return(LoadOfflineLevel(p, name, ignorePerms));
                }
                lvl = LevelInfo.Find(name);
                if (lvl != null)
                {
                    return(GotoLevel(p, lvl, ignorePerms));
                }

                string matches = LevelInfo.FindMapMatches(p, name);
                if (matches == null)
                {
                    return(false);
                }
                return(LoadOfflineLevel(p, matches, ignorePerms));
            }
            else
            {
                lvl = LevelInfo.Find(name);
                if (lvl == null)
                {
                    Player.Message(p, "There is no level \"{0}\" loaded. Did you mean..", name);
                    Command.all.Find("search").Use(p, "levels " + name);
                    return(false);
                }
                return(GotoLevel(p, lvl, ignorePerms));
            }
        }