Пример #1
0
        private void btnLoad_Click(object sender, EventArgs e) {
            var result = openMap.ShowDialog();

            if (result == DialogResult.OK) {
                var timer = new Stopwatch();
                timer.Start();

                _map = new Classicworld(openMap.FileName);
                _map.Load();

                timer.Stop();
                lblTime.Text = "Time: " + timer.Elapsed.TotalSeconds;
                _loaded = true;
            }
        }
Пример #2
0
        /// <summary>
        /// Loads a new file into this map object.
        /// </summary>
        /// <param name="filename">The file to load into this map.</param>
        public void Load(string filename)
        {
            if (!File.Exists(filename)) {
                if (File.Exists(filename + "u"))
                    File.Move(filename + "u", filename);
                else
                    return;
            }

            Path = filename;
            CWMap = new Classicworld(filename);
            HCSettings = new HypercubeMetadata();
            CWMap.MetadataParsers.Add("Hypercube", HCSettings);
            CWMap.Load();

            _physicsBitmask = new byte[(CWMap.BlockData.Length / 8) + 1];

            HCSettings = (HypercubeMetadata)CWMap.MetadataParsers["Hypercube"];

            if (HCSettings.BuildPerms == null) {
                Buildperms.Add("player.build", ServerCore.Permholder.GetPermission("player.build"));
            } else
                Buildperms = PermissionContainer.SplitPermissions(HCSettings.BuildPerms);

            if (HCSettings.ShowPerms == null) {
                Showperms.Add("map.joinmap", ServerCore.Permholder.GetPermission("map.joinmap"));
            } else
                Showperms = PermissionContainer.SplitPermissions(HCSettings.ShowPerms);

            if (HCSettings.JoinPerms == null) {
                Joinperms.Add("map.joinmap", ServerCore.Permholder.GetPermission("map.joinmap"));

                HCSettings.Building = true;
                HCSettings.Physics = true;
                HCSettings.History = true;
            } else
                Joinperms = PermissionContainer.SplitPermissions(HCSettings.JoinPerms);

            if (HCSettings.SaveInterval == 0)
                HCSettings.SaveInterval = 10;

            CPESettings = (CPEMetadata)CWMap.MetadataParsers["CPE"];

            if (CPESettings.CustomBlocksFallback == null) {
                CPESettings.CustomBlocksLevel = CPE.CustomBlocksSupportLevel;
                CPESettings.CustomBlocksVersion = CPE.CustomBlocksVersion;
                CPESettings.CustomBlocksFallback = new byte[256];

                for (var i = 50; i < 66; i++)
                    CPESettings.CustomBlocksFallback[i] = (byte)ServerCore.Blockholder.GetBlock(i).CPEReplace;

                CWMap.MetadataParsers["CPE"] = CPESettings;
            }

            if (CPESettings.EnvMapAppearanceVersion != CPE.EnvMapAppearanceVersion) {
                CPESettings.TextureUrl = "";
                CPESettings.EdgeBlock = 8;
                CPESettings.SideBlock = 7;
                CPESettings.SideLevel = (short)(CWMap.SizeY / 2);
                CPESettings.EnvMapAppearanceVersion = CPE.EnvMapAppearanceVersion;
            }

            if (HCSettings.History)
                History = new MapHistory(this);
        }
Пример #3
0
        /// <summary>
        /// Reloads the map after being unloaded to conserve memory.
        /// </summary>
        public void Load()
        {
            if (Loaded)
                return;

            CWMap = new Classicworld(Path);
            HCSettings = new HypercubeMetadata();
            CWMap.MetadataParsers.Add("Hypercube", HCSettings);
            CWMap.Load();

            _physicsBitmask = new byte[(CWMap.BlockData.Length / 8) + 1];

            HCSettings = (HypercubeMetadata)CWMap.MetadataParsers["Hypercube"];
            Path = Path.Replace(".cwu", ".cw");
            if (File.Exists(Path))
                File.Delete(Path);

            File.Move(Path + "u", Path);

            if (HCSettings.History && History != null)
                History.ReloadHistory();
            else if (HCSettings.History)
                History = new MapHistory(this);

            Loaded = true;
            ServerCore.Logger.Log("Map", CWMap.MapName + " reloaded.", LogType.Info);
            ServerCore.Luahandler.RunFunction("E_MapReloaded", this);
        }