Example #1
0
 /// <summary>
 /// Initializes new instance of <see cref="Block"/>.
 /// </summary>
 /// <param name="id"><see cref="BinBlockID"/> of this block.</param>
 public Block(BinBlockID id)
 {
     this.BlockID = id;
     this.Offsets = new List <long>();
 }
Example #2
0
        public static void GenerateAlignment(this BinaryWriter bw, string mark, long position, BinBlockID id)
        {
            int dif;

            switch (id)
            {
            // Padding is just padding, return
            case BinBlockID.Padding:
                return;

            // Those IDs require Actual alignment based on their previous one
            case BinBlockID.AcidEffects:
            case BinBlockID.AcidEmitters:
            case BinBlockID.EAGLSkeleton:
            case BinBlockID.EAGLAnimations:
            case BinBlockID.LightSourcePack:
            case BinBlockID.EmitterLibrary:
            case BinBlockID.EventTriggers:
            case BinBlockID.EventSequence:
            case BinBlockID.FEngFont:
            case BinBlockID.GeometryPack:
            case BinBlockID.GCareer_Styles:
            case BinBlockID.NISDescription:
            case BinBlockID.NISScript:
            case BinBlockID.PCAWater0:
            case BinBlockID.QuickSpline:
            case BinBlockID.ScenerySection:
            case BinBlockID.StyleMomentsInfo:
            case BinBlockID.TrackPosMarkers:
            case BinBlockID.WorldBounds:
            case BinBlockID.WCollisionPack:
            case BinBlockID.Weatherman:
            case BinBlockID.WWorld:
                dif = (int)(position % 0x100);
                MakeBigAlign(bw, mark, dif);
                return;

            case BinBlockID.WorldAnimHeader:
            case BinBlockID.WorldAnimMatrices:
            case BinBlockID.WorldAnimRTNode:
            case BinBlockID.WorldAnimNodeInfo:
            case BinBlockID.WorldAnimPointer:
                if ((byte)position == (byte)bw.BaseStream.Position)
                {
                    return;
                }
                dif = (int)(position % 0x100);
                MakeBigAlign(bw, mark, dif);
                return;

            default:
                // If we encountered known ID, do the padding accordingly
                if (Map.BlockToAlignment.TryGetValue(id, out var align))
                {
                    GeneratePadding(bw, mark, align);
                }

                // Else generate padding based on previous position
                else
                {
                    dif   = (int)(position % 0x10);
                    align = new Alignment(dif, Alignment.AlignmentType.Actual);
                    GeneratePadding(bw, mark, align);
                }

                return;
            }
        }