Equivalent of System.IO.BinaryReader, but with either endianness, depending on the EndianBitConverter it is constructed with. No data is buffered in the reader; the client may seek within the stream at will.
Inheritance: IDisposable
コード例 #1
0
        internal long ReadLongBuffer(byte[] buffer, long len, EndianBinaryReader reader)
        {
            // TODO check whole function

            byte[] temp = (len > int.MaxValue ? new byte[int.MaxValue] : null);

            long byt = 0;
            while (byt < len)
            {
                int n;
                long missing = len - byt;
                int missing32 = (missing > int.MaxValue ? int.MaxValue : (int)missing);
                if (temp != null) // Use a temporary buffer so offsets fit in an int
                {
                    n = reader.Read(temp, 0, missing32);
                    Array.Copy(temp, 0, buffer, byt, n);
                }
                else // Total package is shorter than int.MaxValue
                {
                    n = reader.Read(buffer, (int)byt, (int)missing);
                }
                byt += n;
            }

            return byt;
        }
コード例 #2
0
 protected override void Parse(EndianBinaryReader r)
 {
     int count = ReadVarInt(r);
     EIDs = new int[count];
     for (int i = 0; i < count; i++)
         EIDs [i] = ReadVarInt(r);
 }
コード例 #3
0
 protected override void Parse(EndianBinaryReader r)
 {
     X = r.ReadInt32();
     Z = r.ReadInt32();
     //int ArraySize = ReadVarInt(r);
     throw new NotImplementedException();
 }
コード例 #4
0
 protected override void Parse(EndianBinaryReader r)
 {
     EID = ReadVarInt(r);
     int count = r.ReadInt32();
     //Console.Write("DEBx2C: " + EID + " ");
     for(int n = 0; n < count; n++)
     {
         var p = new Property();
         p.Key = ReadString8(r);
         p.Val = r.ReadDouble();
         int sub = ReadVarInt(r);
         p.List = new List<PropData>();
         for (int s = 0; s < sub; s++)
         {
             var sd = new PropData();
             sd.UUIDpart1 = r.ReadInt64();
             sd.UUIDpart2 = r.ReadInt64();
             sd.Amount = r.ReadDouble();
             sd.Operation = r.ReadByte();
             p.List.Add(sd);
         }
         Properties.Add(p);
     }
     //Debug.WriteLine(this);
 }
コード例 #5
0
ファイル: TabComplete.cs プロジェクト: mctraveler/MineSharp
 protected override void Parse(EndianBinaryReader r)
 {
     int count = ReadVarInt(r);
     Alternatives = new List<string>(count);
     for (int n = 0; n < count; n++)
         Alternatives.Add(ReadString8(r));
 }
コード例 #6
0
ファイル: EntityLook.cs プロジェクト: mctraveler/MineSharp
 protected override void Parse(EndianBinaryReader r)
 {
     EID = ReadVarInt(r);
     Yaw = r.ReadSByte() * Math.PI / 128;
     Pitch = r.ReadSByte() * Math.PI / 128;
     Unknown = r.ReadBoolean();
 }
コード例 #7
0
ファイル: SpawnPainting.cs プロジェクト: mctraveler/MineSharp
 protected override void Parse(EndianBinaryReader r)
 {
     EID = ReadVarInt(r);
     Title = ReadString8(r);
     Position = CoordInt.Read(r);
     FaceDirection = (Face)r.ReadByte();
 }
コード例 #8
0
ファイル: SectionHeader.cs プロジェクト: xxy1991/cozy
        // TODO: make elf consts file with things like SHT_LOUSER
        internal SectionHeader(EndianBinaryReader reader, Class elfClass, IStringTable table = null)
        {
            this.reader = reader;
            this.table = table;
			this.elfClass = elfClass;
            ReadSectionHeader();
        }
コード例 #9
0
ファイル: SetExperience.cs プロジェクト: mctraveler/MineSharp
        protected override void Parse(EndianBinaryReader r)
        {
			//Console.WriteLine (BitConverter.ToString (r.ReadBytes (50)));
			this.LevelExperience = r.ReadSingle ();
            this.Level = ReadVarInt(r);
            this.TotalExperience = ReadVarInt(r);
		}
コード例 #10
0
        protected override void Parse(EndianBinaryReader r)
        {
            SlotID = r.ReadInt16();

            if (SlotID < 0 && SlotID > 8)
                throw new InvalidOperationException("Invalid holding slot id: " + SlotID);
        }
