ReadInt32() public method

public ReadInt32 ( ) : int
return int
Example #1
1
        public Boolean fromFile(String path)
        {
            FileStream fs = new FileStream(path, FileMode.Open);
            BinaryReader reader = new BinaryReader(fs);
            try
            {
                String h = reader.ReadString();
                float v = BitConverter.ToSingle(reader.ReadBytes(sizeof(float)), 0);
                drawFloorModel = reader.ReadBoolean();
                showAlwaysFloorMap = reader.ReadBoolean();
                lockMapSize = reader.ReadBoolean();
                mapXsize = reader.ReadInt32();
                mapYsize = reader.ReadInt32();

                //edgeXのxはmapX-1
                //yはmapYsize

                return true;

            }
            catch (EndOfStreamException eex)
            {
                //握りつぶす
                return false;
            }
            finally
            {
                reader.Close();
            }
        }
Example #2
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;
            }
        }
    // 
    // Un-marshal an object instance from the data input stream
    // 
    public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs) 
    {
        base.TightUnmarshal(wireFormat, o, dataIn, bs);

        ConsumerInfo info = (ConsumerInfo)o;
        info.ConsumerId = (ConsumerId) TightUnmarshalCachedObject(wireFormat, dataIn, bs);
        info.Browser = bs.ReadBoolean();
        info.Destination = (ActiveMQDestination) TightUnmarshalCachedObject(wireFormat, dataIn, bs);
        info.PrefetchSize = dataIn.ReadInt32();
        info.MaximumPendingMessageLimit = dataIn.ReadInt32();
        info.DispatchAsync = bs.ReadBoolean();
        info.Selector = TightUnmarshalString(dataIn, bs);
        info.SubscriptionName = TightUnmarshalString(dataIn, bs);
        info.NoLocal = bs.ReadBoolean();
        info.Exclusive = bs.ReadBoolean();
        info.Retroactive = bs.ReadBoolean();
        info.Priority = dataIn.ReadByte();

        if (bs.ReadBoolean()) {
            short size = dataIn.ReadInt16();
            BrokerId[] value = new BrokerId[size];
            for( int i=0; i < size; i++ ) {
                value[i] = (BrokerId) TightUnmarshalNestedObject(wireFormat,dataIn, bs);
            }
            info.BrokerPath = value;
        }
        else {
            info.BrokerPath = null;
        }
        info.AdditionalPredicate = (BooleanExpression) TightUnmarshalNestedObject(wireFormat, dataIn, bs);
        info.NetworkSubscription = bs.ReadBoolean();
        info.OptimizedAcknowledge = bs.ReadBoolean();
        info.NoRangeAcks = bs.ReadBoolean();

    }
Example #4
0
 public void readDicFile(string fileName)
 {
     fs = File.OpenRead(fileName);
     br = new BinaryReader(fs);
     int classNum = br.ReadInt32();
     Console.WriteLine("classNum="+classNum);
     int dim = br.ReadInt32();
     Console.WriteLine("dim=" + dim);
     int count,data;
     while (fs.CanRead)
     {
         count = br.ReadInt32();
         Console.WriteLine("count=" + count);
         for (int i = 0; i < count; i++)
         {
             for (int j = 0; j < dim; j++)
             {
                 data = br.ReadInt16();
                 //Console.Write(",data[" + j + "]=" + data);
                 Console.Write(data+",");
             }
             Console.WriteLine();
         }
         Console.WriteLine();
     }
 }
Example #5
0
        private Frame[] GetAnimation()
        {
            if (_patch.length < 1)
                return null;

            MemoryStream ms = new MemoryStream(_patch.data);
            BinaryReader bin = new BinaryReader(ms);

            if (_patch.length < 1)
                return null;

            ushort[] palette = new ushort[0x100];

            for( int i = 0; i < 0x100; ++i )
                palette[i] = (ushort)( bin.ReadUInt16() ^ 0x8000 );

            int start = (int)bin.BaseStream.Position;
            int frameCount = bin.ReadInt32();

            int[] lookups = new int[frameCount];

            for( int i = 0; i < frameCount; ++i )
                lookups[i] = start + bin.ReadInt32();

            Frame[] frames = new Frame[frameCount];

            for( int i = 0; i < frameCount; ++i )
            {
                bin.BaseStream.Seek(lookups[i], SeekOrigin.Begin);
                frames[i] = new Frame(palette, bin, false);
            }

            return frames;
        }
