CrystalMpq.MpqFileStream.ReadBlockOffsets C# (CSharp) Method

ReadBlockOffsets() private static method

private static ReadBlockOffsets ( MpqArchive archive, uint hash, long offset, int count ) : uint[]
archive MpqArchive
hash uint
offset long
count int
return uint[]
        private static unsafe uint[] ReadBlockOffsets(MpqArchive archive, uint hash, long offset, int count)
        {
            int length = count * sizeof(uint);
            var sharedBuffer = CommonMethods.GetSharedBuffer(length);

            if (archive.ReadArchiveData(sharedBuffer, 0, offset, length) != length) throw new EndOfStreamException();

            var offsets = new uint[count];

            Buffer.BlockCopy(sharedBuffer, 0, offsets, 0, length);

            if (!BitConverter.IsLittleEndian) CommonMethods.SwapBytes(offsets);

            // If hash is valid, decode the header
            if (hash != 0) unchecked { CommonMethods.Decrypt(offsets, hash - 1); }

            return offsets;
        }