// Opens the file and adds ".rdf" at the end (Region Data File)
    public RegionFile(string name, ChunkPos pos, float chunkLen)
    {
        bool isLoaded = true;

        this.name        = name;
        this.regionPos   = pos;
        this.chunkLength = chunkLen;
        this.index       = new Dictionary <long, long>();
        this.worldDir    = "Worlds/" + World.worldName + "/";

        this.cachedIndex = new byte[16384];
        this.cachedHoles = new byte[16384];
        this.longArray   = new byte[8];

        try{
            this.file = File.Open(this.worldDir + name + ".rdf", FileMode.Open);
        }
        catch (FileNotFoundException) {
            isLoaded  = false;
            this.file = File.Open(this.worldDir + name + ".rdf", FileMode.Create);
        }

        try{
            this.indexFile = File.Open(this.worldDir + name + ".ind", FileMode.Open);
        }
        catch (FileNotFoundException) {
            isLoaded       = false;
            this.indexFile = File.Open(this.worldDir + name + ".ind", FileMode.Create);
        }

        try{
            this.holeFile = File.Open(this.worldDir + name + ".hle", FileMode.Open);
        }
        catch (FileNotFoundException) {
            isLoaded      = false;
            this.holeFile = File.Open(this.worldDir + name + ".hle", FileMode.Create);
        }

        this.fragHandler = new FragmentationHandler(isLoaded);

        if (isLoaded)
        {
            LoadIndex();
            LoadHoles();
        }
    }
Beispiel #2
0
    // Opens the file and adds ".rdf" at the end (Region Data File)
    public RegionFile(string name, ChunkPos pos, float chunkLen)
    {
        bool isLoaded = true;

        this.name        = name;
        this.regionPos   = pos;
        this.chunkLength = chunkLen;
        this.index       = new Dictionary <long, long>();

        this.cachedIndex = new byte[16384];
        this.cachedHoles = new byte[16384];
        this.longArray   = new byte[8];


                #if UNITY_EDITOR
        this.saveDir  = "Worlds/";
        this.worldDir = this.saveDir + World.worldName + "/";
                #else
        // If is in Dedicated Server
        if (!World.isClient)
        {
            this.saveDir  = "Worlds/";
            this.worldDir = this.saveDir + World.worldName + "/";
        }
        // If it's a Local Server
        else
        {
            this.saveDir  = EnvironmentVariablesCentral.clientExeDir + "\\Worlds\\";
            this.worldDir = this.saveDir + World.worldName + "\\";
        }
                #endif

        try{
            this.file = File.Open(this.worldDir + name + ".rdf", FileMode.Open);
        }
        catch (FileNotFoundException) {
            isLoaded  = false;
            this.file = File.Open(this.worldDir + name + ".rdf", FileMode.Create);
        }

        try{
            this.indexFile = File.Open(this.worldDir + name + ".ind", FileMode.Open);
        }
        catch (FileNotFoundException) {
            isLoaded       = false;
            this.indexFile = File.Open(this.worldDir + name + ".ind", FileMode.Create);
        }

        try{
            this.holeFile = File.Open(this.worldDir + name + ".hle", FileMode.Open);
        }
        catch (FileNotFoundException) {
            isLoaded      = false;
            this.holeFile = File.Open(this.worldDir + name + ".hle", FileMode.Create);
        }

        this.fragHandler = new FragmentationHandler(isLoaded);

        if (isLoaded)
        {
            LoadIndex();
            LoadHoles();
        }
    }