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; }
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); }
protected override void Parse(EndianBinaryReader r) { X = r.ReadInt32(); Z = r.ReadInt32(); //int ArraySize = ReadVarInt(r); throw new NotImplementedException(); }
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); }
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)); }
protected override void Parse(EndianBinaryReader r) { EID = ReadVarInt(r); Yaw = r.ReadSByte() * Math.PI / 128; Pitch = r.ReadSByte() * Math.PI / 128; Unknown = r.ReadBoolean(); }
protected override void Parse(EndianBinaryReader r) { EID = ReadVarInt(r); Title = ReadString8(r); Position = CoordInt.Read(r); FaceDirection = (Face)r.ReadByte(); }
// 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(); }
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); }
protected override void Parse(EndianBinaryReader r) { SlotID = r.ReadInt16(); if (SlotID < 0 && SlotID > 8) throw new InvalidOperationException("Invalid holding slot id: " + SlotID); }
protected override void Parse(EndianBinaryReader r) { Position = new CoordDouble (); Position.X = r.ReadDouble (); Position.Y = r.ReadDouble (); Position.Z = r.ReadDouble (); OnGround = r.ReadByte (); }
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; }
protected override void Parse(EndianBinaryReader r) { Locale = ReadString8(r); ViewDistance = r.ReadByte(); ChatFlags = r.ReadByte(); ChatColors = r.ReadBoolean(); DisplayedSkinParts = r.ReadByte(); }
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 }
protected override void Parse(EndianBinaryReader r) { Name = ReadString8(r); Position = ReadInt8(r); Volume = r.ReadSingle(); Pitch = r.ReadByte(); //Category = (SoundCategoy)r.ReadByte(); }
protected override void Parse(EndianBinaryReader r) { Name = ReadString8(r); Action = (ScoreAction)r.ReadSByte(); if (Action == ScoreAction.Remove) return; Board = ReadString8(r); Value = ReadVarInt(r); }
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 }
protected override void Parse(EndianBinaryReader r) { Board = ReadString8(r); Mode = (ScoreAction)r.ReadSByte(); if (Mode == ScoreAction.Remove) return; Value = ReadString8(r); Type = ReadString8(r); }
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(); }
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; }
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); }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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(); }
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 }
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]; } }