예제 #1
0
 public TeleporterContainer(string mapName)
 {
     _teleporters = new List<Teleporter>();
     _porterSettings = new Settings(mapName + "ports.txt", ReadPorters, "Maps/");
     ServerCore.Setting.RegisterFile(_porterSettings);
     _porterSettings.LoadFile();
 }
예제 #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();
 }
예제 #3
0
파일: Block.cs 프로젝트: umby24/Hypercube
        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();
        }
예제 #4
0
 /// <summary>
 /// Registers a file with the settings system
 /// </summary>
 public void RegisterFile(Settings settingsFile)
 {
     _settingsFiles.Add(settingsFile);
 }
예제 #5
0
파일: D3Map.cs 프로젝트: umby24/Hypercube
        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.
        }
예제 #6
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>();
        }
예제 #7
0
 public BuildMode()
 {
     BuildModeLoader = new Settings("Buildmodes.txt", Load);
     ServerCore.Setting.RegisterFile(BuildModeLoader);
     BuildModeLoader.LoadFile();
 }
예제 #8
0
파일: Text.cs 프로젝트: umby24/Hypercube
 public Text()
 {
     TextSettings = new Settings("Colors.txt", ReadTextSettings);
     ServerCore.Setting.RegisterFile(TextSettings);
     TextSettings.LoadFile();
 }
예제 #9
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();
        }
예제 #10
0
 public PermissionContainer()
 {
     PermFile = new Settings("Permissions.txt", LoadPermissions, "Settings/", false);
     ServerCore.Setting.RegisterFile(PermFile);
     PermFile.LoadFile();
 }
예제 #11
0
파일: Rank.cs 프로젝트: umby24/Hypercube
        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();
        }