Esempio n. 1
0
 public TeleporterContainer(string mapName)
 {
     _teleporters = new List<Teleporter>();
     _porterSettings = new Settings(mapName + "ports.txt", ReadPorters, "Maps/");
     ServerCore.Setting.RegisterFile(_porterSettings);
     _porterSettings.LoadFile();
 }
Esempio n. 2
0
 /// <summary>
 /// Creates a new NetworkHandler Instance, and loads network settings.
 /// </summary>
 public NetworkHandler()
 {
     Ns = new Settings("Network.txt", LoadSettings);
     ServerCore.Setting.RegisterFile(Ns);
     Ns.LoadFile();
     CreateLists();
 }
Esempio n. 3
0
        public BlockContainer()
        {
            NumberList = new Block[255];
            NameList = new SortedDictionary<string, Block>(StringComparer.InvariantCultureIgnoreCase);
            _blocksfile = new Settings("Blocks.txt", LoadBlocks);
            ServerCore.Setting.RegisterFile(_blocksfile);

            UnknownBlock = new Block
                {
                    Id = 99,
                    Name = "Unknown",
                    OnClient = 46,
                    CPELevel = 0,
                    CPEReplace = 46,
                    DeletePermissions = PermissionContainer.SplitPermissions("player.op"),
                    Special = true,
                };

            _blocksfile.LoadFile();
            _blocksfile.SaveFile();
        }
Esempio n. 4
0
        public void LoadMap(string directory, string mapName)
        {
            if (!File.Exists(directory + "/Data-Layer.gz") || !File.Exists(directory + "/Config.txt"))
                return; // -- Not a valid map.

            // -- Load the Config data first..
            var configfile = new Settings("TempD3Config.txt", LoadConfig, directory, false);
            configfile.LoadFile();

            Mapsize = new Vector3S {
                X = (short) configfile.Read("Size_X", 128),
                Y = (short) configfile.Read("Size_Y", 128),
                Z = (short) configfile.Read("Size_Z", 128)
            };

            Spawn = new Vector3S {
                X = (short) float.Parse(configfile.Read("Spawn_X", "1.0")),
                Y = (short) float.Parse(configfile.Read("Spawn_Y", "1.0")),
                Z = (short) float.Parse(configfile.Read("Spawn_Z", "1.0"))
            };

            SpawnRot = (byte)configfile.Read("Spawn_Rot", 0);
            SpawnLook = (byte)configfile.Read("Spawn_Look", 0);

            Motd = configfile.Read("MOTD_Override", "");
            PhysicsStopped = Convert.ToBoolean(configfile.Read("Physic_Stopped", 0));

            // -- Load the block data
            GZip.DecompressFile(directory + "/Data-Layer.gz");
            byte[] allData;

            using (var br = new BinaryReader(new FileStream(directory + "/Data-Layer.gz", FileMode.Open)))
                allData = br.ReadBytes((int)br.BaseStream.Length);

            GZip.CompressFile(directory + "/Data-Layer.gz");

            if (allData.Length != (Mapsize.X * Mapsize.Y * Mapsize.Z) * 4) {
                // -- Size error..
                return;
            }

            Blockdata = new byte[Mapsize.X * Mapsize.Y * Mapsize.Z];
            // -- Converts block data from the D3 array format to the ClassicWorld array format.
            for (var x = 0; x < Mapsize.X; x++) {
                for (var y = 0; y < Mapsize.Y; y++) {
                    for (var z = 0; z < Mapsize.Z; z++)
                        Blockdata[GetIndex(x, y, z)] = allData[GetBlock(x, y, z)];
                }
            }

            // -- Now, Block data will be properly oriented for use in ClassicWorld maps, and we have all the data we need to create a classicworld map.

            var cwMap = new Classicworld(Mapsize.X, Mapsize.Z, Mapsize.Y) {
                BlockData = Blockdata,
                SpawnX = Spawn.X,
                SpawnY = Spawn.Z,
                SpawnZ = Spawn.Y,
                SpawnRotation = SpawnRot,
                SpawnLook = SpawnLook,
                MapName = mapName
            }; // -- Classicworld is in notchian Coordinates.

            cwMap.Save("Maps/" + mapName + ".cw");
            Blockdata = null;
            cwMap.BlockData = null;
            GC.Collect();
            // -- Conversion Complete.
        }
