System.IO.BinaryReader.ReadUInt16()

Here are the examples of the csharp api System.IO.BinaryReader.ReadUInt16() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1353 Examples 7

19 Source : ParamSfoEntry.cs
with MIT License
from 13xforever

public static ParamSfoEntry Read(BinaryReader reader, ParamSfo paramSfo, int itemNumber)
        {
            const int indexOffset = 0x14;
            const int indexEntryLength = 0x10;
            reader.BaseStream.Seek(indexOffset + indexEntryLength * itemNumber, SeekOrigin.Begin);
            var result = new ParamSfoEntry();
            result.KeyOffset = reader.ReadUInt16();
            result.ValueFormat = (EntryFormat)reader.ReadUInt16();
            result.ValueLength = reader.ReadInt32();
            result.ValueMaxLength = reader.ReadInt32();
            result.ValueOffset = reader.ReadInt32();

            reader.BaseStream.Seek(paramSfo.KeysOffset + result.KeyOffset, SeekOrigin.Begin);
            byte tmp;
            var sb = new StringBuilder(32);
            while ((tmp = reader.ReadByte()) != 0)
                sb.Append((char)tmp);
            result.Key = sb.ToString();

            reader.BaseStream.Seek(paramSfo.ValuesOffset + result.ValueOffset, SeekOrigin.Begin);
            result.BinaryValue = reader.ReadBytes(result.ValueMaxLength);

            return result;
        }

19 Source : WaveFormat.cs
with MIT License
from 3wz

private void ReadWaveFormat(BinaryReader br, int formatChunkLength)
        {
            if (formatChunkLength < 16)
                throw new ApplicationException("Invalid WaveFormat Structure");
            this.waveFormatTag = (WaveFormatEncoding)br.ReadUInt16();
            this.channels = br.ReadInt16();
            this.sampleRate = br.ReadInt32();
            this.averageBytesPerSecond = br.ReadInt32();
            this.blockAlign = br.ReadInt16();
            this.bitsPerSample = br.ReadInt16();
            if (formatChunkLength > 16)
            {
                this.extraSize = br.ReadInt16();
                if (this.extraSize != formatChunkLength - 18)
                {
                    Debug.WriteLine("Format chunk mismatch");
                    this.extraSize = (short)(formatChunkLength - 18);
                }
            }
        }

19 Source : EndianBinaryReader.cs
with MIT License
from 91Act

public override ushort ReadUInt16()
        {
            if (endian == EndianType.BigEndian)
            {
                a16 = ReadBytes(2);
                Array.Reverse(a16);
                return BitConverter.ToUInt16(a16, 0);
            }
            return base.ReadUInt16();
        }

19 Source : App.PortableExecutableHelper.cs
with MIT License
from ABTSoftware

internal static bool IsDotNetreplacedembly(string peFile)
            {
                uint peHeader;
                uint peHeaderSignature;
                ushort machine;
                ushort sections;
                uint timestamp;
                uint pSymbolTable;
                uint noOfSymbol;
                ushort optionalHeaderSize;
                ushort characteristics;
                ushort dataDictionaryStart;
                uint[] dataDictionaryRVA = new uint[16];
                uint[] dataDictionarySize = new uint[16];


                Stream fs = new FileStream(peFile, FileMode.Open, FileAccess.Read);
                BinaryReader reader = new BinaryReader(fs);

                //PE Header starts @ 0x3C (60). Its a 4 byte header.
                fs.Position = 0x3C;

                peHeader = reader.ReadUInt32();

                //Moving to PE Header start location...
                fs.Position = peHeader;
                peHeaderSignature = reader.ReadUInt32();

                //We can also show all these value, but we will be       
                //limiting to the CLI header test.

                machine = reader.ReadUInt16();
                sections = reader.ReadUInt16();
                timestamp = reader.ReadUInt32();
                pSymbolTable = reader.ReadUInt32();
                noOfSymbol = reader.ReadUInt32();
                optionalHeaderSize = reader.ReadUInt16();
                characteristics = reader.ReadUInt16();

                /*
                    Now we are at the end of the PE Header and from here, the
                                PE Optional Headers starts...
                        To go directly to the datadictionary, we'll increase the      
                        stream’s current position to with 96 (0x60). 96 because,
                                28 for Standard fields
                                68 for NT-specific fields
                    From here DataDictionary starts...and its of total 128 bytes. DataDictionay has 16 directories in total,
                    doing simple maths 128/16 = 8.
                    So each directory is of 8 bytes.
                                In this 8 bytes, 4 bytes is of RVA and 4 bytes of Size.

                    btw, the 15th directory consist of CLR header! if its 0, its not a CLR file :)
             */
                dataDictionaryStart = Convert.ToUInt16(Convert.ToUInt16(fs.Position) + 0x60);
                fs.Position = dataDictionaryStart;
                for (int i = 0; i < 15; i++)
                {
                    dataDictionaryRVA[i] = reader.ReadUInt32();
                    dataDictionarySize[i] = reader.ReadUInt32();
                }
                if (dataDictionaryRVA[14] == 0)
                {
                    Console.WriteLine("This is NOT a valid CLR File!!");
                    return false;
                }
                else
                {
                    Console.WriteLine("This is a valid CLR File..");
                    return true;
                }
                fs.Close();
            }

19 Source : BinaryReaderExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static string ReadString16L(this BinaryReader reader)
        {
            ushort length = reader.ReadUInt16();
            string rdrStr = (length != 0 ? new string(reader.ReadChars(length)) : string.Empty);

            // client pads string length to be a multiple of 4 including the 2 bytes for length
            reader.Skip(CalculatePadMultiple(sizeof(ushort) + (uint)length, 4u));
            return rdrStr;
        }

19 Source : ReplaceObjectHook.cs
with GNU Affero General Public License v3.0
from ACEmulator

public override void Unpack(BinaryReader reader)
        {
            base.Unpack(reader);

            // The structure of AnimationPartChange here is slightly different for some reason than the other imeplementations.
            // So we'll read in the 2-byte PartIndex and send that to our other implementation of the Unpack function.
            ushort apChangePartIndex = reader.ReadUInt16();
            APChange.Unpack(reader, apChangePartIndex);
        }

19 Source : BSPLeaf.cs
with GNU Affero General Public License v3.0
from ACEmulator