Example #6
0
        /// <summary>
        /// Reads the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="pageSize">Holds the size of a single page in the file.</param>
        /// <param name="rootStream">The root stream.</param>
        /// <returns></returns>
        public static bool Read(BinaryReader reader, int pageSize, out PdbRootStream rootStream)
        {
            rootStream.streams = reader.ReadInt32();
            Debug.WriteLine(String.Format(@"PdbRootStream: PDB file contains {0} streams.", rootStream.streams));
            rootStream.streamLength = new int[rootStream.streams];
            rootStream.streamPages = new int[rootStream.streams][];
            for (int i = 0; i < rootStream.streams; i++)
                rootStream.streamLength[i] = reader.ReadInt32();

            for (int i = 0; i < rootStream.streams; i++)
            {
                Debug.WriteLine(String.Format("\tPDB Stream #{0} (Length {1} bytes)", i, rootStream.streamLength[i]));
                if (rootStream.streamLength[i] > 0)
                {
                    rootStream.streamPages[i] = new int[(rootStream.streamLength[i] / pageSize) + 1];
                    for (int j = 0; j < rootStream.streamPages[i].Length; j++)
                    {
                        rootStream.streamPages[i][j] = reader.ReadInt32();
                        Debug.WriteLine(String.Format("\t\tPage {0} (at offset {1})", rootStream.streamPages[i][j], rootStream.streamPages[i][j] * pageSize));
                    }
                }
            }

            return true;
        }
Example #7
0
		public override void Decode()
		{
			MemoryStream stream = new MemoryStream(Data);
			BinaryReader reader = new BinaryReader(stream);
			this.NumShapes = reader.ReadInt32();
			this.LastShapeID = reader.ReadInt32();
		}
Example #8
0
        private ushort usTotalLength; //Шестнадцать битов для общей длины датаграммы (заголовок + сообщение)

        #endregion Fields

        #region Constructors

        public IPHeader(byte[] byBuffer, int nReceived)
        {
            try
            {
                MemoryStream memoryStream = new MemoryStream(byBuffer, 0, nReceived);
                BinaryReader binaryReader = new BinaryReader(memoryStream);

                byVersionAndHeaderLength = binaryReader.ReadByte();
                byDifferentiatedServices = binaryReader.ReadByte();
                usTotalLength = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
                usIdentification = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
                usFlagsAndOffset = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
                byTTL = binaryReader.ReadByte();
                byProtocol = binaryReader.ReadByte();
                sChecksum = IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
                uiSourceIPAddress = (uint)(binaryReader.ReadInt32());
                uiDestinationIPAddress = (uint)(binaryReader.ReadInt32());

                byHeaderLength = byVersionAndHeaderLength;
                byHeaderLength <<= 4;
                byHeaderLength >>= 4;
                byHeaderLength *= 4;

                Array.Copy(byBuffer, byHeaderLength, byIPData, 0, usTotalLength - byHeaderLength);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
 /*
 Achtung! Hier fehlt noch jegliches Error-Handling
 Es wird nicht einmal geprüft ob die Datei mit VADB anfängt!
 */
 public VDB_Table[] ImportTables(string filename)
 {
     BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open));
     string formatID = reader.ReadString();
     int formatVersion = reader.ReadInt32();
     int tableCount = reader.ReadInt32();
     VDB_Table[] tables = new VDB_Table[tableCount];
     for (int i = 0; i < tableCount; i++) {
         string tableName = reader.ReadString();
         int columnCount = reader.ReadInt32();
         string[] columns = new string[columnCount];
         for (int j = 0; j < columnCount; j++) {
             columns[j] = reader.ReadString();
         }
         int rowCount = reader.ReadInt32();
         tables[i] = new VDB_Table(tableName, rowCount, columns);
     }
     string valueArea = reader.ReadString();
     string[] values = valueArea.Split(VDB_DatabaseExporter.valuesSeperator);
     for (int i = 0; i < values.Length - 1; i++) {
         string[] posval = values[i].Split(VDB_DatabaseExporter.positionValueSeperator);
         string[] pos = posval[0].Split(VDB_DatabaseExporter.positionSeperator);
         int table = Int32.Parse(pos[0]);
         int row = Int32.Parse(pos[1]);
         int column = Int32.Parse(pos[2]);
         tables[table].GetRowAt(row).values[column] = VDB_Value.FromBase64(posval[1]);
     }
     reader.Close();
     return tables;
 }
