コード例 #1
0
        private void OpenInternal(Stream stream, bool cleanupStreamOnDispose)
        {
            _reader = new BinaryReader(stream, Encoding.UTF8);
            _cleanupStreamOnDispose = cleanupStreamOnDispose;

            UserDataHeader = ParseUserDataHeader(_reader);

            if (UserDataHeader == null)
            {
                throw new MpqParsingException("Invalid MPQ header. This is probably not an MPQ archive.");
            }

            ParseArchiveHeader();

            SectorSize = 512 << ArchiveHeader.SectorSizeShift;

            var hashTableEntries = ReadTableEntires <HashTableEntry>("(hash table)", ArchiveHeader.HashTableOffset,
                                                                     ArchiveHeader.HashTableEntryCount);
            var blockTableEntries = ReadTableEntires <BlockTableEntry>("(block table)", ArchiveHeader.BlockTableOffset,
                                                                       ArchiveHeader.BlockTableEntryCount);

            BlockTable = blockTableEntries.ToList().AsReadOnly();
            HashTable  = new MpqHashTable(hashTableEntries.ToArray());
        }
コード例 #2
0
ファイル: MpqArchive.cs プロジェクト: Thenarden/nmpq
        private void OpenInternal(Stream stream, bool cleanupStreamOnDispose)
        {
            _reader = new BinaryReader(stream, Encoding.UTF8);
            _cleanupStreamOnDispose = cleanupStreamOnDispose;

            UserDataHeader = ParseUserDataHeader(_reader);

            if (UserDataHeader == null)
                throw new MpqParsingException("Invalid MPQ header. This is probably not an MPQ archive.");

            ParseArchiveHeader();

            SectorSize = 512 << ArchiveHeader.SectorSizeShift;

            var hashTableEntries = ReadTableEntires<HashTableEntry>("(hash table)", ArchiveHeader.HashTableOffset,
                                                                    ArchiveHeader.HashTableEntryCount);
            var blockTableEntries = ReadTableEntires<BlockTableEntry>("(block table)", ArchiveHeader.BlockTableOffset,
                                                                      ArchiveHeader.BlockTableEntryCount);

            BlockTable = blockTableEntries.ToList().AsReadOnly();
            HashTable = new MpqHashTable(hashTableEntries.ToArray());
        }