ReadInt32() public method

public ReadInt32 ( ) : int
return int
Esempio n. 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();
            }
        }
Esempio n. 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();

    }
Esempio n. 4
0
        internal PageIndexNode(int flags, int number, io.BinaryReader reader, DbColumnType keyType)
            : base(flags, number)
        {
            //read info
            PageSize    = reader.ReadInt32();
            UniqueValue = (flags & Consts.BTreeUniqueKeyValueFlag) != 0;

            //for Unique = true, this's the unique value, otehrwise it's the Value count
            Int32 keyValueCount = reader.ReadInt32();

            Values = new List <int>();

            //read value(s)
            if (UniqueValue)
            {
                //store unique value
                Values.Add(keyValueCount);
            }
            else
            {
                for (var i = 0; i < keyValueCount; i++)
                {
                    Values.Add(reader.ReadInt32());
                }
            }

            //read key, is an object
            Key = (T)keyType.LoadKey(reader);
        }
        private WaveFormat GetWaveFormat(System.IO.BinaryReader br)
        {
            WaveFormat format            = new WaveFormat();
            int        formatChunkLength = br.ReadInt32();

            if (formatChunkLength < 16)
            {
                throw new ApplicationException("Invalid WaveFormat Structure");
            }
            format.FormatTag             = (WaveFormatTag)br.ReadUInt16();
            format.Channels              = br.ReadInt16();
            format.SamplesPerSecond      = br.ReadInt32();
            format.AverageBytesPerSecond = br.ReadInt32();
            format.BlockAlignment        = br.ReadInt16();
            format.BitsPerSample         = br.ReadInt16();
            short extraSize = 0;

            if (formatChunkLength > 16)
            {
                extraSize = br.ReadInt16();
                if (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");

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

                // read any extra data
                // br.ReadBytes(extraSize);
            }
            return(format);
        }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.MapID      = binaryReader.ReadInt32();
     this.Bitmap     = binaryReader.ReadTagReference();
     this.fieldskip  = binaryReader.ReadBytes(576);
     this.fieldskip0 = binaryReader.ReadBytes(2304);
     this.Path       = binaryReader.ReadString256();
     this.SortOrder  = binaryReader.ReadInt32();
     this.GlobalUiMultiplayerLevelFlags = ((Flags)(binaryReader.ReadByte()));
     this.fieldpad            = binaryReader.ReadBytes(3);
     this.MaxTeamsNone        = binaryReader.ReadByte();
     this.MaxTeamsCTF         = binaryReader.ReadByte();
     this.MaxTeamsSlayer      = binaryReader.ReadByte();
     this.MaxTeamsOddball     = binaryReader.ReadByte();
     this.MaxTeamsKOTH        = binaryReader.ReadByte();
     this.MaxTeamsRace        = binaryReader.ReadByte();
     this.MaxTeamsHeadhunter  = binaryReader.ReadByte();
     this.MaxTeamsJuggernaut  = binaryReader.ReadByte();
     this.MaxTeamsTerritories = binaryReader.ReadByte();
     this.MaxTeamsAssault     = binaryReader.ReadByte();
     this.MaxTeamsStub10      = binaryReader.ReadByte();
     this.MaxTeamsStub11      = binaryReader.ReadByte();
     this.MaxTeamsStub12      = binaryReader.ReadByte();
     this.MaxTeamsStub13      = binaryReader.ReadByte();
     this.MaxTeamsStub14      = binaryReader.ReadByte();
     this.MaxTeamsStub15      = binaryReader.ReadByte();
     return(pointerQueue);
 }
Esempio n. 7
0
 internal override void Load(System.IO.BinaryReader br)
 {
     pt1.X = br.ReadInt32();
     pt1.Y = br.ReadInt32();
     pt2.X = br.ReadInt32();
     pt2.Y = br.ReadInt32();
 }
