Example #1
0
 public MapHeader(
     PlaneMetadata plane0Info,
     PlaneMetadata plane1Info,
     PlaneMetadata plane2Info,
     ushort width,
     ushort height,
     string name)
 {
     Plane0Info = plane0Info;
     Plane1Info = plane1Info;
     Plane2Info = plane2Info;
     Width      = width;
     Height     = height;
     Name       = name;
 }
        private void LoadPlane(ushort[] planeData, PlaneMetadata planeInfo, Stream mapsStream)
        {
            var buffer = new byte[planeInfo.CompressedLength];

            mapsStream.Position = planeInfo.Offset;
            mapsStream.Read(buffer, 0, buffer.Length);

            var uncarmacked = Expander.DecompressCarmack(buffer);

            var finalSize = BitConverter.ToUInt16(uncarmacked, 0);
            var rlewData  = new byte[uncarmacked.Length - 2];

            Buffer.BlockCopy(uncarmacked, 2, rlewData, 0, rlewData.Length);

            // TODO: This array can also be created once per map and reused
            var finalBytes = Expander.DecompressRlew(_rlewMarker, rlewData, finalSize);

            Buffer.BlockCopy(finalBytes, 0, planeData, 0, finalBytes.Length);
        }