public MapObjectsListArchiveDeserializer(FileCache fileCache, MapIndex index) { byte[] bytes = fileCache.decompress(index.ObjectFileId); using (GZipStream gzipinputstream = new GZipStream(new MemoryStream(bytes), CompressionMode.Decompress)) { using (MemoryStream stream = new MemoryStream()) { byte[] buffer = new byte[1024]; do { int k = gzipinputstream.Read(buffer, 0, buffer.Length); if (k == -1 || k == 0) //This was causing a hang here, different return value in C#. RS2Sharp made this change, but did not document it. { break; } //Write the bytes to the stream. stream.Write(buffer, 0, k); } while(true); bytes = stream.ToArray(); } } MapObjectListBuffer = new Default317Buffer(bytes); }
public IReadOnlyList <MapIndex> Deserialize() { IBufferReadable buffer = GenerateMapIndexBuffer(); int mapIndexCount = buffer.buffer.Length / (sizeof(short) * 3 + sizeof(byte)); MapIndex[] indexArray = new MapIndex[mapIndexCount]; for (int index = 0; index < mapIndexCount; index++) { //ID is basically the unique value represneing bitwise combined X,Y region id. int id = buffer.getUnsignedLEShort(); int terrain = buffer.getUnsignedLEShort(); int objects = buffer.getUnsignedLEShort(); bool members = buffer.getUnsignedByte() == 1; indexArray[index] = new MapIndex(members, objects, id, terrain); } return(indexArray); }