Esempio n. 8
0
        /// <summary>
        /// Unserializes a BinaryStream into the Attributes of this Instance
        /// </summary>
        /// <param name="reader">The Stream that contains the FileData</param>
        public void Unserialize(System.IO.BinaryReader reader)
        {
            int vcount = reader.ReadInt32();

            if (vcount > 0)
            {
                try
                {
                    int count = reader.ReadInt32();
                    verts.Clear();
                    for (int i = 0; i < vcount; i++)
                    {
                        Vector3f f = new Vector3f();
                        f.Unserialize(reader);
                        verts.Add(f);
                    }

                    items.Clear();
                    for (int i = 0; i < count; i++)
                    {
                        items.Add(this.ReadValue(reader));
                    }
                }
                catch (Exception ex)
                {
                    Helper.ExceptionMessage("", ex);
                }
            }
        }
Esempio n. 9
0
 protected override void DoRead(System.IO.BinaryReader reader)
 {
     Material      = ReadString(reader);
     PrimitiveType = reader.ReadInt32();
     FirstIndex    = reader.ReadInt32();
     TriCount      = reader.ReadInt32();
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.FieldLongInteger  = binaryReader.ReadInt32();
     this.FieldLongInteger0 = binaryReader.ReadInt32();
     return(pointerQueue);
 }
        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;
        }
Esempio n. 12
0
		public void SetDataFrom (BinaryReader reader)
		{
			File = reader.ReadString();
			LineNumber = reader.ReadInt32();
			LinePosition = reader.ReadInt32();
			ErrorMessage = reader.ReadString();
		}
        public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
        {
            System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
            this.Position = binaryReader.ReadVector3();
            int i;

            for (i = 0; (i < 4); i = (i + 1))
            {
                this.NodeIndices00[i] = new NodeIndicesBlock();
                pointerQueue          = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.NodeIndices00[i].ReadFields(binaryReader)));
            }
            for (i = 0; (i < 4); i = (i + 1))
            {
                this.NodeWeights00[i] = new NodeWeightsBlock();
                pointerQueue          = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.NodeWeights00[i].ReadFields(binaryReader)));
            }
            for (i = 0; (i < 4); i = (i + 1))
            {
                this.NodeIndices20[i] = new NodeIndices1Block();
                pointerQueue          = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.NodeIndices20[i].ReadFields(binaryReader)));
            }
            this.UseNewNodeIndices         = binaryReader.ReadInt32();
            this.AdjustedCompoundNodeIndex = binaryReader.ReadInt32();
            return(pointerQueue);
        }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.SettingCategory = ((SettingCategoryEnum)(binaryReader.ReadInt32()));
     this.Value           = binaryReader.ReadInt32();
     return(pointerQueue);
 }
        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();
        }
Esempio n. 16
0
 public NPCTextAudio(BinaryReader inStream)
 {
     Id = inStream.ReadInt32();
     Unknown0 = inStream.ReadInt64();
     Text = inStream.ReadInt32();
     AudioPath = inStream.ReadInt32();
 }