コード例 #11
0
        protected override void Parse(EndianBinaryReader r)
        {
			Position = new CoordDouble ();
			Position.X = r.ReadDouble ();
			Position.Y = r.ReadDouble ();
			Position.Z = r.ReadDouble ();
			OnGround = r.ReadByte ();
		}
コード例 #12
0
 protected override void Parse(EndianBinaryReader r)
 {
     EID = ReadVarInt(r);
     Velocity = new CoordDouble();
     Velocity.X = ((double)r.ReadInt16()) / scale;
     Velocity.Y = ((double)r.ReadInt16()) / scale;
     Velocity.Z = ((double)r.ReadInt16()) / scale;
 }
コード例 #13
0
 protected override void Parse(EndianBinaryReader r)
 {
     Locale = ReadString8(r);
     ViewDistance = r.ReadByte();
     ChatFlags = r.ReadByte();
     ChatColors = r.ReadBoolean();
     DisplayedSkinParts = r.ReadByte();
 }
コード例 #14
0
ファイル: EntityHeadYaw.cs プロジェクト: mctraveler/MineSharp
        protected override void Parse(EndianBinaryReader r)
        {
            EID = ReadVarInt(r);
            Yaw = r.ReadSByte() * Math.PI / 128;
#if DEBUG
            //Console.WriteLine("===== " + EID + ": " + Yaw.ToString("0.0"));
#endif
        }
コード例 #15
0
ファイル: SoundEffect.cs プロジェクト: mctraveler/MineSharp
 protected override void Parse(EndianBinaryReader r)
 {
     Name = ReadString8(r);
     Position = ReadInt8(r);
     Volume = r.ReadSingle();
     Pitch = r.ReadByte();
     //Category = (SoundCategoy)r.ReadByte();
 }
コード例 #16
0
 protected override void Parse(EndianBinaryReader r)
 {
     Name = ReadString8(r);
     Action = (ScoreAction)r.ReadSByte();
     if (Action == ScoreAction.Remove)
         return;
     Board = ReadString8(r);
     Value = ReadVarInt(r);
 }
コード例 #17
0
ファイル: EntityStatus.cs プロジェクト: mctraveler/MineSharp
 protected override void Parse(EndianBinaryReader r)
 {
     EID = r.ReadInt32();
     Status = (EntityStatuses)r.ReadByte();
     #if DEBUGPACKET
     if (Status.ToString() == ((int)Status).ToString())
         throw new NotImplementedException(Status.ToString());
     #endif
 }
コード例 #18
0
 protected override void Parse(EndianBinaryReader r)
 {
     Board = ReadString8(r);
     Mode = (ScoreAction)r.ReadSByte();
     if (Mode == ScoreAction.Remove)
         return;
     Value = ReadString8(r);
     Type = ReadString8(r);
 }
コード例 #19
0
 protected override void Parse(EndianBinaryReader r)
 {
     EID = ReadVarInt(r);
     Delta = new CoordDouble();
     Delta.X = ((double)r.ReadSByte()) / scale;
     Delta.Y = ((double)r.ReadSByte()) / scale;
     Delta.Z = ((double)r.ReadSByte()) / scale;
     OnGround = r.ReadBoolean();
 }
コード例 #20
0
 protected override void Parse(EndianBinaryReader r)
 {
     EID = ReadVarInt(r);
     Type = r.ReadSByte();
     Position = new CoordDouble();
     Position.X = ((double)r.ReadInt32()) / 32;
     Position.Y = ((double)r.ReadInt32()) / 32;
     Position.Z = ((double)r.ReadInt32()) / 32;
 }
コード例 #21
0
ファイル: WindowClick.cs プロジェクト: mctraveler/MineSharp
 protected override void Parse(EndianBinaryReader r)
 {
     WindowID = r.ReadByte();
     Slot = r.ReadInt16();
     RightClick = r.ReadSByte();
     ActionID = r.ReadInt16();
     Shift = r.ReadSByte();
     Item = SlotItem.Read(r);
 }
コード例 #22
0
 protected override void Parse(EndianBinaryReader r)
 {
     EID = ReadVarInt(r);
     Effect = (PlayerEffects)r.ReadSByte();
     #if DEBUGPACKET
     if (Effect.ToString() == ((int)Effect).ToString())
         throw new NotImplementedException(Effect.ToString());
     #endif
 }