public override void Unpack(BinaryReader reader, BSPType treeType)
        {
            Type = Encoding.ASCII.GetString(reader.ReadBytes(4)).Reverse();

            LeafIndex = reader.ReadInt32();

            if (treeType == BSPType.Physics)
            {
                Solid = reader.ReadInt32();

                // Note that if Solid is equal to 0, these values will basically be null. Still read them, but they don't mean anything.
                Sphere = new Sphere();
                Sphere.Unpack(reader);

                InPolys = new List<ushort>();
                uint numPolys = reader.ReadUInt32();
                for (uint i = 0; i < numPolys; i++)
                    InPolys.Add(reader.ReadUInt16());
            }
        }

19 Source : BSPNode.cs
with GNU Affero General Public License v3.0
from ACEmulator

public virtual void Unpack(BinaryReader reader, BSPType treeType)
        {
            Type = Encoding.ASCII.GetString(reader.ReadBytes(4)).Reverse();
            
            switch (Type)
            {
                // These types will unpack the data completely, in their own clreplacedes
                case "PORT":
                case "LEAF":
                    throw new Exception();
            }

            SplittingPlane = new Plane();
            SplittingPlane.Unpack(reader);

            switch (Type)
            {
                case "BPnn":
                case "BPIn":
                    PosNode = BSPNode.ReadNode(reader, treeType);
                    break;
                case "BpIN":
                case "BpnN":
                    NegNode = BSPNode.ReadNode(reader, treeType);
                    break;
                case "BPIN":
                case "BPnN":
                    PosNode = BSPNode.ReadNode(reader, treeType);
                    NegNode = BSPNode.ReadNode(reader, treeType);
                    break;
            }

            if (treeType == BSPType.Cell)
                return;

            Sphere = new Sphere();
            Sphere.Unpack(reader);

            if (treeType == BSPType.Physics)
                return;

            InPolys = new List<ushort>();
            uint numPolys = reader.ReadUInt32();
            for (uint i = 0; i < numPolys; i++)
                InPolys.Add(reader.ReadUInt16());
        }

19 Source : CBldPortal.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void Unpack(BinaryReader reader)
        {
            Flags = (PortalFlags)reader.ReadUInt16();

            OtherCellId = reader.ReadUInt16();
            OtherPortalId = reader.ReadUInt16();

            ushort num_stabs = reader.ReadUInt16();
            for (var i = 0; i < num_stabs; i++)
                StabList.Add(reader.ReadUInt16());

            reader.AlignBoundary();
        }

19 Source : CellPortal.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void Unpack(BinaryReader reader)
        {
            Flags           = (PortalFlags)reader.ReadUInt16();
            PolygonId       = reader.ReadUInt16();
            OtherCellId     = reader.ReadUInt16();
            OtherPortalId   = reader.ReadUInt16();
        }

19 Source : CellStruct.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void Unpack(BinaryReader reader)
        {
            var numPolygons        = reader.ReadUInt32();
            var numPhysicsPolygons = reader.ReadUInt32();
            var numPortals         = reader.ReadUInt32();

            VertexArray.Unpack(reader);

            Polygons.Unpack(reader, numPolygons);

            for (uint i = 0; i < numPortals; i++)
                Portals.Add(reader.ReadUInt16());

            reader.AlignBoundary();

            CellBSP.Unpack(reader, BSPType.Cell);

            PhysicsPolygons.Unpack(reader, numPhysicsPolygons);

            PhysicsBSP.Unpack(reader, BSPType.Physics);

            uint hasDrawingBSP = reader.ReadUInt32();
            if (hasDrawingBSP != 0)
            {
                DrawingBSP = new BSPTree();
                DrawingBSP.Unpack(reader, BSPType.Drawing);
            }

            reader.AlignBoundary();
        }

19 Source : FontCharDesc.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void Unpack(BinaryReader reader)
        {
            Unicode = reader.ReadUInt16();
            OffsetX = reader.ReadUInt16();
            OffsetY = reader.ReadUInt16();
            Width = reader.ReadByte();
            Height = reader.ReadByte();
            HorizontalOffsetBefore = reader.ReadByte();
            HorizontalOffsetAfter = reader.ReadByte();
            VerticalOffsetBefore = reader.ReadByte();
        }

19 Source : StringTableData.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void Unpack(BinaryReader reader)
        {
            Id = reader.ReadUInt32();

            var num_varnames = reader.ReadUInt16();
            for (uint i = 0; i < num_varnames; i++)
                VarNames.Add(reader.ReadUnicodeString());

            var num_vars = reader.ReadUInt16();
            for (uint i = 0; i < num_vars; i++)
                Vars.Add(reader.ReadUnicodeString());

            var num_strings = reader.ReadUInt32();
            for (uint i = 0; i < num_strings; i++)
                Strings.Add(reader.ReadUnicodeString());

            var num_comments = reader.ReadUInt32();
            for (uint i = 0; i < num_comments; i++)
                Comments.Add(reader.ReadUInt32());

            Unknown = reader.ReadByte();
        }

19 Source : CellLandblock.cs
with GNU Affero General Public License v3.0
from ACEmulator

public override void Unpack(BinaryReader reader)
        {
            Id = reader.ReadUInt32();

            uint hasObjects = reader.ReadUInt32();
            if (hasObjects == 1)
                HasObjects = true;

            // Read in the terrain. 9x9 so 81 records.
            for (int i = 0; i < 81; i++)
            {
                var terrain = reader.ReadUInt16();
                Terrain.Add(terrain);
            }

            // Read in the height. 9x9 so 81 records
            for (int i = 0; i < 81; i++)
            {
                var height = reader.ReadByte();
                Height.Add(height);
            }

            reader.AlignBoundary();
        }

19 Source : ContractTable.cs
with GNU Affero General Public License v3.0
from ACEmulator

public override void Unpack(BinaryReader reader)
        {
            Id = reader.ReadUInt32();

            ushort num_contracts = reader.ReadUInt16();
            /*ushort table_size = */reader.ReadUInt16(); // We don't need this since C# handles it's own memory

            for (ushort i = 0; i < num_contracts; i++)
            {
                uint key = reader.ReadUInt32();

                Contract value = new Contract();
                value.Unpack(reader);

                Contracts.Add(key, value);
            }
        }

19 Source : EnvCell.cs
with GNU Affero General Public License v3.0
from ACEmulator

