ReadUInt16() private method

private ReadUInt16 ( ) : ushort
return ushort
Example #1
1
        public RespawnInfo(BinaryReader reader, int Version, int Customversion)
        {
            MonsterIndex = reader.ReadInt32();

            Location = new Point(reader.ReadInt32(), reader.ReadInt32());

            Count = reader.ReadUInt16();
            Spread = reader.ReadUInt16();

            Delay = reader.ReadUInt16();
            Direction = reader.ReadByte();

            if (Envir.LoadVersion >= 36)
            {
                RoutePath = reader.ReadString();
            }

            if (Version > 67)
            {
                RandomDelay = reader.ReadUInt16();
                RespawnIndex = reader.ReadInt32();
                SaveRespawnTime = reader.ReadBoolean();
                RespawnTicks = reader.ReadUInt16();
            }
            else
            {
                RespawnIndex = ++SMain.Envir.RespawnIndex;
            }
        }
 public FaceGroup(BinaryReader reader)
 {
     Min = new Vector3(reader);
     Max = new Vector3(reader);
     StartFace = reader.ReadUInt16();
     EndFace = reader.ReadUInt16();
 }
Example #3
0
        protected override void check(object sender, EventArgs e) {
            int read_width = 0;
            int read_height = 0;
            int read_cwidth = 0;
            int read_cheight = 0;
            int read_quality = 0;
            int read_samples = 0;

            using (Stream stream = new FileStream(outPath, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                using (BinaryReader reader = new BinaryReader(stream, Encoding.Default)) {
                    read_width = reader.ReadUInt16();
                    read_height = reader.ReadUInt16();
                    read_cwidth = reader.ReadUInt16();
                    read_cheight = reader.ReadUInt16();
                    read_quality = reader.ReadByte();
                    read_samples = reader.ReadByte();
                }
            }

            System.Windows.Forms.MessageBox.Show(
                "image width: " + inC1.imageWidth + " = " + read_width +
                "\nimage height: " + inC1.imageHeight + " = " + read_height +
                "\nchannel width: " + inC1.channelWidth + " = " + read_cwidth +
                "\nchannel height: " + inC1.channelHeight + " = " + read_cheight +
                "\nquality: " + inC1.quantizeQuality + " = " + read_quality +
                "\nsamples: " + inC1.samplingMode + " = " + (DataBlob.Samples)read_samples
                , "File Information");
        }
Example #4
0
        public async Task<ImageInfo[]> LoadFromDbAsync(string dbFileName)
        {
            var file = await FileSystem.Current.GetFileFromPathAsync(dbFileName).ConfigureAwait(false);
            if (file == null)
                throw new FileNotFoundException();
            using (var fs = await file.OpenAsync(FileAccess.Read).ConfigureAwait(false))
            using (var gz = new GZipStream(fs, CompressionMode.Decompress))
            using (var br = new BinaryReader(gz))
            {
                long count = br.ReadInt32();
                _info = new ImageInfo[count];

                for (var i = 0; i < count; i++)
                {
                    var hash = br.ReadUInt64();
                    var titleId = br.ReadUInt16();
                    var episodeId = br.ReadUInt16();
                    var frame = br.ReadUInt32();
                    _info[i] = new ImageInfo
                    {
                        Hash = hash,
                        TitleId = titleId,
                        EpisodeId = episodeId,
                        Frame = frame
                    };
                }
            }
            return _info;
        }
Example #5
0
 /// <summary>
 /// Initialize an instance of this structure by reading it from the given <see cref="BinaryReader"/>.
 /// </summary>
 /// <param name="reader">The <see cref="BinaryReader"/> to read the structure from.</param>
 internal RWTriangle(BinaryReader reader)
 {
     C = reader.ReadUInt16();
     B = reader.ReadUInt16();
     MatID = reader.ReadInt16();
     A = reader.ReadUInt16();
 }
Example #6
0
        public InstallShieldPackage(string filename, int priority)
        {
            this.priority = priority;
            s = FileSystem.Open(filename);

            // Parse package header
            BinaryReader reader = new BinaryReader(s);
            uint signature = reader.ReadUInt32();
            if (signature != 0x8C655D13)
                throw new InvalidDataException("Not an Installshield package");

            reader.ReadBytes(8);
            /*var FileCount = */reader.ReadUInt16();
            reader.ReadBytes(4);
            /*var ArchiveSize = */reader.ReadUInt32();
            reader.ReadBytes(19);
            var TOCAddress = reader.ReadInt32();
            reader.ReadBytes(4);
            var DirCount = reader.ReadUInt16();

            // Parse the directory list
            s.Seek(TOCAddress, SeekOrigin.Begin);
            BinaryReader TOCreader = new BinaryReader(s);
            for (var i = 0; i < DirCount; i++)
                ParseDirectory(TOCreader);
        }
Example #7
0
        public MixFile(string filename, int priority)
        {
            this.priority = priority;
            s = FileSystem.Open(filename);

            // Detect format type
            s.Seek(0, SeekOrigin.Begin);
            var reader = new BinaryReader(s);
            var isCncMix = reader.ReadUInt16() != 0;

            // The C&C mix format doesn't contain any flags or encryption
            var isEncrypted = false;
            if (!isCncMix)
                isEncrypted = (reader.ReadUInt16() & 0x2) != 0;

            List<PackageEntry> entries;
            if (isEncrypted)
            {
                long unused;
                entries = ParseHeader(DecryptHeader(s, 4, out dataStart), 0, out unused);
            }
            else
                entries = ParseHeader(s, isCncMix ? 0 : 4, out dataStart);

            index = entries.ToDictionaryWithConflictLog(x => x.Hash,
                "{0} ({1} format, Encrypted: {2}, DataStart: {3})".F(filename, (isCncMix ? "C&C" : "RA/TS/RA2"), isEncrypted, dataStart),
                null, x => "(offs={0}, len={1})".F(x.Offset, x.Length)
            );
        }
Example #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        public void Parse(Stream input)
        {
            BinaryReader br = new BinaryReader(input);

            _FrameSize = new Rect(this.Version);
            _FrameSize.Parse(input);

            _FrameRateDelay = br.ReadUInt16();
            _FrameRate = (_FrameRateDelay >> 8) + ((_FrameRateDelay & 0xFF) / 100);
            _FrameCount = br.ReadUInt16();

            int x = Math.Abs((this._FrameSize.Xmax - this._FrameSize.Xmin) / 12);
            int y = Math.Abs((this._FrameSize.Ymax - this._FrameSize.Ymin) / 12);

            if (x > SwfFile.Configuration.MaximumStageSizeX)
            {
                Log.Warn(this, "The x value(" + x + ") of the stage exceeds the allowed maximum.");
            }

            if (x < SwfFile.Configuration.MinimumStageSizeX)
            {
                Log.Warn(this, "The x value(" + x + ") of the stage under-runs the allowed minimum.");
            }

            if (y > SwfFile.Configuration.MaximumStageSizeY)
            {
                Log.Warn(this, "The y value(" + y + ") of the stage exceeds the allowed maximum.");
            }
            if (y < SwfFile.Configuration.MinimumStageSizeY)
            {
                Log.Warn(this, "The y value(" + y + ") of the stage under-runs the allowed minimum.");
            }
        }
Example #9
0
 public PosTbl(Stream si)
 {
     var binaryReader = new BinaryReader(si);
     int num = tbloff - 144;
     si.Position = num + 160;
     va0 = binaryReader.ReadUInt16();
     va2 = binaryReader.ReadUInt16();
     si.Position = num + 168;
     va8 = binaryReader.ReadInt32();
     vac = binaryReader.ReadInt32();
     si.Position = num + 176;
     vb0 = binaryReader.ReadInt32();
     vb4 = binaryReader.ReadInt32();
     vb8 = binaryReader.ReadInt32();
     si.Position = num + 192;
     vc0 = binaryReader.ReadInt32();
     vc4 = binaryReader.ReadInt32();
     vc8 = binaryReader.ReadInt32();
     vcc = binaryReader.ReadInt32();
     si.Position = num + 208;
     vd0 = binaryReader.ReadInt32();
     vd4 = binaryReader.ReadInt32();
     vd8 = binaryReader.ReadInt32();
     vdc = binaryReader.ReadInt32();
     si.Position = num + 224;
     ve0 = binaryReader.ReadInt32();
     ve4 = binaryReader.ReadInt32();
     ve8 = binaryReader.ReadInt32();
     vec = binaryReader.ReadInt32();
     si.Position = num + 240;
     vf0 = binaryReader.ReadInt32();
     vf4 = binaryReader.ReadInt32();
     vf8 = binaryReader.ReadInt32();
     vfc = binaryReader.ReadInt32();
 }
Example #10
0
        public void Load(string destinationDirectory, string resourceName, BinaryReader binaryReader)
        {
            binaryReader.BaseStream.Seek(2, SeekOrigin.Current);
            uint length = binaryReader.ReadUInt32();
            byte[] imageData = binaryReader.ReadBytes((int)length);
            short xOffset = binaryReader.ReadInt16();
            short yOffset = binaryReader.ReadInt16();
            ushort width = binaryReader.ReadUInt16();
            ushort height = binaryReader.ReadUInt16();
            binaryReader.BaseStream.Seek(8, SeekOrigin.Current);

            var bmp = new Bmp(width, height);
            var colorData = bmp.Data;
            var palette = PaletteLoader.DefaultPalette;
            int index = 0;
            for (int y = 0; y < height; ++y) {
                for (int x = 0; x < width; ++x) {
                    colorData[y, x] = palette.Colors[imageData[index]];
                    ++index;
                }
            }

            bmp.Save(Path.Combine(destinationDirectory, resourceName), ImageFormat);
            Bmp.SaveOffsets(resourceName, xOffset, yOffset);
        }
Example #11
0
File: NBM.cs Project: MetLob/tinke
        public override void Read(string file)
        {
            BinaryReader br = new BinaryReader(File.OpenRead(file));
            uint file_size = (uint)br.BaseStream.Length;

            // Read header values
            ushort depth = br.ReadUInt16();
            ushort width = br.ReadUInt16();
            ushort height = br.ReadUInt16();
            ushort unknown = br.ReadUInt16();
            ColorFormat format = (depth == 0x01) ? ColorFormat.colors256 : ColorFormat.colors16;

            // Palette
            int palette_length = (depth == 0x01) ? 0x200 : 0x20;
            Color[][] colors = new Color[1][];
            colors[0] = Actions.BGR555ToColor(br.ReadBytes(palette_length));
            palette = new RawPalette(colors, false, format);

            // Tiles
            int tiles_length = width * height;
            if (depth == 0)
                tiles_length /= 2;
            Byte[] tiles = br.ReadBytes(tiles_length);

            br.Close();
            Set_Tiles(tiles, width, height, format, TileForm.Lineal, true);
        }
Example #12
0
 internal static void ReadCustomData(Player player, BinaryReader reader)
 {
     int count = reader.ReadUInt16();
     for (int k = 0; k < count; k++)
     {
         string modName = reader.ReadString();
         string name = reader.ReadString();
         byte[] data = reader.ReadBytes(reader.ReadUInt16());
         Mod mod = ModLoader.GetMod(modName);
         ModPlayer modPlayer = mod == null ? null : player.GetModPlayer(mod, name);
         if (modPlayer != null)
         {
             using (MemoryStream stream = new MemoryStream(data))
             {
                 using (BinaryReader customReader = new BinaryReader(stream))
                 {
                     modPlayer.LoadCustomData(customReader);
                 }
             }
             if (modName == "ModLoader" && name == "MysteryPlayer")
             {
                 ((MysteryPlayer)modPlayer).RestoreData(player);
             }
         }
         else
         {
             ModPlayer mystery = player.GetModPlayer(ModLoader.GetMod("ModLoader"), "MysteryPlayer");
             ((MysteryPlayer)mystery).AddData(modName, name, data);
         }
     }
 }
Example #13
0
        protected override void ReadContentFrom(BinaryReader input)
        {
            //https://www.microsoft.com/typography/otspec/cmap.htm
            long beginAt = input.BaseStream.Position;
            //
            ushort version = input.ReadUInt16(); // 0
            ushort tableCount = input.ReadUInt16();

            var entries = new CMapEntry[tableCount];
            for (int i = 0; i < tableCount; i++)
            {
                ushort platformId = input.ReadUInt16();
                ushort encodingId = input.ReadUInt16();
                uint offset = input.ReadUInt32();
                entries[i] = new CMapEntry(platformId, encodingId, offset);
            }

            charMaps = new CharacterMap[tableCount];
            for (int i = 0; i < tableCount; i++)
            {
                CMapEntry entry = entries[i];
                input.BaseStream.Seek(beginAt + entry.Offset, SeekOrigin.Begin);
                CharacterMap cmap = charMaps[i] = ReadCharacterMap(entry, input);
                cmap.PlatformId = entry.PlatformId;
                cmap.EncodingId = entry.EncodingId;
            }
        }
Example #14
0
        public OBJf(IffChunk Chunk)
            : base(Chunk)
        {
            MemoryStream MemStream = new MemoryStream(Chunk.Data);
            BinaryReader Reader = new BinaryReader(MemStream);

            //Unknown + version (always 0)
            Reader.ReadBytes(8);

            string Header = Encoding.ASCII.GetString(Reader.ReadBytes(4));

            if (Header != "fJBO")
                return; //Error? This shouldn't occur...

            m_NumEntries = Reader.ReadInt32();

            for (int i = 0; i < m_NumEntries; i++)
            {
                IDPair FuncIDs = new IDPair();
                FuncIDs.GuardFuncID = Reader.ReadUInt16();
                FuncIDs.FunctionID = Reader.ReadUInt16();

                m_FuncIDs.Add(FuncIDs);
            }
        }
Example #15
0
        public override void Read(Stream input)
        {
            BinaryReader reader = new BinaryReader(input, Encoding.Default, true);
            uint magicNumber1 = reader.ReadUInt32(); // foxf
            ushort magicNumber2 = reader.ReadUInt16(); // pk
            FpkType = (FpkType) reader.ReadByte(); // ' ' or 'd'
            byte magicNumber3 = reader.ReadByte(); // w
            ushort magicNumber4 = reader.ReadUInt16(); // in
            uint fileSize = reader.ReadUInt32();
            reader.Skip(18);
            uint magicNumber5 = reader.ReadUInt32(); // 2
            uint fileCount = reader.ReadUInt32();
            uint referenceCount = reader.ReadUInt32();
            reader.Skip(4);

            for (int i = 0; i < fileCount; i++)
            {
                Entries.Add(FpkEntry.ReadFpkEntry(input));
            }

            for (int i = 0; i < referenceCount; i++)
            {
                References.Add(FpkReference.ReadFpkReference(input));
            }
        }
Example #16
0
        public Metadata(BinaryReader reader)
        {
            magic = reader.ReadUInt32();
            if (magic != 0x424A5342)
                return;

            offset = (uint)reader.BaseStream.Position - 4;
            majorVersion = reader.ReadUInt16();
            minorVersion = reader.ReadUInt16();
            reserved = reader.ReadUInt32();
            versionString = readString(reader, reader.ReadInt32());
            flags = reader.ReadUInt16();
            int numStreams = reader.ReadUInt16();
            streams = new DotNetStream[numStreams];
            uint lastOffset = offset;
            for (int i = 0; i < numStreams; i++) {
                uint fileOffset = offset + reader.ReadUInt32();
                uint size = reader.ReadUInt32();
                string name = readAsciizString(reader);
                streams[i] = new DotNetStream(name, fileOffset, size);
                lastOffset = Math.Max(lastOffset, fileOffset + size);
            }
            lastOffset = Math.Max(lastOffset, (uint)reader.BaseStream.Position);
            length = lastOffset - offset;
            headerLength = (uint)reader.BaseStream.Position - offset;
        }
Example #17
0
		/// <summary> Creates a new glyph variant record by reading it from the specified stream. </summary>
		/// <param name="reader"> The correctly positioned stream to read from. </param>
		public GlyphVariantRecord(BinaryReader reader)
		{
			Contract.Requires(reader != null);

			Glyph = reader.ReadUInt16();
			AdvanceMeasurement = reader.ReadUInt16();
		}
Example #18
0
        /// <summary>
        /// Constructs a new <see cref="Key"/> instance.
        /// </summary>
        /// <param name="encodedText">The encoded Licence text.</param>
        public Key(String encodedText)
        {
            _encodedText = encodedText;
            try
            {
                using (BinaryReader reader = new BinaryReader(
                    new MemoryStream(Base32.Decode(encodedText))))
                {
                    // Get the Licence data from the reader.
                    LicenceId = reader.ReadInt32();
                    _startDateOffset = reader.ReadUInt16();
                    _endDateOffset = reader.ReadUInt16();
                    byte productCount = reader.ReadByte();
                    for (int i = 0; i < productCount; i++)
                    {
                        _products.Add(new Product(reader));
                    }

                    // Validate the signature that follows the Licence data.
                    _isValid = DSAVerifyHash(
                        new SHA1CryptoServiceProvider().ComputeHash(ToArray()),
                        reader.ReadBytes(reader.ReadByte()),
                        LicenceConstants.PublicKey, "SHA1");
                }
            }
            catch
            {
                _isValid = false;
            }
        }
Example #19
0
        internal NameResolutionRecord(BinaryReader reader)
        {
            UInt16 type = reader.ReadUInt16();
            int valueLength = reader.ReadUInt16();

            if (type != EndRecordType)
            {
                int entriesLength = valueLength;

                if (type == Ip6RecordType)
                {
                    this.IsIpVersion6 = true;
                    this.IpAddress = reader.ReadBytes(Ip6Length);
                    entriesLength -= Ip6Length;
                }
                else
                {
                    this.IsIpVersion6 = false;
                    this.IpAddress = reader.ReadBytes(Ip4Length);
                    entriesLength -= Ip4Length;
                }
                this.DnsEntries = this.ReadDnsEntries(reader, entriesLength);

                int remainderLength = valueLength % ValueAlignmentBoundary;
                if (remainderLength > 0)
                {
                    reader.ReadBytes(ValueAlignmentBoundary - remainderLength);		// Read fill bytes to boundary.
                }
            }
        }
        public IEnumerable<Packet> ReadPackets(string file)
        {
            using (var gr = new BinaryReader(new FileStream(file, FileMode.Open, FileAccess.Read), Encoding.ASCII))
            {
                gr.ReadBytes(3); // PKT
                gr.ReadBytes(2); // 0x02, 0x02
                gr.ReadByte(); // 0x06
                Build = gr.ReadUInt16(); // build
                gr.ReadBytes(4); // client locale
                gr.ReadBytes(20); // packet key
                gr.ReadBytes(64); // realm name

                var packets = new List<Packet>();
                while (gr.PeekChar() >= 0)
                {
                    Direction direction = gr.ReadByte() == 0xff ? Direction.Server : Direction.Client;
                    uint unixtime = gr.ReadUInt32();
                    uint tickcount = gr.ReadUInt32();
                    uint size = gr.ReadUInt32();
                    OpCodes opcode = (direction == Direction.Client) ? (OpCodes)gr.ReadUInt32() : (OpCodes)gr.ReadUInt16();
                    byte[] data = gr.ReadBytes((int)size - ((direction == Direction.Client) ? 4 : 2));

                    packets.Add(new Packet(direction, opcode, data, unixtime, tickcount));
                }
                return packets;
            }
        }
Example #21
0
        /// <summary>
        ///     Gets the name of the first model on a CGFX file.
        ///     Returns null if the file doesn't contain any model.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static string getName(MemoryStream data)
        {
            BinaryReader input = new BinaryReader(data);

            cgfxHeader header = new cgfxHeader();
            header.magic = IOUtils.readString(input, 0, 4);
            header.endian = input.ReadUInt16();
            header.length = input.ReadUInt16();
            header.revision = input.ReadUInt32();
            header.fileLength = input.ReadUInt32();
            header.entries = input.ReadUInt32();

            data.Seek(header.length + 8, SeekOrigin.Begin);
            List<dictEntry> models = getDictionary(input);

            if (models.Count > 0)
            {
                data.Seek(models[0].dataOffset + 0xc, SeekOrigin.Begin);
                string name = IOUtils.readString(input, getRelativeOffset(input));
                data.Close();
                return name;
            }
            else
            {
                data.Close();
                return null;
            }
        }
Example #22
0
        public static CpuArchitectures GetPEArchitecture(string pFilePath)
        {
            ushort architecture = 0;

            ushort[] coffHeader = new ushort[10];

            using (FileStream fStream = new FileStream(pFilePath, FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader bReader = new BinaryReader(fStream))
                {
                    if (bReader.ReadUInt16() == 23117) //check the MZ signature
                    {
                        fStream.Seek(0x3A, SeekOrigin.Current); // Go to the location of the location of the NT header
                        fStream.Seek(bReader.ReadUInt32(), SeekOrigin.Begin); // seek to the start of the NT header.
                        if (bReader.ReadUInt32() == 17744) //check the PE\0\0 signature.
                        {
                            for (int i = 0; i < 10; i++) // Read COFF Header
                                coffHeader[i] = bReader.ReadUInt16();
                            if (coffHeader[8] > 0) // Read Optional Header
                                architecture = bReader.ReadUInt16();
                        }
                    }
                }
            }

            switch (architecture)
            {
                case 0x20b:
                    return CpuArchitectures.x64;
                case 0x10b:
                    return ((coffHeader[9] & 0x100) == 0) ? CpuArchitectures.AnyCpu : CpuArchitectures.x86;
                default:
                    return CpuArchitectures.Unknown;
            }
        }
        // As found in .DAT archives (RESOURCE.DAT, IO.DAT)
        public void Load(string destinationDirectory, string baseName, BinaryReader binaryReader)
        {
            xOffset = binaryReader.ReadInt16();
            yOffset = binaryReader.ReadInt16();
            binaryReader.BaseStream.Seek(4, SeekOrigin.Current);
            width = binaryReader.ReadUInt16();
            height = binaryReader.ReadUInt16();
            binaryReader.BaseStream.Seek(2, SeekOrigin.Current);
            uint length = binaryReader.ReadUInt32();

            var imageOffset = binaryReader.BaseStream.Position;

            var rowDataOffsets = new ushort[height];
            for (int i = 0; i < height; ++i) {
                rowDataOffsets[i] = binaryReader.ReadUInt16();
            }

            var bmp = new Bmp(width, height);
            var imageData = binaryReader.ReadBytes((int)length - 2*height);

            ReadImage(imageData, rowDataOffsets, false, bmp.Data);

            Debug.Assert(binaryReader.BaseStream.Position - imageOffset == length);
            bmp.Save(Path.Combine(destinationDirectory, baseName), ImageFormat);
            Bmp.SaveOffsets(baseName, xOffset, yOffset);
        }
Example #24
0
        public MapInfo(BinaryReader reader)
        {
            Index = reader.ReadInt32();
            FileName = reader.ReadString();
            Title = reader.ReadString();
            MiniMap = reader.ReadUInt16();
            Light = (LightSetting) reader.ReadByte();
            if (Envir.LoadVersion >= 3) BigMap = reader.ReadUInt16();
            if (Envir.LoadVersion >= 10) reader.ReadByte();

            int count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
                SafeZones.Add(new SafeZoneInfo(reader) { Info = this });

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
                Respawns.Add(new RespawnInfo(reader));

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
                NPCs.Add(new NPCInfo(reader));

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
                Movements.Add(new MovementInfo(reader));
        }
        public WowCorePacketReader(string filename)
        {
            _reader = new BinaryReader(new FileStream(filename, FileMode.Open, FileAccess.Read), Encoding.ASCII);
            _reader.ReadBytes(3);                   // PKT
            Version = _reader.ReadUInt16();     // sniff version (0x0201, 0x0202)
            ushort build;
            switch (Version)
            {
                case 0x0201:
                    build = _reader.ReadUInt16();   // build
                    _reader.ReadBytes(40);          // session key
                    break;
                case 0x0202:
                    _reader.ReadByte();             // 0x06
                    build = _reader.ReadUInt16();   // build
                    _reader.ReadBytes(4);           // client locale
                    _reader.ReadBytes(20);          // packet key
                    _reader.ReadBytes(64);          // realm name
                    break;
                case 0x0300:
                    _reader.ReadByte();                  // snifferId
                    build = (ushort)_reader.ReadUInt32();// client build
                    _reader.ReadBytes(4);                // client locale
                    _reader.ReadBytes(40);               // session key
                    var optionalHeaderLength = _reader.ReadInt32();
                    _reader.ReadBytes(optionalHeaderLength);
                    break;
                default:
                    throw new Exception(String.Format("Unknown sniff version {0:X2}", Version));
            }

            UpdateFieldsLoader.LoadUpdateFields(build);
        }
 public FaceInfo( BinaryReader reader )
 {
     Vertex1 = reader.ReadUInt16();
     Vertex0 = reader.ReadUInt16();
     Flags = (GeometryFlag) reader.ReadUInt16();
     Vertex2 = reader.ReadUInt16();
 }
Example #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NiTriShapeData"/> class.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="reader">The reader.</param>
        public NiTriShapeData(NiFile file, BinaryReader reader) : base(file, reader)
		{
			this.NumTrianglePoints = reader.ReadUInt32();
			if (base.Version >= eNifVersion.VER_10_1_0_0)
			{
				this.HasTriangles = reader.ReadBoolean(Version);
			}
			if (base.Version <= eNifVersion.VER_10_0_1_2 || this.HasTriangles || base.Version >= eNifVersion.VER_10_0_1_3)
			{
				this.Triangles = new Triangle[(int)this.NumTriangles];
				this.HasTriangles = this.Triangles.Length > 0;
				for (int i = 0; i < (int)this.NumTriangles; i++)
				{
					this.Triangles[i] = new Triangle(reader);
				}
			}
			if (base.Version >= eNifVersion.VER_3_1)
			{
				ushort num = reader.ReadUInt16();
				this.MatchGroups = new ushort[(int)num][];
				for (int j = 0; j < (int)num; j++)
				{
					ushort num2 = reader.ReadUInt16();
					this.MatchGroups[j] = new ushort[(int)num2];
					for (int k = 0; k < (int)num2; k++)
					{
						this.MatchGroups[j][k] = reader.ReadUInt16();
					}
				}
			}
		}
 protected override void ReadContentFrom(BinaryReader reader)
 {
     //USHORT 	version 	Version number (0 or 1).
     //USHORT 	numRecs 	Number of VDMX groups present
     //USHORT 	numRatios 	Number of aspect ratio groupings
     //Ratio 	ratRange[numRatios] 	Ratio ranges (see below for more info)
     //USHORT 	offset[numRatios] 	Offset from start of this table to the VDMX group for this ratio range.
     //Vdmx 	groups 	The actual VDMX groupings (documented below)
     //Ratio Record Type 	Name 	Description
     //BYTE 	bCharSet 	Character set (see below).
     //BYTE 	xRatio 	Value to use for x-Ratio
     //BYTE 	yStartRatio 	Starting y-Ratio value.
     //BYTE 	yEndRatio 	Ending y-Ratio value.
     ushort version = reader.ReadUInt16();
     ushort numRecs = reader.ReadUInt16();
     ushort numRatios = reader.ReadUInt16();
     ratios = new Ratio[numRatios];
     for (int i = 0; i < numRatios; ++i)
     {
         ratios[i] = new Ratio(
             reader.ReadByte(),
             reader.ReadByte(),
             reader.ReadByte(),
             reader.ReadByte());
     }
     short[] offsets = Utils.ReadInt16Array(reader, numRatios);
     //------
     //actual vdmx group
     //TODO: implement this
 }
Example #29
0
        public void Deserialize(byte[] buffer)
        {
            if (buffer.Length == 240)
            {
                MemoryStream MS = new MemoryStream(buffer);
                BinaryReader BR = new BinaryReader(MS);

                ushort length = BR.ReadUInt16();
                if (length == 240)
                {
                    ushort type = BR.ReadUInt16();
                    if (type == 1124)
                    {
                        Username = Encoding.ASCII.GetString(BR.ReadBytes(16));
                        Username = Username.Replace("\0", "");
                        BR.ReadBytes(112);
                        Password = Encoding.ASCII.GetString(BR.ReadBytes(16));
                        BR.ReadBytes(112);
                        Server = Encoding.ASCII.GetString(BR.ReadBytes(16));
                        Server = Server.Replace("\0", "");
                    }
                }
                BR.Close();
                MS.Close();
            }
        }
Example #30
0
File: ANA.cs Project: MetLob/tinke
        public override void Read(string file)
        {
            BinaryReader br = new BinaryReader(File.OpenRead(file));

            ushort num_tiles = br.ReadUInt16();
            ushort depth = br.ReadUInt16();
            ColorFormat format = (depth == 0x01 ? ColorFormat.colors256 : ColorFormat.colors16);
            if (br.BaseStream.Length - 4 == num_tiles * 0x40)
                format = ColorFormat.colors256;

            Byte[] tiles = br.ReadBytes(num_tiles * (0x20 + 0x20 * depth));

            int width = 64;
            if (num_tiles == 0x10)
                width = 32;
            int height = tiles.Length / width;
            if (depth == 0)
                height *= 2;

            br.Close();
            Set_Tiles(tiles, width, height, format, TileForm.Horizontal, true);
            pluginHost.Set_Image(this);

            // If the image is 8bpp, convert to 8bpp the palette (4bpp per default)
            PaletteBase palette = pluginHost.Get_Palette();
            if (palette.Loaded && format == ColorFormat.colors256)
            {
                palette.Depth = ColorFormat.colors256;
                pluginHost.Set_Palette(palette);
            }
        }