Esempio n. 17
0
 internal override void Load(System.IO.BinaryReader br)
 {
     Left   = br.ReadInt32();
     Top    = br.ReadInt32();
     width  = br.ReadInt32();
     height = br.ReadInt32();
 }
 /*
 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;
 }
Esempio n. 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);
		}
Esempio n. 20
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
 }
Esempio n. 21
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;
    }
Esempio n. 22
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;
        }
        public override void Initialize(System.IO.BinaryReader reader, RecordHeader header)
        {
            while (reader.BaseStream.Position < header.DataEndPos)
            {
                var type = (SubRecordType)reader.ReadInt32();
                var size = reader.ReadInt32();

                switch (type)
                {
                case SubRecordType.Id:
                    id = reader.ReadString(size);
                    break;

                case SubRecordType.IntValue:
                    index = reader.ReadInt32();
                    break;

                case SubRecordType.Data:
                    texture = reader.ReadString(size);
                    break;
                }
            }

            records.Add(index, this);
        }
Esempio n. 24
0
        public override void Initialize(System.IO.BinaryReader reader, RecordHeader header)
        {
            while (reader.BaseStream.Position < header.DataEndPos)
            {
                var type = (SubRecordType)reader.ReadInt32();
                var size = reader.ReadInt32();

                switch (type)
                {
                case SubRecordType.Id:
                    name = reader.ReadString(size);
                    break;

                case SubRecordType.Data:
                    calculateFromAllLevelsLessThanPCsLevel = reader.ReadInt32();
                    break;

                case SubRecordType.NextName:
                    chanceNone = reader.ReadByte();
                    break;

                case SubRecordType.Index:
                    index = reader.ReadInt32();
                    break;

                case SubRecordType.CreatureName:
                    creatureNames.Add(reader.ReadString(size));
                    break;

                case SubRecordType.IntValue:
                    pcLevel.Add(reader.ReadInt16());
                    break;
                }
            }
        }
Esempio n. 25
0
        private void Mod_LoadAreaPortals(SDHeader header, ref CModel.SModel _SModel, ref System.IO.BinaryReader br)
        {
            List <SDAreaPortal>        DAreaPortal = new List <SDAreaPortal>();
            List <CModel.SMAreaPortal> MAreaPortal = new List <CModel.SMAreaPortal>();

            br.BaseStream.Seek(header.lumps[LUMP_AREAPORTALS].fileofs, System.IO.SeekOrigin.Begin);
            while (br.BaseStream.Position < (header.lumps[LUMP_AREAPORTALS].fileofs + header.lumps[LUMP_AREAPORTALS].filelen))
            {
                SDAreaPortal _DAreaPortal;

                _DAreaPortal.portalnum = br.ReadInt32();
                _DAreaPortal.otherarea = br.ReadInt32();

                DAreaPortal.Add(_DAreaPortal);
            }

            for (int i = 0; i < DAreaPortal.Count; i++)
            {
                CModel.SMAreaPortal _MAreaPortal;

                _MAreaPortal.portalnum = DAreaPortal[i].portalnum;
                _MAreaPortal.otherarea = DAreaPortal[i].otherarea;

                MAreaPortal.Add(_MAreaPortal);
            }

            _SModel.numareaportals = MAreaPortal.Count;
            _SModel.areaportals    = MAreaPortal.ToArray();
        }
Esempio n. 26
0
        private void Mod_LoadAreas(SDHeader header, ref CModel.SModel _SModel, ref System.IO.BinaryReader br)
        {
            List <SDArea>        DArea = new List <SDArea>();
            List <CModel.SMArea> MArea = new List <CModel.SMArea>();

            br.BaseStream.Seek(header.lumps[LUMP_AREAS].fileofs, System.IO.SeekOrigin.Begin);
            while (br.BaseStream.Position < (header.lumps[LUMP_AREAS].fileofs + header.lumps[LUMP_AREAS].filelen))
            {
                SDArea _DArea;

                _DArea.numareaportals  = br.ReadInt32();
                _DArea.firstareaportal = br.ReadInt32();

                DArea.Add(_DArea);
            }

            for (int i = 0; i < DArea.Count; i++)
            {
                CModel.SMArea _MArea;

                _MArea.numareaportals  = DArea[i].numareaportals;
                _MArea.firstareaportal = DArea[i].firstareaportal;
                _MArea.floodvalid      = 0;
                _MArea.floodnum        = 0;

                MArea.Add(_MArea);
            }

            _SModel.numareas = MArea.Count;
            _SModel.areas    = MArea.ToArray();
        }
Esempio n. 27
0
        private void Mod_LoadVisibility(SDHeader header, ref CModel.SModel _SModel, ref System.IO.BinaryReader br)
        {
            int pos_visdata = 0;

            br.BaseStream.Seek(header.lumps[LUMP_VISIBILITY].fileofs, System.IO.SeekOrigin.Begin);

            if (header.lumps[LUMP_VISIBILITY].filelen == 0)
            {
                _SModel.vis.numclusters = 0;
                _SModel.vis.bitofs      = null;
                _SModel.visdata         = null;

                return;
            }

            _SModel.vis.numclusters = br.ReadInt32();
            _SModel.vis.bitofs      = new int[_SModel.vis.numclusters, 2];

            for (int i = 0; i < _SModel.vis.numclusters; i++)
            {
                _SModel.vis.bitofs[i, DVIS_PVS] = br.ReadInt32();
                _SModel.vis.bitofs[i, DVIS_PHS] = br.ReadInt32();

                // decrement the offsets, because the data is stored in a seperate byte array
                _SModel.vis.bitofs[i, DVIS_PVS] -= 4 + ((4 * _SModel.vis.numclusters * 2));
                _SModel.vis.bitofs[i, DVIS_PHS] -= 4 + ((4 * _SModel.vis.numclusters * 2));
            }

            _SModel.visdata = new byte[(header.lumps[LUMP_VISIBILITY].fileofs + header.lumps[LUMP_VISIBILITY].filelen) - br.BaseStream.Position];
            while (br.BaseStream.Position < (header.lumps[LUMP_VISIBILITY].fileofs + header.lumps[LUMP_VISIBILITY].filelen))
            {
                _SModel.visdata[pos_visdata++] = br.ReadByte();
            }
        }
Esempio n. 28
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);

            }
        }
Esempio n. 29
0
        private static bool ReadInfoHeader(System.IO.BinaryReader aReader, ref BitmapInfoHeader aHeader)
        {
            aHeader.size = aReader.ReadUInt32();
            if (aHeader.size < 40)
            {
                return(false);
            }
            aHeader.width             = aReader.ReadInt32();
            aHeader.height            = aReader.ReadInt32();
            aHeader.nColorPlanes      = aReader.ReadUInt16();
            aHeader.nBitsPerPixel     = aReader.ReadUInt16();
            aHeader.compressionMethod = (BMPComressionMode)aReader.ReadInt32();
            aHeader.rawImageSize      = aReader.ReadUInt32();
            aHeader.xPPM             = aReader.ReadInt32();
            aHeader.yPPM             = aReader.ReadInt32();
            aHeader.nPaletteColors   = aReader.ReadUInt32();
            aHeader.nImportantColors = aReader.ReadUInt32();
            int pad = (int)aHeader.size - 40;

            if (pad > 0)
            {
                aReader.ReadBytes(pad);
            }
            return(true);
        }
Esempio n. 30
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;
		}
Esempio n. 31
0
        /// <summary>
        /// Load previously persisted cookie library from the file.
        /// </summary>
        internal static void Load()
        {
#if !BESTHTTP_DISABLE_COOKIE_SAVE
            if (!IsSavingSupported)
            {
                return;
            }

            lock (Locker)
            {
                if (Loaded)
                {
                    return;
                }

                SetupFolder();

                try
                {
                    Cookies.Clear();

                    if (!Directory.Exists(CookieFolder))
                    {
                        Directory.CreateDirectory(CookieFolder);
                    }

                    if (!File.Exists(LibraryPath))
                    {
                        return;
                    }

                    using (var fs = new FileStream(LibraryPath, FileMode.Open))
                        using (var br = new System.IO.BinaryReader(fs))
                        {
                            /*int version = */ br.ReadInt32();
                            int cookieCount = br.ReadInt32();

                            for (int i = 0; i < cookieCount; ++i)
                            {
                                Cookie cookie = new Cookie();
                                cookie.LoadFrom(br);

                                if (cookie.WillExpireInTheFuture())
                                {
                                    Cookies.Add(cookie);
                                }
                            }
                        }
                }
                catch
                {
                    Cookies.Clear();
                }
                finally
                {
                    Loaded = true;
                }
            }