Example #10
0
 public static bool ReadFile(string FileName)
 {
     LCMeshReader.OpenedFile = FileName;
       LCMeshReader.pMesh = new tMeshContainer();
       BinaryReader b = new BinaryReader( new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read));
       LCMeshReader.pMesh.HeaderInfo = new tHeaderInfo();
       LCMeshReader.pMesh.HeaderInfo.Format = b.ReadBytes(4);
       LCMeshReader.pMesh.HeaderInfo.Version = b.ReadInt32();
       LCMeshReader.pMesh.HeaderInfo.MeshDataSize = b.ReadInt32();
       LCMeshReader.pMesh.HeaderInfo.MeshCount = b.ReadUInt32();
       LCMeshReader.pMesh.HeaderInfo.VertexCount = b.ReadUInt32();
       LCMeshReader.pMesh.HeaderInfo.JointCount = b.ReadUInt32();
       LCMeshReader.pMesh.HeaderInfo.TextureMaps = b.ReadUInt32();
       LCMeshReader.pMesh.HeaderInfo.NormalCount = b.ReadUInt32();
       LCMeshReader.pMesh.HeaderInfo.ObjCount = b.ReadUInt32();
       LCMeshReader.pMesh.HeaderInfo.UnknownCount = b.ReadUInt32();
       LCMeshReader.pMesh.FileName = b.ReadBytes(b.ReadInt32());
       LCMeshReader.pMesh.Scale = b.ReadSingle();
       LCMeshReader.pMesh.Value1 = b.ReadUInt32();
       LCMeshReader.pMesh.FilePath = FileName;
       bool flag = false;
       if (LCMeshReader.pMesh.HeaderInfo.Version == 16)
       {
     if (LCMeshReader.ReadV10(b, b.BaseStream.Position))
       flag = true;
       }
       else if (LCMeshReader.pMesh.HeaderInfo.Version == 17 && LCMeshReader.ReadV11(b, b.BaseStream.Position))
     flag = true;
       b.Close();
       return flag;
 }
Example #11
0
		public void SetDataFrom (BinaryReader reader)
		{
			File = reader.ReadString();
			LineNumber = reader.ReadInt32();
			LinePosition = reader.ReadInt32();
			ErrorMessage = reader.ReadString();
		}
Example #12
0
 public EmmeMatrix(BinaryReader reader)
     : this()
 {
     this.MagicNumber = reader.ReadUInt32();
     if(!this.IsValidHeader())
     {
         return;
     }
     this.Version = reader.ReadInt32();
     this.Type = (DataType)reader.ReadInt32();
     this.Dimensions = reader.ReadInt32();
     this.Indexes = new int[this.Dimensions][];
     for(int i = 0; i < this.Indexes.Length; i++)
     {
         Indexes[i] = new int[reader.ReadInt32()];
     }
     for(int i = 0; i < this.Indexes.Length; i++)
     {
         var row = Indexes[i];
         for(int j = 0; j < row.Length; j++)
         {
             row[j] = reader.ReadInt32();
         }
     }
     LoadData(reader.BaseStream);
 }
