Exemplo n.º 1
0
        public void ReadLocations(Stream st, bool readTimeStamps = true)
        {
            RegionFile_Location tempLocation = new RegionFile_Location();
            BinaryReader        br           = new BinaryReader(st);

            for (int i = 0; i < 1024; i++)
            {
                tempLocation.offset      = (short)BinaryJava.Read3byteInt(br);
                tempLocation.sectorCount = br.ReadByte();
                if (tempLocation.sectorCount != 0)
                {
                    locations.Add(tempLocation);
                }

                tempLocation = new RegionFile_Location();
            }
            if (readTimeStamps)
            {
                for (int i = 0; i < 1024; i++)
                {
                    if (tempLocation.sectorCount != 0)
                    {
                        locations[i].timestamp = BinaryJava.ReadInt(br);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static RegionFile_Chunk GetChunkByLocation(RegionFile_Location location, Stream st)
        {
            RegionFile_Chunk tempChunk = new RegionFile_Chunk();

            BinaryReader br = new BinaryReader(st);
            {
                br.ReadBytes(8192);
                long ichi = br.BaseStream.Position;
                br.BaseStream.Position = location.offset * 4096;
                byte[]       chunkData   = br.ReadBytes(location.sectorCount * 4096);
                BinaryReader chunkDataBR = new BinaryReader(new MemoryStream(chunkData));
                tempChunk.length          = BinaryJava.ReadInt(chunkDataBR);
                tempChunk.compressionType = chunkDataBR.ReadByte();
                if (tempChunk.compressionType == 2)
                {
                    //tempChunk.Data = Deflactor.DeCompress(chunkDataBR.ReadBytes(tempChunk.length)); // chunkData.Skip(5).Take(tempChunk.length).ToArray());
                    //File.WriteAllBytes( "decomBytesNewnewnew",Deflactor.DeCompress(chunkDataBR.ReadBytes(tempChunk.length)));
                    tempChunk.tag = RegionFile_Chunk.ReadTags(Deflactor.DeCompress(chunkDataBR.ReadBytes(tempChunk.length)));
                    chunkDataBR.Dispose();
                    return(tempChunk);
                }
                else
                {
                    throw new Exception("Unknown compression type");
                }
            }
        }
Exemplo n.º 3
0
        public static RegionFile_Location ReadLocation(Stream st, short index, bool readTimeStamps = true)
        {
            RegionFile_Location location = new RegionFile_Location();

            using (BinaryReader br = new BinaryReader(st))
            {
                br.BaseStream.Position = index * 4;
                location.offset        = (short)BinaryJava.Read3byteInt(br);
                location.sectorCount   = br.ReadByte();
                if (readTimeStamps)
                {
                    br.BaseStream.Position = index * 4 + 4096;
                    if (location.sectorCount != 0)
                    {
                        location.timestamp = BinaryJava.ReadInt(br);
                    }
                }
                return(location);
            }
        }