#endif
        }
Esempio n. 32
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);
        }
Esempio n. 33
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.SectionIndex  = binaryReader.ReadInt32();
     this.PcaDataOffset = binaryReader.ReadInt32();
     return(pointerQueue);
 }
Esempio n. 34
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);
 }
Esempio n. 35
0
 public GAT(byte[] data)
 {
     try
     {
         using (System.IO.MemoryStream ms = new System.IO.MemoryStream(data, 0, data.Length))
         {
             using (System.IO.BinaryReader br = new System.IO.BinaryReader(ms))
             {
                 m_Magic    = System.Text.Encoding.Default.GetString(br.ReadBytes(4));
                 m_VerMajor = br.ReadByte();
                 m_VerMinor = br.ReadByte();
                 m_Width    = br.ReadInt32();
                 m_Height   = br.ReadInt32();
                 m_Cells    = new GATCell[m_Width * m_Height + 1];
                 for (int i = 0; i <= m_Width * m_Height - 1; i++)
                 {
                     m_Cells[i] = new GATCell(br);
                 }
             }
         }
     }
     catch
     {
         throw;
     }
 }
Esempio n. 36
0
        /** Deserializes links placed by the user */
        public virtual UserConnection[] DeserializeUserConnections()
        {
            System.IO.BinaryReader stream = readerStream;

            if (MoveToAnchor("UserConnections"))
            {
                int count = stream.ReadInt32();

                UserConnection[] userConnections = new UserConnection[count];

                for (int i = 0; i < count; i++)
                {
                    UserConnection conn = new UserConnection();
                    conn.p1 = new Vector3(stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle());
                    conn.p2 = new Vector3(stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle());

                    conn.doOverrideCost = stream.ReadBoolean();
                    conn.overrideCost   = stream.ReadInt32();

                    conn.oneWay        = stream.ReadBoolean();
                    conn.width         = stream.ReadSingle();
                    conn.type          = (ConnectionType)stream.ReadInt32();
                    userConnections[i] = conn;
                }
                return(userConnections);
            }
            else
            {
                return(new UserConnection[0]);
            }
        }