Example #13
0
            public static void Load()
            {
                var local = GetData("UFSJ.S.uscx");
                try
                {
                    using (var i = new BinaryReader(File.OpenRead(local)))
                    {
                        if (i.ReadChar() == 'U')
                        {
                            OnTopMost = i.ReadBoolean(); //OnTopMost
                            SilentProgress = i.ReadBoolean(); //SilentProgress
                            ShowSummary = i.ReadBoolean(); //ShowSummary
                            AssociateExt = i.ReadBoolean(); //AssociateExt
                            StartHide = i.ReadBoolean(); //StartHide
                            ShellMenus = i.ReadBoolean(); //ShellMenus
                            SettingMode = i.ReadInt16(); //SettingMode
                            Theme = i.ReadString(); //ColorScheme
                            Language = i.ReadString(); //Language
                            Formats = i.ReadString(); //Formats
                            Position = new Point(i.ReadInt32(), i.ReadInt32());
                        }
                    }
                }
                catch (Exception)
                {
                    SaveDefault();
                    Load();
                }

            }
        private static ModelMesh ReadMesh(BinaryReader r)
        {
            var data    = new ModelMesh();
            data.NumVerts   = r.ReadInt32();
            data.NumPrims   = r.ReadInt32();
            data.NumRefBones= r.ReadInt32();
            data.RefBones  = ReadList(r, data.NumRefBones, ReadRefBone);

            foreach(var i in data.RefBones)
                i.Matrix    = ReadSingleArray(r, 16);

            data.Vertices   = ReadList(r, data.NumVerts, ReadVertex);
            data.NumTangents= r.ReadInt32();

            System.Diagnostics.Debug.Assert(data.NumTangents == 0);

            data.Tangents   = ReadList(r, data.NumTangents, ReadVector4);
            data.Skins      = ReadList(r, data.NumVerts, ReadSkin);

              //System.Diagnostics.Debug.Assert(data.Unknown2 == 0);

            data.Primitives = new List<ModelPrimitive>();

            for(int i= 0; i < data.NumPrims; ++i)
            {
                var prim    = new ModelPrimitive();

                prim.NumIndices = r.ReadInt32();
                prim.Indices    = ReadList(r, prim.NumIndices, r.ReadUInt16);

                data.Primitives.Add(prim);
            }

            return data;
        }
        public static ModelFile FromFile(string file)
        {
            var data= new ModelFile() { FileName= file };

            using(var s= File.OpenRead(file))
            using(var r = new BinaryReader(s))
            {
                data.Magic      = ReadString(r);
                data.Version    = r.ReadInt32();
                data.Descriptions= ReadList(r, 2, ReadString);
                data.NumBones   = r.ReadInt32();
                data.Bones      = ReadList(r, data.NumBones, ReadBone);

                foreach(var i in data.Bones)
                    i.ParentID  = r.ReadInt32();

                foreach(var i in data.Bones)
                    i.Params    = ReadSingleArray(r, 7);

                data.Mesh       = ReadMesh(r);
                data.NumMaterials= r.ReadInt32();

              //System.Diagnostics.Debug.Assert(data.NumMaterials == 1);

                data.Materials  = ReadList(r, data.NumMaterials, ReadMaterial);
                data.Params     = ReadParamList(r);
            }

            return data;
        }
Example #16
0
        public TileData(Engine engine)
        {
            _instance = this;

            IConfigurationService configurationService = engine.Services.GetService<IConfigurationService>();
            string ultimaOnlineDirectory = configurationService.GetValue<string>(ConfigSections.UltimaOnline, ConfigKeys.UltimaOnlineDirectory);

            string filePath = Path.Combine(ultimaOnlineDirectory, "tiledata.mul");

            if (filePath != null)
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader bin = new BinaryReader(fs);

                    m_LandData = new LandData[0x4000];

                    for (int i = 0; i < 0x4000; ++i)
                    {
                        if ((i & 0x1F) == 0)
                        {
                            bin.ReadInt32(); // header
                        }

                        TileFlag flags = (TileFlag)bin.ReadInt32();
                        bin.ReadInt16(); // skip 2 bytes -- textureID

                        m_LandData[i] = new LandData(ReadNameString(bin), flags);
                    }

                    m_ItemData = new ItemData[0x4000];
                    m_HeightTable = new int[0x4000];

                    for (int i = 0; i < 0x4000; ++i)
                    {
                        if ((i & 0x1F) == 0)
                            bin.ReadInt32(); // header

                        TileFlag flags = (TileFlag)bin.ReadInt32();
                        int weight = bin.ReadByte();
                        int quality = bin.ReadByte();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int quantity = bin.ReadByte();
                        int anim = bin.ReadInt16();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int value = bin.ReadByte();
                        int height = bin.ReadByte();

                        m_ItemData[i] = new ItemData(ReadNameString(bin), flags, weight, quality, quantity, value, height, anim);
                        m_HeightTable[i] = height;
                    }
                }
            }
            else
            {
                throw new FileNotFoundException();
            }
        }
