示例#1
0
        void ReadGroup(Header parentHeader, bool loadAll, ProxySink.DataInfo info)
        {
            _r.Position = parentHeader.Position;
            var endPosition = parentHeader.Position + parentHeader.DataSize;

            while (_r.Position < endPosition)
            {
                var header = new Header(this, _r, Format);

                // STREAMING READ
                if (info != null && (info.Data != null || Format != GameFormat.TES3))
                {
                    if (header.Type == "GRUP" && Depth < MaxDepthStreamed)
                    {
                        if (info.Data != null)
                        {
                            goto next;
                        }
                        info.EnterGroup();
                        ReadGRUP(header, loadAll, info);
                        info.LeaveGroup();
                        continue;
                    }
                    else
                    {
                        info.Data?.Invoke(_r.ReadAbsoluteBytes(header.HeaderPosition, (int)(header.Position - header.HeaderPosition) + (int)header.DataSize));
                    }
                    goto next;
                }

                // LOCAL READ
                if (header.Type == "GRUP")
                {
                    ReadGRUP(header, loadAll, null);
                    continue;
                }
                // HACK to limit cells loading
                if (header.Type == "CELL" && _cellsLoaded > int.MaxValue)
                {
                    goto next;
                }
                var record = header.CreateRecord(_r.Position, RecordLevel);
                if (record == null)
                {
                    goto next;
                }
                ReadRecord(record, header.Compressed);
                Records.Add(record);
                if (header.Type == "CELL")
                {
                    _cellsLoaded++;
                }
                continue;

                // NEXT
next:
                _r.Position += header.DataSize;
            }
        }