Esempio n. 37
0
        public void Load(System.IO.BinaryReader reader)
        {
            version = reader.ReadByte();
            if (version > VERSION)
            {
                throw new CacheException("Unknown CacheItem Version.", null, version);
            }

            name             = reader.ReadString();
            type             = reader.ReadString();
            pfd              = new Packages.PackedFileDescriptor();
            pfd.Type         = reader.ReadUInt32();
            pfd.Group        = reader.ReadUInt32();
            pfd.LongInstance = reader.ReadUInt64();
            influence        = reader.ReadInt32();
            score            = reader.ReadInt32();
            guid             = reader.ReadUInt32();
            folder           = reader.ReadString();


            int size = reader.ReadInt32();

            if (size == 0)
            {
                thumb = null;
            }
            else
            {
                byte[]       data = reader.ReadBytes(size);
                MemoryStream ms   = new MemoryStream(data);

                thumb = Image.FromStream(ms);
            }
        }
Esempio n. 38
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;
            }
        }
Esempio n. 39
0
        public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
        {
            System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
            this.fieldskip           = binaryReader.ReadBytes(4);
            this.Size                = binaryReader.ReadInt16();
            this.Count               = binaryReader.ReadInt16();
            this.fieldskip0          = binaryReader.ReadBytes(4);
            this.fieldskip1          = binaryReader.ReadBytes(4);
            this.ChildShapesSize     = binaryReader.ReadInt32();
            this.ChildShapesCapacity = binaryReader.ReadInt32();
            int i;

            for (i = 0; (i < 4); i = (i + 1))
            {
                this.ChildShapesStorage00[i] = new ChildShapesStorageBlock();
                pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.ChildShapesStorage00[i].ReadFields(binaryReader)));
            }
            this.MultisphereCount         = binaryReader.ReadInt32();
            this.VehiclePhantomShapeFlags = ((Flags)(binaryReader.ReadInt32()));
            this.fieldpad = binaryReader.ReadBytes(8);
            this.X0       = binaryReader.ReadSingle();
            this.X1       = binaryReader.ReadSingle();
            this.Y0       = binaryReader.ReadSingle();
            this.Y1       = binaryReader.ReadSingle();
            this.Z0       = binaryReader.ReadSingle();
            this.Z1       = binaryReader.ReadSingle();
            for (i = 0; (i < 4); i = (i + 1))
            {
                this.Multispheres00[i] = new MultispheresBlock();
                pointerQueue           = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.Multispheres00[i].ReadFields(binaryReader)));
            }
            return(pointerQueue);
        }
Esempio n. 40
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;
        }
        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();

        }
        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;
        }
Esempio n. 43
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();
     }
 }
Esempio n. 44
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;
            }
        }
Esempio n. 45
0
		public override void Decode()
		{
			MemoryStream stream = new MemoryStream(Data);
			BinaryReader reader = new BinaryReader(stream);
			this.ShapeId = reader.ReadInt32();
			this.Flags = reader.ReadInt32();
		}
