예제 #1
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);
        }
예제 #2
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;
        }
예제 #3
0
        public void PerkStringHandler(
            IMutagenReadStream stream,
            MajorRecordHeader major,
            BinaryFileProcessor.ConfigConstructor instr,
            List <KeyValuePair <uint, uint> > processedStrings,
            IStringsLookup overlay,
            ref uint newIndex)
        {
            var  majorCompletePos = stream.Position + major.ContentLength;
            long?lastepft         = null;

            while (stream.Position < majorCompletePos)
            {
                var sub = stream.GetSubrecord();
                switch (sub.RecordTypeInt)
                {
                case RecordTypeInts.FULL:
                case RecordTypeInts.EPF2:
                    AStringsAlignment.ProcessStringLink(stream, instr, processedStrings, overlay, ref newIndex);
                    break;

                case RecordTypeInts.EPFT:
                    lastepft = stream.Position;
                    break;

                case RecordTypeInts.EPFD:
                    var pos = stream.Position;
                    stream.Position = lastepft.Value;
                    var epftFrame = stream.ReadSubrecordFrame();
                    if (epftFrame.Content[0] == (byte)APerkEntryPointEffect.ParameterType.LString)
                    {
                        stream.Position = pos;
                        AStringsAlignment.ProcessStringLink(stream, instr, processedStrings, overlay, ref newIndex);
                    }
                    stream.Position = pos;
                    break;

                default:
                    break;
                }
                stream.Position += sub.TotalLength;
            }
        }
예제 #4
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;
            }
        }