Exemplo n.º 1
0
 public bool TryReadMod(IBinaryReadStream stream, out ModHeader header)
 {
     if (stream.Remaining < this.ModHeaderLength)
     {
         header = default;
         return(false);
     }
     header = new ModHeader(this, stream.ReadSpan(this.ModHeaderLength));
     return(true);
 }
Exemplo n.º 2
0
        public static void FillModTypes(
            IBinaryReadStream stream,
            ModTypeFillWrapper fill,
            BinaryOverlayFactoryPackage package)
        {
            int?      lastParsed      = null;
            ModHeader headerMeta      = stream.GetModHeader(package);
            var       minimumFinalPos = checked ((int)(stream.Position + headerMeta.TotalLength));

            fill(
                stream: stream,
                finalPos: minimumFinalPos,
                offset: 0,
                type: headerMeta.RecordType,
                lastParsed: lastParsed,
                recordTypeConverter: null);
            stream.Position = (int)headerMeta.TotalLength;
            while (!stream.Complete)
            {
                GroupHeader groupMeta = stream.GetGroup(package);
                if (!groupMeta.IsGroup)
                {
                    throw new ArgumentException("Did not see GRUP header as expected.");
                }
                if (groupMeta.ContentLength == 0)
                {
                    stream.Position += groupMeta.TotalLength;
                    continue;
                }
                minimumFinalPos = checked ((int)(stream.Position + groupMeta.TotalLength));
                var parsed = fill(
                    stream: stream,
                    finalPos: minimumFinalPos,
                    offset: 0,
                    type: groupMeta.ContainedRecordType,
                    lastParsed: lastParsed,
                    recordTypeConverter: null);
                if (!parsed.KeepParsing)
                {
                    break;
                }
                if (!parsed.KeepParsing)
                {
                    break;
                }
                if (minimumFinalPos > stream.Position)
                {
                    stream.Position = checked ((int)minimumFinalPos);
                }
                lastParsed = parsed.ParsedIndex;
            }
        }
Exemplo n.º 3
0
 public static bool TryReadMod(this IMutagenReadStream stream, out ModHeader header) => stream.MetaData.Constants.TryReadMod(stream, out header);
Exemplo n.º 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="header">Existing ModHeader struct</param>
 /// <param name="span">Span to overlay on, aligned to the start of the header</param>
 public ModHeaderFrame(ModHeader header, ReadOnlyMemorySlice <byte> span)
 {
     this._header = header;
     this.HeaderAndContentData = span.Slice(0, checked ((int)this._header.TotalLength));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="meta">Game metadata to use as reference for alignment</param>
 /// <param name="span">Span to overlay on, aligned to the start of the ModHeader</param>
 public ModHeaderFrame(GameConstants meta, ReadOnlyMemorySlice <byte> span)
 {
     this._header = meta.ModHeader(span);
     this.HeaderAndContentData = span.Slice(0, checked ((int)this._header.TotalLength));
 }