Exemple #1
0
        public void MajorMemoryFrameTryLocateSubrecord()
        {
            var majorFrame = new MajorRecordFrame(GameConstants.Oblivion, _majorBytes);

            Assert.True(majorFrame.TryLocateSubrecord(RecordTypes.DATA, out var _, out var loc));
            Assert.Equal(DataPos, loc);
        }
Exemple #2
0
 private void ProcessCombatStyle(
     MajorRecordFrame majorFrame,
     long fileOffset)
 {
     if (majorFrame.TryLocateSubrecord(RecordTypes.CSTD, out var ctsd, out var ctsdLoc))
     {
         var len  = ctsd.ContentLength;
         var move = 2;
         this._instructions.SetSubstitution(
             sub: new byte[] { 0, 0 },
             loc: fileOffset + ctsdLoc + ctsd.HeaderLength + move);
         move = 38;
         if (len < 2 + move)
         {
             return;
         }
         this._instructions.SetSubstitution(
             sub: new byte[] { 0, 0 },
             loc: fileOffset + ctsdLoc + ctsd.HeaderLength + move);
         move = 53;
         if (len < 3 + move)
         {
             return;
         }
         this._instructions.SetSubstitution(
             sub: new byte[] { 0, 0, 0 },
             loc: fileOffset + ctsdLoc + ctsd.HeaderLength + 53);
         move = 69;
         if (len < 3 + move)
         {
             return;
         }
         this._instructions.SetSubstitution(
             sub: new byte[] { 0, 0, 0 },
             loc: fileOffset + ctsdLoc + ctsd.HeaderLength + 69);
         move = 82;
         if (len < 2 + move)
         {
             return;
         }
         this._instructions.SetSubstitution(
             sub: new byte[] { 0, 0 },
             loc: fileOffset + ctsdLoc + ctsd.HeaderLength + 82);
         move = 113;
         if (len < 3 + move)
         {
             return;
         }
         this._instructions.SetSubstitution(
             sub: new byte[] { 0, 0, 0 },
             loc: fileOffset + ctsdLoc + ctsd.HeaderLength + 113);
     }
 }
Exemple #3
0
    private void ProcessGameSettings(
        MajorRecordFrame majorFrame,
        long fileOffset)
    {
        var edidRec = majorFrame.LocateSubrecordFrame("EDID");

        if ((char)edidRec.Content[0] != 'f')
        {
            return;
        }

        if (majorFrame.TryLocateSubrecord(RecordTypes.DATA, out var dataRec, out var dataIndex))
        {
            dataIndex += dataRec.HeaderLength;
            ProcessZeroFloat(majorFrame, fileOffset, ref dataIndex);
        }
    }
Exemple #4
0
 /// <summary>
 /// Iterates a MajorRecordFrame's contents and locates the first occurance of the desired type
 /// </summary>
 /// <param name="majorFrame">Frame to read from</param>
 /// <param name="type">Type to search for</param>
 /// <param name="header">SubrecordHeader if found</param>
 /// <returns>True if matching subrecord is found</returns>
 public static bool TryLocateSubrecord(this MajorRecordFrame majorFrame, RecordType type, out SubrecordHeader header)
 {
     return(majorFrame.TryLocateSubrecord(type, header: out header, loc: out var _));
 }
Exemple #5
0
    private void ProcessWater(
        MajorRecordFrame majorFrame,
        long fileOffset)
    {
        var amount = 0;

        if (majorFrame.TryLocateSubrecord(RecordTypes.DATA, out var dataRec, out var dataLoc))
        {
            var len = dataRec.ContentLength;
            if (len == 0x02)
            {
                this._instructions.SetSubstitution(
                    loc: fileOffset + dataLoc + Plugins.Internals.Constants.HeaderLength,
                    sub: new byte[] { 0, 0 });
                this._instructions.SetRemove(
                    section: RangeInt64.FactoryFromLength(
                        loc: fileOffset + dataLoc + dataRec.HeaderLength,
                        length: 2));
                amount -= 2;
            }

            if (len == 0x56)
            {
                this._instructions.SetSubstitution(
                    loc: fileOffset + dataLoc + Plugins.Internals.Constants.HeaderLength,
                    sub: new byte[] { 0x54, 0 });
                this._instructions.SetRemove(
                    section: RangeInt64.FactoryFromLength(
                        loc: fileOffset + dataLoc + dataRec.HeaderLength + 0x54,
                        length: 2));
                amount -= 2;
            }

            if (len == 0x2A)
            {
                this._instructions.SetSubstitution(
                    loc: fileOffset + dataLoc + Plugins.Internals.Constants.HeaderLength,
                    sub: new byte[] { 0x28, 0 });
                this._instructions.SetRemove(
                    section: RangeInt64.FactoryFromLength(
                        loc: fileOffset + dataLoc + dataRec.HeaderLength + 0x28,
                        length: 2));
                amount -= 2;
            }

            if (len == 0x3E)
            {
                this._instructions.SetSubstitution(
                    loc: fileOffset + dataLoc + Plugins.Internals.Constants.HeaderLength,
                    sub: new byte[] { 0x3C, 0 });
                this._instructions.SetRemove(
                    section: RangeInt64.FactoryFromLength(
                        loc: fileOffset + dataLoc + dataRec.HeaderLength + 0x3C,
                        length: 2));
                amount -= 2;
            }

            var move = 0x39;
            if (len >= 3 + move)
            {
                this._instructions.SetSubstitution(
                    sub: new byte[] { 0, 0, 0 },
                    loc: fileOffset + dataLoc + dataRec.HeaderLength + move);
            }
        }

        ProcessLengths(
            majorFrame,
            amount,
            fileOffset);
    }