Esempio n. 5
0
        /// <summary>
        /// Loads server settings, loads the database, and prepares the system for use.
        /// </summary>
        public static void Setup()
        {
            Setting = new PbSettingsLoader();
            TextFormats = new Text();

            SysSettings = new Settings("System.txt", ReadSystemSettings);
            Setting.RegisterFile(SysSettings);
            SysSettings.LoadFile();

            Rulesfile = new Settings("Rules.txt", ReadRules, "Settings/", false);
            Setting.RegisterFile(Rulesfile);
            Rulesfile.LoadFile();

            if (RotateLogs)
                Logger.RotateLogs();

            Permholder = new PermissionContainer();
            Rankholder = new RankContainer();
            Blockholder = new BlockContainer();
            BmContainer = new BuildMode();

            DefaultRank = Rankholder.GetRank(DefaultRank.Name);

            DB = new Database();
            Logger.Log("Database", "Database loaded.", LogType.Info);

            Nh = new NetworkHandler();
            Logger.Log("", "Core Initialized.", LogType.Info);

            Maps = new Dictionary<string, HypercubeMap>(StringComparer.InvariantCultureIgnoreCase);
            HypercubeMap.LoadMaps();

            HypercubeMap m;
            Maps.TryGetValue(MapMain, out m);

            if (m == null) {
                var mainMap = new HypercubeMap("Maps/" + MapMain + ".cw", MapMain, 128, 128, 128);
                Maps.Add(MapMain, mainMap);
                Logger.Log("Core", "Main world not found, a new one has been created.", LogType.Warning);
            }

            Commandholder = new CommandHandler();
            Fillholder = new FillContainer();

            Luahandler = new HCLua();
            Luahandler.RegisterFunctions();
            Luahandler.LoadScripts();

            Setting.SaveAll();

            FillStacks();
            ActionQueue = new ConcurrentQueue<MapAction>();
        }
Esempio n. 6
0
 public BuildMode()
 {
     BuildModeLoader = new Settings("Buildmodes.txt", Load);
     ServerCore.Setting.RegisterFile(BuildModeLoader);
     BuildModeLoader.LoadFile();
 }
Esempio n. 7
0
 public Text()
 {
     TextSettings = new Settings("Colors.txt", ReadTextSettings);
     ServerCore.Setting.RegisterFile(TextSettings);
     TextSettings.LoadFile();
 }
Esempio n. 8
0
        public CommandHandler()
        {
            CommandDict = new Dictionary<string, Command>(StringComparer.InvariantCultureIgnoreCase);

            Populate();
            RegisterGroups();

            AliasLoader = new Settings("Aliases.txt", LoadAliases, "Settings/", false);
            ServerCore.Setting.RegisterFile(AliasLoader);
            AliasLoader.LoadFile();

            CommandSettings = new Settings("Commands.txt", LoadCommands);
            ServerCore.Setting.RegisterFile(CommandSettings);
            CommandSettings.LoadFile();

            FillFile();
        }
Esempio n. 9
0
 public PermissionContainer()
 {
     PermFile = new Settings("Permissions.txt", LoadPermissions, "Settings/", false);
     ServerCore.Setting.RegisterFile(PermFile);
     PermFile.LoadFile();
 }
Esempio n. 10
0
        public RankContainer()
        {
            NumberList = new SortedDictionary<int, Rank>();
            NameList = new SortedDictionary<string, Rank>(StringComparer.InvariantCultureIgnoreCase);
            RankHierarchy = new Dictionary<Rank, List<Rank>>();

            Ranksfile = new Settings("Ranks.txt", LoadRanks);
            ServerCore.Setting.RegisterFile(Ranksfile);
            Ranksfile.LoadFile();
        }