Example #17
0
		private static bool ParseFileHeader(BinaryReader reader, out string filename)
		{
			filename = null;
			if (reader.BaseStream.Position < reader.BaseStream.Length)
			{
				int headerSignature = reader.ReadInt32();
				if (headerSignature == 67324752) //PKZIP
				{
					reader.BaseStream.Seek(14, SeekOrigin.Current); //ignore unneeded values
					int compressedSize = reader.ReadInt32();
					int unCompressedSize = reader.ReadInt32();
					short fileNameLenght = reader.ReadInt16();
					short extraFieldLenght = reader.ReadInt16();
					filename = new string(reader.ReadChars(fileNameLenght));
					if (string.IsNullOrEmpty(filename))
						return false;
					//Seek to the next file header
					reader.BaseStream.Seek(extraFieldLenght + compressedSize, SeekOrigin.Current);
					if (unCompressedSize == 0) //Directory or not supported. Skip it
						return ParseFileHeader(reader, out filename);
					else
						return true;
				}
			}
			return false;
		}
Example #18
0
        public wavefile(FileStream file)
        {
            BinaryReader binRead = new BinaryReader(file);

            //head data
            ChunkID =  binRead.ReadChars(4);
            ChunkSize = binRead.ReadInt32();
            Format = binRead.ReadChars(4);
            Subchunk1ID = binRead.ReadChars(4);
            Subchunk1Size = binRead.ReadInt32();//in bytes
            AudioFormat = binRead.ReadInt16();
            NumChannels = binRead.ReadInt16();
            SampleRate = binRead.ReadInt32();//samples per second?
            ByteRate = binRead.ReadInt32();
            BlockAlign = binRead.ReadInt16();
            BitsPerSample = binRead.ReadInt16();
            Subchunk2ID = binRead.ReadChars(4);
            Subchunk2Size = binRead.ReadInt32();//in bytes

            int numSamples = Subchunk2Size / (BitsPerSample / 8);
            data = new byte[numSamples];
            wave = new float[numSamples];

            data = binRead.ReadBytes(numSamples);

            for (int i = 0; i < numSamples; i++)
            {
                wave[i] = ((float)data[i] - 128) / 128;
            }
        }
Example #19
0
		void DepthClient_FrameReady(object sender, FrameReadyEventArgs e)
		{
			DepthFrameReadyEventArgs args = new DepthFrameReadyEventArgs();
			DepthFrameData dfd = new DepthFrameData();

			MemoryStream ms = new MemoryStream(e.Data);
			BinaryReader br = new BinaryReader(ms);

			dfd.PlayerIndexBitmask = br.ReadInt32();
			dfd.PlayerIndexBitmaskWidth = br.ReadInt32();

			DepthImageFrame frame = br.ReadDepthImageFrame();
			dfd.ImageFrame = frame;

			int dataLength = (int)(ms.Length - ms.Position);

			if(_depthShort == null || _depthShort.Length != dataLength / 2)
				_depthShort = new short[dataLength / 2];

			Buffer.BlockCopy(e.Data, (int)br.BaseStream.Position, _depthShort, 0, dataLength);

			dfd.DepthData = _depthShort;

			DepthFrame = dfd;
			args.DepthFrame = dfd;

			if(DepthFrameReady != null)
				DepthFrameReady(this, args);
		}
        public void SetDataFrom(BinaryReader reader)
        {
            var tests = new List<LiveTestStatus>();
            CurrentAssembly = reader.ReadString();
            CurrentTest = reader.ReadString();
            TotalNumberOfTests = reader.ReadInt32();
            TestsCompleted = reader.ReadInt32();
            var count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                var test = new LiveTestStatus("", null);
                test.SetDataFrom(reader);
                tests.Add(test);
            }
            _failedTest = tests.ToArray();

            tests = new List<LiveTestStatus>();
            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                var test = new LiveTestStatus("", null);
                test.SetDataFrom(reader);
                tests.Add(test);
            }
            _failedButNowPassing = tests.ToArray();
        }
