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); } } }
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); } } }
protected virtual void LoadBlockData([NotNull] Map map, [NotNull] Stream gs) { map.Blocks = new byte[map.Volume]; BufferUtil.ReadAll(gs, map.Blocks); map.ConvertBlockTypes(MCSharpMapping); }