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;
        }