Esempio n. 1
0
    void DelayedLoad()
    {
        if (null == _record)
        {
            return;
        }

        if (!_record.Open())
        {
            return;
        }

        BinaryReader br = _record.binaryReader;

        _dataSource.Import(br);
        _record.Close();
        _record = null;
    }
Esempio n. 2
0
    public void Import(Pathea.PeRecordReader r)
    {
        if (null == r)
        {
            return;
        }
        if (_tmpVoxelFileStream == null)
        {
            return;
        }

        if (!r.Open())
        {
            return;
        }

        BinaryReader br = r.binaryReader;

        // Version check
        int ver = br.ReadInt32();

        if (ver != s_ver)
        {
            Debug.LogError("[VoxelSave]:Error version:" + ver + "|" + s_ver);
            r.Close();
            return;
        }

        int cnt = br.ReadInt32();

        byte[]       buff  = VFVoxelChunkData.s_ChunkDataPool.Get();
        BinaryWriter tmpbw = new BinaryWriter(_tmpVoxelFileStream);

        _tmpVoxelFileStream.Seek(0, SeekOrigin.Begin);
        tmpbw.Write(ver);
        tmpbw.Write(cnt);
        for (int i = 0; i < cnt; i++)
        {
            br.Read(buff, 0, VoxelTerrainConstants.VOXEL_ARRAY_LENGTH_VT);
            _tmpVoxelFileStream.Write(buff, 0, VoxelTerrainConstants.VOXEL_ARRAY_LENGTH_VT);
        }
        VFVoxelChunkData.s_ChunkDataPool.Free(buff);

        _modifiedChunksInfo.Clear();
        //long chnkDataPos = br.BaseStream.Position;
        //long infoDataPos = chnkDataPos + cnt*VoxelTerrainConstants.VOXEL_ARRAY_LENGTH_VT;
        //br.BaseStream.Seek(infoDataPos);
        for (int i = 0; i < cnt; i++)
        {
            int  x   = br.ReadInt32();
            int  y   = br.ReadInt32();
            int  z   = br.ReadInt32();
            int  w   = br.ReadInt32();
            long pos = br.ReadInt64();
            _modifiedChunksInfo.Add(new IntVector4(x, y, z, w), pos);
        }

        if (_addtionalReader != null)
        {
            _addtionalReader(br);
        }
        r.Close();
    }