Esempio n. 46
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();
            }
        }
        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;
        }
Esempio n. 48
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;
        }
Esempio n. 49
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();
                }

            }
Esempio n. 50
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);
            }
        }
Esempio n. 51
0
        //読み込み
        public virtual void OnRead(System.IO.BinaryReader reader)
        {
            //バージョンチェック
            int version = reader.ReadInt32();

            if (version == Version)
            {
                List <string> nameList = new List <string>();
                int           count    = reader.ReadInt32();
                for (int i = 0; i < count; ++i)
                {
                    string key    = reader.ReadString();
                    byte[] buffer = reader.ReadBytes(reader.ReadInt32());
                    nameList.Add(key);
                    BinaryUtil.BinaryRead(buffer, FindWindow(key).ReadPageData);
                }
                string currentWindowName = reader.ReadString();

                ChangeActiveWindows(nameList);
                ChangeCurrentWindow(currentWindowName);
            }
            else
            {
                Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.UnknownVersion, version));
            }
        }
Esempio n. 52
0
		public override void Decode()
		{
			MemoryStream stream = new MemoryStream(Data);
			BinaryReader reader = new BinaryReader(stream);
			this.NumShapes = reader.ReadInt32();
			this.LastShapeID = reader.ReadInt32();
		}
Esempio n. 53
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;
 }
Esempio n. 54
0
        /// <summary>
        /// Unserializes a BinaryStream into the Attributes of this Instance
        /// </summary>
        /// <param name="reader">The Stream that contains the FileData</param>
        public override void Unserialize(System.IO.BinaryReader reader)
        {
            tried   = false;
            version = reader.ReadUInt32();

            string name = reader.ReadString();
            uint   myid = reader.ReadUInt32();

            sgres.Unserialize(reader);
            sgres.BlockID = myid;

            if (Parent.Fast)
            {
                elements.Clear();
                links.Clear();
                groups.Clear();
                joints.Clear();
                return;
            }

            int count = reader.ReadInt32();

            elements.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcElement e = new GmdcElement(this);
                e.Unserialize(reader);
                elements.Add(e);
            }

            count = reader.ReadInt32();
            links.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcLink l = new GmdcLink(this);
                l.Unserialize(reader);
                links.Add(l);
            }

            count = reader.ReadInt32();
            groups.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcGroup g = new GmdcGroup(this);
                g.Unserialize(reader);
                groups.Add(g);
            }

            model.Unserialize(reader);

            count = reader.ReadInt32();
            joints.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcJoint s = new GmdcJoint(this);
                s.Unserialize(reader);
                joints.Add(s);
            }
        }
Esempio n. 55
0
        /// <summary>
        /// Read method implementation of IBinarySerializable interface
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        internal static Date Read(System.IO.BinaryReader reader)
        {
            int year  = reader.ReadInt32();
            int month = reader.ReadInt32();
            int day   = reader.ReadInt32();

            return(new Date(year, month, day));
        }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.CampaignID = binaryReader.ReadInt32();
     this.MapID      = binaryReader.ReadInt32();
     this.Path       = binaryReader.ReadString256();
     return(pointerQueue);
 }
Esempio n. 57
0
 public void Read(System.IO.BinaryReader br)
 {
     this.Icon.Read(br);
     this.Planes     = br.ReadInt16();
     this.BitCount   = br.ReadInt16();
     this.BytesInRes = br.ReadInt32();
     this.Offset     = br.ReadInt32();
 }
Esempio n. 58
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.NaturalPitch       = binaryReader.ReadInt16();
     this.BendBounds         = binaryReader.ReadInt32();
     this.MaxGainPitchBounds = binaryReader.ReadInt32();
     return(pointerQueue);
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.SingleAnimationReferenceFlags = ((Flags)(binaryReader.ReadInt32()));
     this.AnimationPeriod = binaryReader.ReadInt32();
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(20));
     return(pointerQueue);
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.Plane      = binaryReader.ReadVector3();
     this.LeftChild  = binaryReader.ReadInt32();
     this.RightChild = binaryReader.ReadInt32();
     return(pointerQueue);
 }