Example #21
0
        public void Initialize()
        {
            int CurrentVersion;
            _initialized = true;

            if (!File.Exists(FileName))
                return;

            _stream = new FileStream(FileName, FileMode.Open, FileAccess.ReadWrite);
            _reader = new BinaryReader(_stream);
            CurrentVersion = _reader.ReadInt32();
            if (CurrentVersion != LibVersion)
            {
                MessageBox.Show("Wrong version, expecting lib version: " + LibVersion.ToString() + " found version: " + CurrentVersion.ToString() + ".", "Failed to open", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return;
            }
            Count = _reader.ReadInt32();
            Images = new List<MImage>();
            IndexList = new List<int>();

            for (int i = 0; i < Count; i++)
                IndexList.Add(_reader.ReadInt32());

            for (int i = 0; i < Count; i++)
                Images.Add(null);

            for (int i = 0; i < Count; i++)
                CheckImage(i);
        }
Example #22
0
        private static bool Load(BinaryReader reader, out Value value)
        {
            List<KeyValuePair<Value, Value>>	array;
            Value								arrayKey;
            Value								arrayValue;
            int									count;
            ValueContent						type;

            type = (ValueContent)reader.ReadInt32 ();

            switch (type)
            {
                case ValueContent.Boolean:
                    value = reader.ReadBoolean () ? BooleanValue.True : BooleanValue.False;

                    break;

                case ValueContent.Map:
                    count = reader.ReadInt32 ();
                    array = new List<KeyValuePair<Value, Value>> (count);

                    while (count-- > 0)
                    {
                        if (!ValueAccessor.Load (reader, out arrayKey) || !ValueAccessor.Load (reader, out arrayValue))
                        {
                            value = null;

                            return false;
                        }

                        array.Add (new KeyValuePair<Value, Value> (arrayKey, arrayValue));
                    }

                    value = array;

                    break;

                case ValueContent.Number:
                    value = reader.ReadDecimal ();

                    break;

                case ValueContent.String:
                    value = reader.ReadString ();

                    break;

                case ValueContent.Void:
                    value = VoidValue.Instance;

                    break;

                default:
                    value = null;

                    return false;
            }

            return true;
        }
Example #23
0
 public BAR(Stream file)
 {
     if (!file.CanRead || !file.CanSeek)
     {
         throw new NotSupportedException("Cannot read or seek in stream");
     }
     using (var br = new BinaryReader(file))
     {
         if (file.Length < 16 || br.ReadUInt32() != 0x01524142)
         {
             throw new InvalidDataException("Invalid signature");
         }
         int fileC = br.ReadInt32();
         fileList = new List<BARFile>(fileC);
         Debug.WriteLine("Loading BAR with " + fileC + " files");
         file.Position = 16;
         for (int i = 0; i < fileC; i++)
         {
             var bf = new BARFile();
             bf.type = br.ReadUInt32();
             {
                 byte[] b = br.ReadBytes(4);
                 Buffer.BlockCopy(b, 0, bf._id, 0, 4);
             }
             long lpos = file.Position + 8;
             uint pos = br.ReadUInt32();
             int len = br.ReadInt32();
             file.Position = pos;
             bf.data = br.ReadBytes(len);
             fileList.Add(bf);
             file.Position = lpos;
         }
     }
     //BinaryReader should close file
 }
Example #24
0
 public NPCTextAudio(BinaryReader inStream)
 {
     Id = inStream.ReadInt32();
     Unknown0 = inStream.ReadInt64();
     Text = inStream.ReadInt32();
     AudioPath = inStream.ReadInt32();
 }
Example #25
0
		public override void Decode()
		{
			MemoryStream stream = new MemoryStream(Data);
			BinaryReader reader = new BinaryReader(stream);
			this.ShapeId = reader.ReadInt32();
			this.Flags = reader.ReadInt32();
		}
        public Message Deserialize(CircularBuffer buffer)
        {
            // Read the message size
            if (buffer.Available < 4)
            {
                return null;
            }
            int offset = 0;
            uint size = (uint)((buffer.PeekByte(offset++) << 0) |
                               (buffer.PeekByte(offset++) << 8) |
                               (buffer.PeekByte(offset++) << 16) |
                               (buffer.PeekByte(offset++) << 24));
            if (buffer.Available < (int)size)
            {
                return null;
            }

            // read the message's contents
            byte[] data = new byte[size];
            buffer.Read(data, 0, (int)size);

            // decode the message's contents
            MemoryStream ms = new MemoryStream(data, false);
            BinaryReader reader = new BinaryReader(ms);
            reader.ReadInt32();
            MessageType type = (MessageType)reader.ReadInt32();
            MessageDecoder decoder;
            if (!m_decoders.TryGetValue(type, out decoder))
            {
                throw new NotImplementedException("Message type not supported: " + type);
            }
            Message msg = decoder(reader, type);
            LogMessage(msg, "<<");
            return msg;
        }
Example #27
0
    public static Shape Load(string fn)
    {
        if (!System.IO.File.Exists(fn))
            throw new System.Exception("File not found: " + fn);

        System.IO.BinaryReader br = new System.IO.BinaryReader(new System.IO.FileStream(fn, System.IO.FileMode.Open));
        Shape s = new Shape();

        s.Width = br.ReadInt32();
        s.Height = br.ReadInt32();
        s.matrix = new bool[s.Width, s.Height];

        try
        {
            for (int x = 0; x < s.Width; x++)
                for (int y = 0; y < s.Height; y++)
                    s.notEmptyCellsCount += (s.matrix[x, y] = br.ReadBoolean()) ? 1 : 0;
        }
        catch (System.IO.EndOfStreamException)
        {
            throw new System.Exception("Invalid data for shape " + fn);
        }

        br.Close();
        s.CreateTexture();
        return s;
    }
Example #28
0
        public Template(BinaryReader log, long chunkOffset, LogRoot root)
        {
            this.LogRoot = root;
            this.ChunkOffset = chunkOffset;
            this.Position = log.BaseStream.Position;

            int nextTemplate = log.ReadInt32();
            int templateID2 = log.ReadInt32();

            log.BaseStream.Position -= 4;

            byte[] g = log.ReadBytes(16);
            Guid templateGuid = new Guid(g);
            this.Length = log.ReadInt32();
            long i = this.Length;
            this.ChildNodes = new List<INode>();

            //log.BaseStream.Position = this.Position;
            while(i >= 0 && !root.ReachedEOS)
            {
                Console.WriteLine("Current length: " + i);
                INode node = LogNode.NewNode(log, this, chunkOffset, root);
                this.ChildNodes.Add(node);
                i -= node.Length;
                if (node is _x00)
                    root.ReachedEOS = true;
            }
        }
Example #29
0
        /// <summary>
        /// Reads a new WaveFormat object from a stream
        /// </summary>
        /// <param name="br">A binary reader that wraps the stream</param>
        public WaveFormat(BinaryReader br)
        {
            int formatChunkLength = br.ReadInt32();
            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)
                {
                    Console.WriteLine("Format chunk mismatch");
                    //RRL GSM exhibits this bug. Don't throw an exception
                    //throw new ApplicationException("Format chunk length mismatch");

                    this.extraSize = (short) (formatChunkLength - 18);
                }

                // read any extra data
                // br.ReadBytes(extraSize);

            }
        }
        private void loadFromFile(string fileName)
        {
            if (!File.Exists(fileName))
            {
                return;
            }

            FileStream fstream = File.OpenRead(fileName);
            BinaryReader reader = new BinaryReader(fstream);

            int cnt = reader.ReadInt32();
            for (int i = 0; i < cnt; i++)
            {
                string symbol = reader.ReadString();
                int stockCount = reader.ReadInt32();
                int buyPrice = reader.ReadInt32();

                PortfolioItem item = new PortfolioItem()
                {
                    Symbol = symbol,
                    Amount = stockCount,
                    BuyPrice = buyPrice,
                };

                list.Add(item);

            }

            reader.Close();
            fstream.Close();

        }