public override void Unpack(BinaryReader reader)
        {
            Id = reader.ReadUInt32();

            Flags = (EnvCellFlags)reader.ReadUInt32();

            reader.BaseStream.Position += 4; // Skip ahead 4 bytes, because this is the CellId. Again. Twice.

            byte numSurfaces    = reader.ReadByte();
            byte numPortals     = reader.ReadByte();    // Note that "portal" in this context does not refer to the swirly pink/purple thing, its basically connecting cells
            ushort numStabs     = reader.ReadUInt16();  // I believe this is what cells can be seen from this one. So the engine knows what else it needs to load/draw.

            // Read what surfaces are used in this cell
            for (uint i = 0; i < numSurfaces; i++)
                Surfaces.Add(0x08000000u | reader.ReadUInt16()); // these are stored in the dat as short values, so we'll make them a full dword

            EnvironmentId = (0x0D000000u | reader.ReadUInt16());

            CellStructure = reader.ReadUInt16();

            Position.Unpack(reader);

            CellPortals.Unpack(reader, numPortals);

            for (uint i = 0; i < numStabs; i++)
                VisibleCells.Add(reader.ReadUInt16());

            if ((Flags & EnvCellFlags.HreplacedtaticObjs) != 0)
                StaticObjects.Unpack(reader);

            if ((Flags & EnvCellFlags.HasRestrictionObj) != 0)
                RestrictionObj = reader.ReadUInt32();
        }

19 Source : Texture.cs
with GNU Affero General Public License v3.0
from ACEmulator

private List<int> GetImageColorArray()
        {
            List<int> colors = new List<int>();
            if (Length == 0) return colors;

            switch (Format)
            {
                case SurfacePixelFormat.PFID_R8G8B8: // RGB
                    using (BinaryReader reader = new BinaryReader(new MemoryStream(SourceData)))
                    {
                        for (uint i = 0; i < Height; i++)
                            for (uint j = 0; j < Width; j++)
                            {
                                byte b = reader.ReadByte();
                                byte g = reader.ReadByte();
                                byte r = reader.ReadByte();
                                int color = (r << 16) | (g << 8) | b;
                                colors.Add(color);
                            }
                    }
                    break;
                case SurfacePixelFormat.PFID_CUSTOM_LSCAPE_R8G8B8:
                    using (BinaryReader reader = new BinaryReader(new MemoryStream(SourceData)))
                    {
                        for (uint i = 0; i < Height; i++)
                            for (uint j = 0; j < Width; j++)
                            {
                                byte r = reader.ReadByte();
                                byte g = reader.ReadByte();
                                byte b = reader.ReadByte();
                                int color = (r << 16) | (g << 8) | b;
                                colors.Add(color);
                            }
                    }
                    break;
                case SurfacePixelFormat.PFID_A8R8G8B8: // ARGB format. Most UI textures fall into this category
                    using (BinaryReader reader = new BinaryReader(new MemoryStream(SourceData)))
                    {
                        for (uint i = 0; i < Height; i++)
                            for (uint j = 0; j < Width; j++)
                                colors.Add(reader.ReadInt32());
                    }
                    break;
                case SurfacePixelFormat.PFID_INDEX16: // 16-bit indexed colors. Index references position in a palette;
                    using (BinaryReader reader = new BinaryReader(new MemoryStream(SourceData)))
                    {
                        for (uint y = 0; y < Height; y++)
                            for (uint x = 0; x < Width; x++)
                                colors.Add(reader.ReadInt16());
                    }
                    break;
                case SurfacePixelFormat.PFID_A8: // Greyscale, also known as Cairo A8.
                case SurfacePixelFormat.PFID_CUSTOM_LSCAPE_ALPHA:
                    using (BinaryReader reader = new BinaryReader(new MemoryStream(SourceData)))
                    {
                        for (uint y = 0; y < Height; y++)
                            for (uint x = 0; x < Width; x++)
                                colors.Add(reader.ReadByte());
                    }
                    break;
                case SurfacePixelFormat.PFID_P8: // Indexed
                    using (BinaryReader reader = new BinaryReader(new MemoryStream(SourceData)))
                    {
                        for (uint y = 0; y < Height; y++)
                            for (uint x = 0; x < Width; x++)
                                colors.Add(reader.ReadByte());
                    }
                    break;
                case SurfacePixelFormat.PFID_R5G6B5: // 16-bit RGB
                    using (BinaryReader reader = new BinaryReader(new MemoryStream(SourceData)))
                    {
                        for (uint y = 0; y < Height; y++)
                            for (uint x = 0; x < Width; x++)
                            {
                                ushort val = reader.ReadUInt16();
                                List<int> color = get565RGB(val);
                                colors.Add(color[0]); // Red
                                colors.Add(color[1]); // Green
                                colors.Add(color[2]); // Blue
                            }
                    }
                    break;
                case SurfacePixelFormat.PFID_A4R4G4B4:
                    using (BinaryReader reader = new BinaryReader(new MemoryStream(SourceData)))
                    {
                        for (uint y = 0; y < Height; y++)
                            for (uint x = 0; x < Width; x++)
                            {
                                ushort val = reader.ReadUInt16();
                                int alpha = (val >> 12) / 0xF * 255;
                                int red = (val >> 8 & 0xF) / 0xF * 255;
                                int green = (val >> 4 & 0xF) / 0xF * 255;
                                int blue = (val & 0xF) / 0xF * 255;

                                colors.Add(alpha);
                                colors.Add(red);
                                colors.Add(green);
                                colors.Add(blue);
                            }
                    }
                    break;
                default:
                    Console.WriteLine("Unhandled SurfacePixelFormat (" + Format.ToString() + ") in RenderSurface " + Id.ToString("X8"));
                    break;
            }

            return colors;
        }

19 Source : BinaryReaderExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static uint ReadCompressedUInt32(this BinaryReader reader)
        {
            var b0 = reader.ReadByte();
            if ((b0 & 0x80) == 0)
                return b0;

            var b1 = reader.ReadByte();
            if ((b0 & 0x40) == 0)
                return (uint)(((b0 & 0x7F) << 8) | b1);

            var s = reader.ReadUInt16();
            return (uint)(((((b0 & 0x3F) << 8) | b1) << 16) | s);
        }