コード例 #23
0
 protected override void Parse(EndianBinaryReader r)
 {
     Reason = (GameState)r.ReadByte();
     Value = r.ReadSingle();
     #if DEBUGPACKET
     if (Reason.ToString() == ((int)Reason).ToString())
         throw new NotImplementedException(Reason.ToString());
     #endif
 }
コード例 #24
0
ファイル: PlayerLook.cs プロジェクト: mctraveler/MineSharp
        protected override void Parse(EndianBinaryReader r)
        {
			Yaw = r.ReadSingle () * Math.PI / 180;
			Pitch = r.ReadSingle () * Math.PI / 180;
			OnGround = r.ReadBoolean ();
#if DEBUG
			//Console.WriteLine("P L: " + Pitch);
#endif
		}
コード例 #25
0
ファイル: EntityAction.cs プロジェクト: mctraveler/MineSharp
 protected override void Parse(EndianBinaryReader r)
 {
     EID = ReadVarInt(r);
     Action = (Actions)ReadVarInt(r);
     JumpBoost = ReadVarInt(r);
     #if DEBUGPACKET
     if (Action.ToString() == ((int)Action).ToString())
         throw new NotImplementedException(Action.ToString());
     #endif
 }
コード例 #26
0
ファイル: Animation.cs プロジェクト: mctraveler/MineSharp
        protected override void Parse(EndianBinaryReader r)
        {
            EID = ReadVarInt(r);
            Animate = (Animations)r.ReadByte();

            #if DEBUGPACKET
            if (Animate.ToString() == ((int)Animate).ToString())
                throw new NotImplementedException(Animate.ToString());
            #endif

        }
コード例 #27
0
ファイル: BlockChange.cs プロジェクト: mctraveler/MineSharp
 protected override void Parse(EndianBinaryReader r)
 {
     Position = CoordInt.Read(r);
     int val = ReadVarInt(r);
     BlockType = (BlockID)(val >> 4);
     Metadata = (byte)(val & 0x0F);
     #if DEBUGPACKET
     if (BlockType.ToString() == ((int)BlockType).ToString())
         throw new NotImplementedException(BlockType.ToString());
     #endif
 }
コード例 #28
0
ファイル: ChunkDataBulk.cs プロジェクト: mctraveler/MineSharp
            public UItem(EndianBinaryReader r)
            {
                X = r.ReadInt32();
                Z = r.ReadInt32();
                OccupiedBitmap = r.ReadInt16();
                AdditionalBitmap = r.ReadInt16();
#if DEBUG
                if (AdditionalBitmap != 0)
                    Log.WriteServer("AdditionalData: " + AdditionalBitmap.ToString("X"));
#endif
            }
コード例 #29
0
        protected override void Parse(EndianBinaryReader r)
        {
			EID = ReadVarInt(r);
			Delta = new CoordDouble ();
			Delta.X = ((double)r.ReadSByte ()) / 32;
			Delta.Y = ((double)r.ReadSByte ()) / 32;
			Delta.Z = ((double)r.ReadSByte ()) / 32;
			Yaw = r.ReadSByte () * Math.PI / 128;
			Pitch = r.ReadSByte () * Math.PI / 128;
            OnGround = r.ReadBoolean();
		}
コード例 #30
0
ファイル: BlockAction.cs プロジェクト: mctraveler/MineSharp
        protected override void Parse(EndianBinaryReader r)
        {
            Position = CoordInt.Read(r);
            TypeState = r.ReadByte();
            PitchDirection = r.ReadByte();
            BlockType = (BlockID)ReadVarInt(r);

            #if DEBUGPACKET
            if (BlockType.ToString() == ((int)BlockType).ToString())
                throw new NotImplementedException(BlockType.ToString());
            #endif
        }
コード例 #31
0
 private void ReadLength()
 {
     lenBuffer = new byte[4];
     using (MiscUtil.IO.EndianBinaryReader reader = new MiscUtil.IO.EndianBinaryReader(EndianBitConverter.Big, new MemoryStream(incomingBuffer), Encoding.UTF8))
     {
         int len = reader.ReadInt32();
         if (len < 0 || len >= ClientConnection.packetLen)
         {
             throw new IOException("Packet len " + len + " is out of range!");
         }
         incomingBuffer = new byte[len];
     }
 }