예제 #1
0
        public Map Load(string fileName)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }
            using (FileStream fs = File.OpenRead(fileName)) {
                using (GZipStream gs = new GZipStream(fs, CompressionMode.Decompress)) {
                    int formatVersion;
                    Map map = LoadHeaderInternal(gs, out formatVersion);

                    map.Blocks = new byte[map.Volume];
                    if (formatVersion != 1050)
                    {
                        BufferUtil.ReadAll(gs, map.Blocks);
                    }
                    else
                    {
                        byte[] buffer = new byte[4];
                        for (int i = 0; i < map.Volume; i++)
                        {
                            gs.Read(buffer, 0, 4);
                            map.Blocks[i] = buffer[0];
                        }
                    }
                    map.ConvertBlockTypes(Mapping);
                    return(map);
                }
            }
        }
예제 #2
0
        public virtual Map Load(string fileName)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }
            using (FileStream mapStream = File.OpenRead(fileName)) {
                using (GZipStream gs = new GZipStream(mapStream, CompressionMode.Decompress)) {
                    Map map = LoadHeaderInternal(gs);

                    // Read in the map data
                    map.Blocks = new byte[map.Volume];
                    BufferUtil.ReadAll(gs, map.Blocks);

                    map.ConvertBlockTypes(Mapping);

                    if (gs.ReadByte() != 0xBD)
                    {
                        return(map);
                    }
                    ReadCustomBlocks(gs, map);
                    return(map);
                }
            }
        }
예제 #3
0
 protected virtual void LoadBlockData([NotNull] Map map, [NotNull] Stream gs)
 {
     map.Blocks = new byte[map.Volume];
     BufferUtil.ReadAll(gs, map.Blocks);
     map.ConvertBlockTypes(MCSharpMapping);
 }