19 Source : BinaryReaderExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static uint ReadAsDataIDOfKnownType(this BinaryReader reader, uint knownType)
        {
            var value = reader.ReadUInt16();

            if ((value & 0x8000) != 0)
            {
                var lower = reader.ReadUInt16();
                var higher = (value & 0x3FFF) << 16;

                return (uint)(knownType + (higher | lower));
            }

            return (knownType + value);
        }

19 Source : BinaryReaderExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static string ReadPString(this BinaryReader reader, uint sizeOfLength = 2)
        {
            int stringlength;
            switch (sizeOfLength)
            {
                case 1:
                    stringlength = reader.ReadByte();
                    break;
                case 2:
                default:
                    stringlength = reader.ReadUInt16();
                    break;
            }

            byte[] thestring = reader.ReadBytes(stringlength);

            return System.Text.Encoding.Default.GetString(thestring);
        }

19 Source : BinaryReaderExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static string ReadUnicodeString(this BinaryReader reader)
        {
            uint stringLength = reader.ReadCompressedUInt32();
            string thestring = "";
            for (int i = 0; i < stringLength; i++)
            {
                ushort myChar = reader.ReadUInt16();
                thestring += Convert.ToChar(myChar);
            }
            return thestring;
        }

19 Source : DxtUtil.cs
with GNU Affero General Public License v3.0
from ACEmulator

private static void DecompressDxt1Block(BinaryReader imageReader, int x, int y, int blockCountX, int width, int height, byte[] imageData)
        {
            ushort c0 = imageReader.ReadUInt16();
            ushort c1 = imageReader.ReadUInt16();

            byte r0, g0, b0;
            byte r1, g1, b1;
            ConvertRgb565ToRgb888(c0, out r0, out g0, out b0);
            ConvertRgb565ToRgb888(c1, out r1, out g1, out b1);

            uint lookupTable = imageReader.ReadUInt32();

            for (int blockY = 0; blockY < 4; blockY++)
            {
                for (int blockX = 0; blockX < 4; blockX++)
                {
                    byte r = 0, g = 0, b = 0, a = 255;
                    uint index = (lookupTable >> 2 * (4 * blockY + blockX)) & 0x03;

                    if (c0 > c1)
                    {
                        switch (index)
                        {
                            case 0:
                                r = r0;
                                g = g0;
                                b = b0;
                                break;
                            case 1:
                                r = r1;
                                g = g1;
                                b = b1;
                                break;
                            case 2:
                                r = (byte)((2 * r0 + r1) / 3);
                                g = (byte)((2 * g0 + g1) / 3);
                                b = (byte)((2 * b0 + b1) / 3);
                                break;
                            case 3:
                                r = (byte)((r0 + 2 * r1) / 3);
                                g = (byte)((g0 + 2 * g1) / 3);
                                b = (byte)((b0 + 2 * b1) / 3);
                                break;
                        }
                    }
                    else
                    {
                        switch (index)
                        {
                            case 0:
                                r = r0;
                                g = g0;
                                b = b0;
                                break;
                            case 1:
                                r = r1;
                                g = g1;
                                b = b1;
                                break;
                            case 2:
                                r = (byte)((r0 + r1) / 2);
                                g = (byte)((g0 + g1) / 2);
                                b = (byte)((b0 + b1) / 2);
                                break;
                            case 3:
                                r = 0;
                                g = 0;
                                b = 0;
                                a = 0;
                                break;
                        }
                    }

                    int px = (x << 2) + blockX;
                    int py = (y << 2) + blockY;
                    if ((px < width) && (py < height))
                    {
                        int offset = ((py * width) + px) << 2;
                        imageData[offset] = r;
                        imageData[offset + 1] = g;
                        imageData[offset + 2] = b;
                        imageData[offset + 3] = a;
                    }
                }
            }
        }

19 Source : DxtUtil.cs
with GNU Affero General Public License v3.0
from ACEmulator

private static void DecompressDxt3Block(BinaryReader imageReader, int x, int y, int blockCountX, int width, int height, byte[] imageData)
        {
            byte a0 = imageReader.ReadByte();
            byte a1 = imageReader.ReadByte();
            byte a2 = imageReader.ReadByte();
            byte a3 = imageReader.ReadByte();
            byte a4 = imageReader.ReadByte();
            byte a5 = imageReader.ReadByte();
            byte a6 = imageReader.ReadByte();
            byte a7 = imageReader.ReadByte();

            ushort c0 = imageReader.ReadUInt16();
            ushort c1 = imageReader.ReadUInt16();

            byte r0, g0, b0;
            byte r1, g1, b1;
            ConvertRgb565ToRgb888(c0, out r0, out g0, out b0);
            ConvertRgb565ToRgb888(c1, out r1, out g1, out b1);

            uint lookupTable = imageReader.ReadUInt32();

            int alphaIndex = 0;
            for (int blockY = 0; blockY < 4; blockY++)
            {
                for (int blockX = 0; blockX < 4; blockX++)
                {
                    byte r = 0, g = 0, b = 0, a = 0;

                    uint index = (lookupTable >> 2 * (4 * blockY + blockX)) & 0x03;

                    switch (alphaIndex)
                    {
                        case 0:
                            a = (byte)((a0 & 0x0F) | ((a0 & 0x0F) << 4));
                            break;
                        case 1:
                            a = (byte)((a0 & 0xF0) | ((a0 & 0xF0) >> 4));
                            break;
                        case 2:
                            a = (byte)((a1 & 0x0F) | ((a1 & 0x0F) << 4));
                            break;
                        case 3:
                            a = (byte)((a1 & 0xF0) | ((a1 & 0xF0) >> 4));
                            break;
                        case 4:
                            a = (byte)((a2 & 0x0F) | ((a2 & 0x0F) << 4));
                            break;
                        case 5:
                            a = (byte)((a2 & 0xF0) | ((a2 & 0xF0) >> 4));
                            break;
                        case 6:
                            a = (byte)((a3 & 0x0F) | ((a3 & 0x0F) << 4));
                            break;
                        case 7:
                            a = (byte)((a3 & 0xF0) | ((a3 & 0xF0) >> 4));
                            break;
                        case 8:
                            a = (byte)((a4 & 0x0F) | ((a4 & 0x0F) << 4));
                            break;
                        case 9:
                            a = (byte)((a4 & 0xF0) | ((a4 & 0xF0) >> 4));
                            break;
                        case 10:
                            a = (byte)((a5 & 0x0F) | ((a5 & 0x0F) << 4));
                            break;
                        case 11:
                            a = (byte)((a5 & 0xF0) | ((a5 & 0xF0) >> 4));
                            break;
                        case 12:
                            a = (byte)((a6 & 0x0F) | ((a6 & 0x0F) << 4));
                            break;
                        case 13:
                            a = (byte)((a6 & 0xF0) | ((a6 & 0xF0) >> 4));
                            break;
                        case 14:
                            a = (byte)((a7 & 0x0F) | ((a7 & 0x0F) << 4));
                            break;
                        case 15:
                            a = (byte)((a7 & 0xF0) | ((a7 & 0xF0) >> 4));
                            break;
                    }
                    ++alphaIndex;

                    switch (index)
                    {
                        case 0:
                            r = r0;
                            g = g0;
                            b = b0;
                            break;
                        case 1:
                            r = r1;
                            g = g1;
                            b = b1;
                            break;
                        case 2:
                            r = (byte)((2 * r0 + r1) / 3);
                            g = (byte)((2 * g0 + g1) / 3);
                            b = (byte)((2 * b0 + b1) / 3);
                            break;
                        case 3:
                            r = (byte)((r0 + 2 * r1) / 3);
                            g = (byte)((g0 + 2 * g1) / 3);
                            b = (byte)((b0 + 2 * b1) / 3);
                            break;
                    }

                    int px = (x << 2) + blockX;
                    int py = (y << 2) + blockY;
                    if ((px < width) && (py < height))
                    {
                        int offset = ((py * width) + px) << 2;
                        imageData[offset] = r;
                        imageData[offset + 1] = g;
                        imageData[offset + 2] = b;
                        imageData[offset + 3] = a;
                    }
                }
            }
        }

