Exemplo n.º 1
0
        public static void ProcessStringLink(
            IMutagenReadStream stream,
            BinaryFileProcessor.ConfigConstructor instr,
            List <KeyValuePair <uint, uint> > processedStrings,
            IStringsLookup overlay,
            ref uint newIndex)
        {
            var sub = stream.ReadSubrecord();

            if (sub.ContentLength != 4)
            {
                throw new ArgumentException();
            }
            var curIndex = BinaryPrimitives.ReadUInt32LittleEndian(stream.GetSpan(4));

            if (!overlay.TryLookup(curIndex, out var str))
            {
                instr.SetSubstitution(stream.Position, new byte[4]);
            }
            else if (curIndex != 0)
            {
                var assignedIndex = newIndex++;
                processedStrings.Add(new KeyValuePair <uint, uint>(curIndex, assignedIndex));
                byte[] b = new byte[4];
                BinaryPrimitives.WriteUInt32LittleEndian(b, assignedIndex);
                instr.SetSubstitution(stream.Position, b);
            }
            stream.Position -= sub.HeaderLength;
        }
Exemplo n.º 2
0
    public void GameSettingStringHandler(
        IMutagenReadStream stream,
        MajorRecordHeader major,
        BinaryFileProcessor.ConfigConstructor instr,
        List <KeyValuePair <uint, uint> > processedStrings,
        IStringsLookup overlay,
        ref uint newIndex)
    {
        stream.Position -= major.HeaderLength;
        var majorRec = stream.GetMajorRecordFrame();

        if (!majorRec.TryLocateSubrecordFrame("EDID", out var edidRec))
        {
            throw new ArgumentException();
        }
        if (edidRec.Content[0] != (byte)'s')
        {
            return;
        }
        if (!majorRec.TryLocateSubrecordPinFrame("DATA", out var dataRec))
        {
            throw new ArgumentException();
        }
        stream.Position += dataRec.Location;
        AStringsAlignment.ProcessStringLink(stream, instr, processedStrings, overlay, ref newIndex);
    }
Exemplo n.º 3
0
        private void Align(
            IMutagenReadStream stream,
            MajorRecordHeader major,
            BinaryFileProcessor.ConfigConstructor instr,
            List <KeyValuePair <uint, uint> > processedStrings,
            IStringsLookup overlay,
            ref uint newIndex)
        {
            var majorCompletePos = stream.Position + major.ContentLength;

            while (stream.Position < majorCompletePos)
            {
                var sub = stream.GetSubrecord();
                if (StringTypes.Contains(sub.RecordType))
                {
                    ProcessStringLink(stream, instr, processedStrings, overlay, ref newIndex);
                }
                stream.Position += sub.TotalLength;
            }
        }