Beispiel #1
0
        /// <summary>
        /// Creates a new blank map.
        /// </summary>
        public HypercubeMap(Hypercube Core, string Filename, string MapName, short SizeX, short SizeY, short SizeZ)
        {
            ServerCore = Core;
            Map        = new ClassicWorld(SizeX, SizeZ, SizeY);

            HCSettings          = new HypercubeMetadata(); // -- Hypercube specific settings, woo.
            HCSettings.Building = true;                    // -- Enable building and physics by default.
            HCSettings.Physics  = true;
            HCSettings.History  = new int[Map.BlockData.Length];

            foreach (Rank r in Core.Rankholder.Ranks)   // -- Allow all ranks to access this map by default.
            {
                JoinRanks.Add(r);
                BuildRanks.Add(r);
                ShowRanks.Add(r);
            }

            Map.MetadataParsers.Add("Hypercube", HCSettings); // -- Add the parser so it will save with the map :)

            Map.MapName = MapName;
            Path        = Filename;

            Map.GeneratingSoftware = "Hypercube";
            Map.GeneratorName      = "Blank";
            Map.CreatingService    = "Classicube";
            Map.CreatingUsername   = "******";

            var myRef = (CPEMetadata)Map.MetadataParsers["CPE"];

            if (myRef.CustomBlocksFallback == null)
            {
                myRef.CustomBlocksLevel    = 1;
                myRef.CustomBlocksVersion  = 1;
                myRef.CustomBlocksFallback = new byte[256];

                for (int i = 50; i < 66; i++)
                {
                    myRef.CustomBlocksFallback[i] = (byte)Core.Blockholder.GetBlock(i).CPEReplace;
                }

                Map.MetadataParsers["CPE"] = myRef;
            }

            Map.Save(Path);

            LastClient = DateTime.UtcNow;
            Clients    = new List <NetworkClient>();
            Entities   = new List <Entity>();

            ClientThread = new Thread(MapMain);
            ClientThread.Start();

            EntityThread = new Thread(MapEntities);
            EntityThread.Start();
        }
Beispiel #2
0
        /// <summary>
        /// Saves this map.
        /// </summary>
        /// <param name="Filename"></param>
        public void SaveMap(string Filename = "")
        {
            if (!Loaded)
            {
                return;
            }

            HCSettings.BuildRanks = "";

            foreach (Rank r in BuildRanks)
            {
                HCSettings.BuildRanks += r.ID + ",";
            }
            foreach (Rank r in JoinRanks)
            {
                HCSettings.JoinRanks += r.ID + ",";
            }
            foreach (Rank r in ShowRanks)
            {
                HCSettings.ShowRanks += r.ID + ",";
            }

            HCSettings.BuildRanks = HCSettings.BuildRanks.TrimEnd(',');
            HCSettings.ShowRanks  = HCSettings.ShowRanks.TrimEnd(',');
            HCSettings.JoinRanks  = HCSettings.JoinRanks.TrimEnd(',');

            Map.MetadataParsers["Hypercube"] = HCSettings;

            if (Filename != "")
            {
                Map.Save(Filename);
            }
            else
            {
                Map.Save(Path);
            }
        }