19 Source : UnpackableExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static void UnpackPackedHashTable(this Dictionary<uint, uint> value, BinaryReader reader)
        {
            var totalObjects = reader.ReadUInt16();
            /*var bucketSize = */
            reader.ReadUInt16();

            for (int i = 0; i < totalObjects; i++)
                value.Add(reader.ReadUInt32(), reader.ReadUInt32());
        }

19 Source : UnpackableExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static void UnpackPackedHashTable<T>(this Dictionary<uint, T> value, BinaryReader reader) where T : IUnpackable, new()
        {
            var totalObjects = reader.ReadUInt16();
            /*var bucketSize = */reader.ReadUInt16();

            for (int i = 0; i < totalObjects; i++)
            {
                var key = reader.ReadUInt32();

                var item = new T();
                item.Unpack(reader);
                value.Add(key, item);
            }
        }

19 Source : UnpackableExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static void UnpackPackedHashTable<T>(this SortedDictionary<uint, T> value, BinaryReader reader) where T : IUnpackable, new()
        {
            var totalObjects = reader.ReadUInt16();
            /*var bucketSize = */
            reader.ReadUInt16();

            for (int i = 0; i < totalObjects; i++)
            {
                var key = reader.ReadUInt32();

                var item = new T();
                item.Unpack(reader);
                value.Add(key, item);
            }
        }

19 Source : SWVertex.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void Unpack(BinaryReader reader)
        {
            var numUVs = reader.ReadUInt16();
            UVs = new List<Vec2Duv>(numUVs);

            Origin = reader.ReadVector3();
            Normal = reader.ReadVector3();

            UVs.Unpack(reader, numUVs);
        }

19 Source : TabooTableEntry.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void Unpack(BinaryReader reader)
        {
            Unknown1 = reader.ReadUInt32();
            Unknown2 = reader.ReadUInt16();

            uint count = reader.ReadUInt32();

            for (int i = 0; i < count; i++)
                BannedPatterns.Add(reader.ReadString());
        }

19 Source : ChatPoseTable.cs
with GNU Affero General Public License v3.0
from ACEmulator

public override void Unpack(BinaryReader reader)
        {
            Id = reader.ReadUInt32();

            var totalObjects = reader.ReadUInt16();
            reader.ReadUInt16(); // var bucketSize
            for (int i = 0; i < totalObjects; i++)
            {
                string key = reader.ReadPString(); reader.AlignBoundary();
                string value = reader.ReadPString(); reader.AlignBoundary();
                ChatPoseHash.Add(key, value);
            }

            var totalEmoteObjects = reader.ReadUInt16();
            reader.ReadUInt16();// var bucketSize
            for (int i = 0; i < totalEmoteObjects; i++)
            {
                string key = reader.ReadPString(); reader.AlignBoundary();
                ChatEmoteData value = new ChatEmoteData();
                value.Unpack(reader);
                ChatEmoteHash.Add(key, value);
            }
        }

19 Source : LandblockInfo.cs
with GNU Affero General Public License v3.0
from ACEmulator

public override void Unpack(BinaryReader reader)
        {
            Id = reader.ReadUInt32();

            NumCells = reader.ReadUInt32();

            Objects.Unpack(reader);

            ushort numBuildings = reader.ReadUInt16();
            PackMask = reader.ReadUInt16();

            Buildings.Unpack(reader, numBuildings);

            if ((PackMask & 1) == 1)
                RestrictionTables.UnpackPackedHashTable(reader);
        }

19 Source : BSPPortal.cs
with GNU Affero General Public License v3.0
from ACEmulator

public override void Unpack(BinaryReader reader, BSPType treeType)
        {
            Type = Encoding.ASCII.GetString(reader.ReadBytes(4)).Reverse();

            SplittingPlane = new Plane();
            SplittingPlane.Unpack(reader);

            PosNode = BSPNode.ReadNode(reader, treeType);
            NegNode = BSPNode.ReadNode(reader, treeType);

            if (treeType == BSPType.Drawing)
            {
                Sphere = new Sphere();
                Sphere.Unpack(reader);

                var numPolys = reader.ReadUInt32();
                var numPortals = reader.ReadUInt32();

                InPolys = new List<ushort>();
                for (uint i = 0; i < numPolys; i++)
                    InPolys.Add(reader.ReadUInt16());

                InPortals.Unpack(reader, numPortals);
            }
        }

19 Source : BinaryReaderExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static string ReadObfuscatedString(this BinaryReader reader)
        {
            int stringlength = reader.ReadUInt16();

            byte[] thestring = reader.ReadBytes(stringlength);

            for (var i = 0; i < stringlength; i++)
                // flip the bytes in the string to undo the obfuscation: i.e. 0xAB => 0xBA
                thestring[i] = (byte)((thestring[i] >> 4) | (thestring[i] << 4));

            return System.Text.Encoding.GetEncoding(1252).GetString(thestring);
        }

19 Source : DxtUtil.cs
with GNU Affero General Public License v3.0
from ACEmulator

private static void DecompressDxt5Block(BinaryReader imageReader, int x, int y, int blockCountX, int width, int height, byte[] imageData)
        {
            byte alpha0 = imageReader.ReadByte();
            byte alpha1 = imageReader.ReadByte();

            ulong alphaMask = (ulong)imageReader.ReadByte();
            alphaMask += (ulong)imageReader.ReadByte() << 8;
            alphaMask += (ulong)imageReader.ReadByte() << 16;
            alphaMask += (ulong)imageReader.ReadByte() << 24;
            alphaMask += (ulong)imageReader.ReadByte() << 32;
            alphaMask += (ulong)imageReader.ReadByte() << 40;

            ushort c0 = imageReader.ReadUInt16();
            ushort c1 = imageReader.ReadUInt16();

            byte r0, g0, b0;
            byte r1, g1, b1;
            ConvertRgb565ToRgb888(c0, out r0, out g0, out b0);
            ConvertRgb565ToRgb888(c1, out r1, out g1, out b1);

            uint lookupTable = imageReader.ReadUInt32();

            for (int blockY = 0; blockY < 4; blockY++)
            {
                for (int blockX = 0; blockX < 4; blockX++)
                {
                    byte r = 0, g = 0, b = 0, a = 255;
                    uint index = (lookupTable >> 2 * (4 * blockY + blockX)) & 0x03;

                    uint alphaIndex = (uint)((alphaMask >> 3 * (4 * blockY + blockX)) & 0x07);
                    if (alphaIndex == 0)
                    {
                        a = alpha0;
                    }
                    else if (alphaIndex == 1)
                    {
                        a = alpha1;
                    }
                    else if (alpha0 > alpha1)
                    {
                        a = (byte)(((8 - alphaIndex) * alpha0 + (alphaIndex - 1) * alpha1) / 7);
                    }
                    else if (alphaIndex == 6)
                    {
                        a = 0;
                    }
                    else if (alphaIndex == 7)
                    {
                        a = 0xff;
                    }
                    else
                    {
                        a = (byte)(((6 - alphaIndex) * alpha0 + (alphaIndex - 1) * alpha1) / 5);
                    }

                    switch (index)
                    {
                        case 0:
                            r = r0;
                            g = g0;
                            b = b0;
                            break;
                        case 1:
                            r = r1;
                            g = g1;
                            b = b1;
                            break;
                        case 2:
                            r = (byte)((2 * r0 + r1) / 3);
                            g = (byte)((2 * g0 + g1) / 3);
                            b = (byte)((2 * b0 + b1) / 3);
                            break;
                        case 3:
                            r = (byte)((r0 + 2 * r1) / 3);
                            g = (byte)((g0 + 2 * g1) / 3);
                            b = (byte)((b0 + 2 * b1) / 3);
                            break;
                    }

                    int px = (x << 2) + blockX;
                    int py = (y << 2) + blockY;
                    if ((px < width) && (py < height))
                    {
                        int offset = ((py * width) + px) << 2;
                        imageData[offset] = r;
                        imageData[offset + 1] = g;
                        imageData[offset + 2] = b;
                        imageData[offset + 3] = a;
                    }
                }
            }
        }

19 Source : UnpackableExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static void UnpackSmartArray<T>(this Dictionary<ushort, T> value, BinaryReader reader) where T : IUnpackable, new()
        {
            var totalObjects = reader.ReadCompressedUInt32();

            for (int i = 0; i < totalObjects; i++)
            {
                var key = reader.ReadUInt16();

                var item = new T();
                item.Unpack(reader);
                value.Add(key, item);
            }
        }

19 Source : UnpackableExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static void Unpack<T>(this Dictionary<ushort, T> value, BinaryReader reader, uint fixedQuanreplacedy) where T : IUnpackable, new()
        {
            for (int i = 0; i < fixedQuanreplacedy; i++)
            {
                var key = reader.ReadUInt16();

                var item = new T();
                item.Unpack(reader);
                value.Add(key, item);
            }
        }

19 Source : LanguageInfo.cs
with GNU Affero General Public License v3.0
from ACEmulator

private List<char> UnpackList(BinaryReader reader)
        {
            List<char> l = new List<char>();

            byte numElements = reader.ReadByte();
            for (int i = 0; i < numElements; i++)
            {
                ushort c = reader.ReadUInt16();
                l.Add((char)c);
            }

            return l;
        }

19 Source : SpellComponentsTable.cs
with GNU Affero General Public License v3.0
from ACEmulator

public override void Unpack(BinaryReader reader)
        {
            Id = reader.ReadUInt32();

            uint numComps = reader.ReadUInt16(); // Should be 163 or 0xA3
            reader.AlignBoundary();

            SpellComponents.Unpack(reader, numComps);
        }

19 Source : PacketFragmentHeader.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void Unpack(BinaryReader reader)
        {
            Sequence    = reader.ReadUInt32();
            Id          = reader.ReadUInt32();
            Count       = reader.ReadUInt16();
            Size        = reader.ReadUInt16();
            Index       = reader.ReadUInt16();
            Queue       = reader.ReadUInt16();
        }

19 Source : PacketHeaderOptional.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void Unpack(BinaryReader reader, PacketHeader header)
        {
            Header = header;
            Size = (uint)reader.BaseStream.Position;
            BinaryWriter writer = new BinaryWriter(headerBytes);

            if (header.HasFlag(PacketHeaderFlags.ServerSwitch)) // 0x100
            {
                writer.Write(reader.ReadBytes(8));
            }

            if (header.HasFlag(PacketHeaderFlags.RequestRetransmit)) // 0x1000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
                uint retransmitCount = reader.ReadUInt32();
                writer.Write(retransmitCount);
                RetransmitData = new List<uint>();
                for (uint i = 0u; i < retransmitCount; i++)
                {
                    if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
                    uint sequence = reader.ReadUInt32();
                    writer.Write(sequence);
                    RetransmitData.Add(sequence);
                }
            }

            if (header.HasFlag(PacketHeaderFlags.RejectRetransmit)) // 0x2000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
                uint count = reader.ReadUInt32();
                writer.Write(count);
                for (int i = 0; i < count; i++)
                {
                    if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
                    writer.Write(reader.ReadBytes(4));
                }
            }

            if (header.HasFlag(PacketHeaderFlags.AckSequence)) // 0x4000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
                AckSequence = reader.ReadUInt32();
                writer.Write(AckSequence);
            }

            if (header.HasFlag(PacketHeaderFlags.LoginRequest)) // 0x10000
            {
                long position = reader.BaseStream.Position;
                long length = reader.BaseStream.Length - position;
                if (length < 1) { IsValid = false; return; }
                byte[] loginBytes = new byte[length];
                reader.BaseStream.Read(loginBytes, (int)position, (int)length);
                writer.Write(loginBytes);
                reader.BaseStream.Position = position;
            }

            if (header.HasFlag(PacketHeaderFlags.WorldLoginRequest)) // 0x20000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 8) { IsValid = false; return; }
                long position = reader.BaseStream.Position;
                writer.Write(reader.ReadBytes(8));
                reader.BaseStream.Position = position;
            }

            if (header.HasFlag(PacketHeaderFlags.ConnectResponse)) // 0x80000
            {
                long position = reader.BaseStream.Position;
                if (reader.BaseStream.Length < reader.BaseStream.Position + 8) { IsValid = false; return; }
                writer.Write(reader.ReadBytes(8));
                reader.BaseStream.Position = position;
            }

            if (header.HasFlag(PacketHeaderFlags.CICMDCommand)) // 0x400000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 8) { IsValid = false; return; }
                writer.Write(reader.ReadBytes(8));
            }

            if (header.HasFlag(PacketHeaderFlags.TimeSync)) // 0x1000000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 8) { IsValid = false; return; }
                TimeSynch = reader.ReadDouble();
                writer.Write(TimeSynch);
            }

            if (header.HasFlag(PacketHeaderFlags.Ecreplacedquest)) // 0x2000000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
                EcreplacedquestClientTime = reader.ReadSingle();
                writer.Write(EcreplacedquestClientTime);
            }

            if (header.HasFlag(PacketHeaderFlags.Flow)) // 0x8000000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 6) { IsValid = false; return; }
                FlowBytes = reader.ReadUInt32();
                FlowInterval = reader.ReadUInt16();
                writer.Write(FlowBytes);
                writer.Write(FlowInterval);
            }

            Size = (uint)reader.BaseStream.Position - Size;
        }

19 Source : LayeredSpell.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static LayeredSpell ReadLayeredSpell(this BinaryReader reader)
        {
            var layeredSpell = new LayeredSpell();
            layeredSpell.SpellId = reader.ReadUInt16();
            layeredSpell.Layer = reader.ReadUInt16();

            return layeredSpell;
        }

19 Source : PacketHeader.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void Unpack(BinaryReader reader)
        {
            Sequence    = reader.ReadUInt32();
            Flags       = (PacketHeaderFlags)reader.ReadUInt32();
            Checksum    = reader.ReadUInt32();
            Id          = reader.ReadUInt16();
            Time        = reader.ReadUInt16();
            Size        = reader.ReadUInt16();
            Iteration   = reader.ReadUInt16();
        }

19 Source : EanAnimation.cs
with GNU General Public License v3.0
from aelariane

public void Load(BinaryReader br, FileStream fs)
    {
        this.Offset = br.ReadInt32();
        this.Offset += 16;
        this.FrameCount = br.ReadInt32();
        this.MipWidth = br.ReadInt32();
        this.MipHeight = br.ReadInt32();
        this.StartX = br.ReadInt32();
        this.StartY = br.ReadInt32();
        this.TileCount = br.ReadUInt16();
        this.TotalCount = br.ReadUInt16();
        this.CellWidth = br.ReadUInt16();
        this.CellHeight = br.ReadUInt16();
        this.Frames = new EanFrame[(int)this.TotalCount];
        long position = fs.Position;
        fs.Seek((long)this.Offset, SeekOrigin.Begin);
        for (int i = 0; i < (int)this.TotalCount; i++)
        {
            this.Frames[i].X = br.ReadUInt16();
            this.Frames[i].Y = br.ReadUInt16();
            this.Frames[i].Width = br.ReadUInt16();
            this.Frames[i].Height = br.ReadUInt16();
        }
        fs.Seek(position, SeekOrigin.Begin);
    }

19 Source : Pack.cs
with Apache License 2.0
from aequabit

public object[] Deserialize(byte[] data)
    {
        MemoryStream Stream = new MemoryStream(data);
        BinaryReader Reader = new BinaryReader(Stream, Encoding.UTF8);
        List<object> Items = new List<object>();
        byte Current = 0;
        byte Count = Reader.ReadByte();

        for (int I = 0; I <= Count - 1; I++)
        {
            Current = Reader.ReadByte();

            switch (Current)
            {
                case 0:
                    Items.Add(Reader.ReadBoolean());
                    break;
                case 1:
                    Items.Add(Reader.ReadByte());
                    break;
                case 2:
                    Items.Add(Reader.ReadBytes(Reader.ReadInt32()));
                    break;
                case 3:
                    Items.Add(Reader.ReadChar());
                    break;
                case 4:
                    Items.Add(Reader.ReadString().ToCharArray());
                    break;
                case 5:
                    Items.Add(Reader.ReadDecimal());
                    break;
                case 6:
                    Items.Add(Reader.ReadDouble());
                    break;
                case 7:
                    Items.Add(Reader.ReadInt32());
                    break;
                case 8:
                    Items.Add(Reader.ReadInt64());
                    break;
                case 9:
                    Items.Add(Reader.ReadSByte());
                    break;
                case 10:
                    Items.Add(Reader.ReadInt16());
                    break;
                case 11:
                    Items.Add(Reader.ReadSingle());
                    break;
                case 12:
                    Items.Add(Reader.ReadString());
                    break;
                case 13:
                    Items.Add(Reader.ReadUInt32());
                    break;
                case 14:
                    Items.Add(Reader.ReadUInt64());
                    break;
                case 15:
                    Items.Add(Reader.ReadUInt16());
                    break;
                case 16:
                    Items.Add(DateTime.FromBinary(Reader.ReadInt64()));
                    break;
            }
        }

        Reader.Close();
        return Items.ToArray();
    }

19 Source : WaveHeader.cs
with GNU General Public License v3.0
from ahmed605

public virtual void Read(BinaryReader br)
        {
            RiffChunkID = br.ReadInt32();
            RiffChunkSize = br.ReadInt32();
            Format = br.ReadInt32();

            FmtChunkID = br.ReadInt32();
            FmtChunkSize = br.ReadInt32();
            AudioFormat = br.ReadUInt16();
            NumChannels = br.ReadInt16();
            SampleRate = br.ReadInt32();
            ByteRate = br.ReadInt32();
            BlockAlign = br.ReadInt16();
            BitsPerSample = br.ReadInt16();

            if (AudioFormat == WaveFormatExtensible)
            {
                ExtraDataSize = br.ReadInt16();
                ValidBitsPerSample = br.ReadInt16();
                AvailableChannelMask = (ChannelMask) br.ReadInt32();
                FormatGuid[0] = br.ReadUInt32();
                FormatGuid[1] = br.ReadUInt32();
                FormatGuid[2] = br.ReadUInt32();
                FormatGuid[3] = br.ReadUInt32();
            }

            DataChunkID = br.ReadInt32();
            DataChunkSize = br.ReadInt32();
        }

19 Source : ResourceHeader.cs
with GNU General Public License v3.0
from ahmed605

public void Read(BinaryReader br)
        {
            Magic = br.ReadUInt32();
            Type = (ResourceType) br.ReadUInt32();
            Flags = br.ReadUInt32();
            CompressCodec = (CompressionType)br.ReadUInt16();

            if (Magic == MagicBigEndian)
            {
                Magic = DataUtil.SwapEndian(Magic);
                Type = (ResourceType)DataUtil.SwapEndian((uint)Type);
                Flags = DataUtil.SwapEndian(Flags);
            }
        }

19 Source : PtrCollection.cs
with GNU General Public License v3.0
from ahmed605

public void Read(BinaryReader br)
        {
            var ptrListOffset = ResourceUtil.ReadOffset(br);
            Count = br.ReadUInt16();
            Size = br.ReadUInt16();

            _itemOffsets = new uint[Count];
            _items = new List<T>();

            using (new StreamContext(br))
            {
                br.BaseStream.Seek(ptrListOffset, SeekOrigin.Begin);

                for (int i = 0; i < Count; i++)
                {
                    _itemOffsets[i] = ResourceUtil.ReadOffset(br);
                }

                for (int i = 0; i < Count; i++)
                {
                    br.BaseStream.Seek(_itemOffsets[i], SeekOrigin.Begin);
                    var item = new T();
                    item.Read(br);
                    _items.Add(item);
                }
            }
        }

19 Source : SimpleCollection.cs
with GNU General Public License v3.0
from ahmed605

public void Read(BinaryReader br)
        {
            var offset = ResourceUtil.ReadOffset(br);

            Count = br.ReadUInt16();
            Size = br.ReadUInt16();

            Values = new List<T>(Count);

            using (new StreamContext(br))
            {
                br.BaseStream.Seek(offset, SeekOrigin.Begin);

                for (int i = 0; i < Count; i++)
                {
                    Values.Add(ReadData(br));
                }
            }
        }

19 Source : Geometry.cs
with GNU General Public License v3.0
from ahmed605

public new void Read(BinaryReader br)
        {
            base.Read(br);

            Unknown1 = br.ReadUInt32();
            Unknown2 = br.ReadUInt32();

            var vertexBuffersOffset = ResourceUtil.ReadOffset(br);
            Unknown3 = br.ReadUInt32();
            Unknown4 = br.ReadUInt32();
            Unknown5 = br.ReadUInt32();

            var indexBuffersOffset = ResourceUtil.ReadOffset(br);
            Unknown6 = br.ReadUInt32();
            Unknown7 = br.ReadUInt32();
            Unknown8 = br.ReadUInt32();

            IndexCount = br.ReadUInt32();
            FaceCount = br.ReadUInt32();
            VertexCount = br.ReadUInt16();
            PrimitiveType = br.ReadUInt16();

            Unknown9 = br.ReadUInt32();

            VertexStride = br.ReadUInt16();
            Unknown10 = br.ReadUInt16();

            Unknown11 = br.ReadUInt32();
            Unknown12 = br.ReadUInt32();
            Unknown13 = br.ReadUInt32();

            // Data

            br.BaseStream.Seek(vertexBuffersOffset, SeekOrigin.Begin);
            VertexBuffer = new VertexBuffer(br);

            br.BaseStream.Seek(indexBuffersOffset, SeekOrigin.Begin);
            IndexBuffer = new IndexBuffer(br);
        }

19 Source : Model.cs
with GNU General Public License v3.0
from ahmed605

public new void Read(BinaryReader br)
        {
            base.Read(br);

            Geometries = new PtrCollection<Geometry>(br);

            var unknownVectorOffsets = ResourceUtil.ReadOffset(br);
            var materialMappingOffset = ResourceUtil.ReadOffset(br);

            Unknown1 = br.ReadUInt16();
            Unknown2 = br.ReadUInt16();

            Unknown3 = br.ReadUInt16();
            Unknown4 = br.ReadUInt16();

            //

            br.BaseStream.Seek(unknownVectorOffsets, SeekOrigin.Begin);
            UnknownVectors = new SimpleArray<Vector4>(br, 4, reader => new Vector4(reader));

            br.BaseStream.Seek(materialMappingOffset, SeekOrigin.Begin);
            ShaderMappings = new SimpleArray<ushort>(br, Geometries.Count, reader => reader.ReadUInt16());
        }

19 Source : VertexBuffer.cs
with GNU General Public License v3.0
from ahmed605

public new void Read(BinaryReader br)
        {
            base.Read(br);

            VertexCount = br.ReadUInt16();
            Unknown1 = br.ReadUInt16();

            DataOffset = ResourceUtil.ReadDataOffset(br);

            StrideSize = br.ReadUInt32();

            var vertexDeclOffset = ResourceUtil.ReadOffset(br);

            Unknown2 = br.ReadUInt32();

            DataOffset2 = ResourceUtil.ReadDataOffset(br);

            var p2Offset = ResourceUtil.ReadOffset(br); // null

            //

            br.BaseStream.Seek(vertexDeclOffset, SeekOrigin.Begin);
            VertexDeclaration = new VertexDeclaration(br);
        }

See More Examples