ReadDouble() public method

Reads a double-precision floating-point value from the stream, using the bit converter for this reader. 8 bytes are read.
public ReadDouble ( ) : double
return double
Esempio n. 1
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 ();
		}
        protected override void Parse(EndianBinaryReader r)
        {
            Position = new CoordDouble();
            Position.X = r.ReadDouble();
            Position.Y = r.ReadDouble();
            Position.Z = r.ReadDouble();
            Yaw = r.ReadSingle() * Math.PI / 180;
            Pitch = r.ReadSingle() * Math.PI / 180;
            OnGround = r.ReadBoolean();
#if DEBUG
            //Console.WriteLine("PPL: " + Pitch);
#endif
        }
        protected override void Parse(EndianBinaryReader r)
        {
            Position = new CoordDouble();
            Position.X = r.ReadDouble();
            Position.Y = r.ReadDouble();
            Position.Z = r.ReadDouble();
            Yaw = r.ReadSingle() * Math.PI / 180;
            Pitch = r.ReadSingle() * Math.PI / 180;
            Relative = r.ReadByte();

            //Console.WriteLine("Parsed: " + this);
            //Debug.WriteLine("Parsed: " + this);
        }
Esempio n. 4
0
        public void Parse(EndianBinaryReader reader, uint size)
        {
            var maxReadPos = reader.BaseStream.Position + size;
            while(reader.BaseStream.Position < maxReadPos)
            {
                if (objectStack.Count != 0)
                {
                    var count = reader.ReadUInt16();
                    var propString = "";
                    for (var i = 0; i < count; i++)
                    {
                        propString += (char) reader.ReadByte();
                    }
                    objectStack.Peek().CurrentProperty = propString;
                }

                var type = (Globals.Amf0Types)reader.ReadByte();

                switch (type)
                {
                    case Globals.Amf0Types.Number:
                        {
                            var value = reader.ReadDouble();
                            if(objectStack.Count != 0)
                            {
                                objectStack.Peek().Numbers.Add(objectStack.Peek().CurrentProperty, value);
                            }
                            else
                            {
                                amfData.Numbers.Add(value);
                            }
                        }
                        break;
                    case Globals.Amf0Types.Boolean:
                        {
                            var value = reader.ReadBoolean();
                            if (objectStack.Count != 0)
                            {
                                objectStack.Peek().Booleans.Add(objectStack.Peek().CurrentProperty, value);
                            }
                            else
                            {
                                amfData.Booleans.Add(value);
                            }
                        }
                        break;
                    case Globals.Amf0Types.String:
                        {
                            var count = reader.ReadUInt16();
                            var pushString = "";
                            for (var i = 0; i < count; i++)
                            {
                                pushString += (char) reader.ReadByte();
                            }

                            if (objectStack.Count != 0)
                            {
                                objectStack.Peek().Strings.Add(objectStack.Peek().CurrentProperty, pushString);
                            }
                            else
                            {
                                amfData.Strings.Add(pushString);
                            }
                        }
                        break;
                    case Globals.Amf0Types.Null:

                        if (objectStack.Count != 0)
                        {
                            objectStack.Peek().Nulls++;
                        }
                        else
                        {
                            amfData.Nulls++;
                        }
                        break;
                    case Globals.Amf0Types.Object:
                    case Globals.Amf0Types.Array:
                        {
                            if(type == Globals.Amf0Types.Array)
                            {
                                var arrayLength = reader.ReadInt32();
                            }
                            var objectAdd = new AmfObject();
                            objectStack.Push(objectAdd);
                        }
                        break;
                    case Globals.Amf0Types.ObjectEnd:
                        {
                            if(objectStack.Count == 1)
                            {
                                amfData.Objects.Add(objectStack.Pop());
                            }
                            else if(objectStack.Count > 1)
                            {
                                var mostRecentObject = objectStack.Pop();
                                objectStack.Peek().Objects.Add(objectStack.Peek().CurrentProperty, mostRecentObject);
                            }
                        }
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
                /*
                switch (type)
                {
                    case Amf0Types.Array:
                    case Amf0Types.Object:
                        {
                            if(type == Amf0Types.Array)
                            {
                                var arrayLength = reader.ReadInt32();
                                Console.WriteLine("Array:" + arrayLength);
                            }
                            bool hasProperty = false;
                            string property = "";
                            var objectAdd = new AmfObject();
                            while (reader.BaseStream.Position < maxReadPos)
                            {
                                if(!hasProperty)
                                {
                                    property = "";
                                    var propertyStringLength = reader.ReadUInt16();
                                    for (var i = 0; i < propertyStringLength; i++)
                                    {
                                        property += (char)reader.ReadByte();
                                    }
                                    hasProperty = true;
                                }

                                if (hasProperty == true)
                                {
                                    if(property.Length == 0)
                                    {
                                        amfData.Objects.Add(objectAdd);

                                        break;
                                    }
                                    var objtype = (Amf0Types)reader.ReadByte();
                                    parseType(objtype, reader, ref objectAdd.Nulls, objectNumbers: objectAdd.Numbers,
                                              objectBooleans: objectAdd.Booleans, objectStrings: objectAdd.Strings,
                                              property: property);
                                    hasProperty = false;
                                }
                            }
                        }
                        break;
                    default:
                        parseType(type, reader, ref amfData.Nulls, amfData.Numbers, amfData.Booleans, amfData.Strings);
                        break;
                }*/
            }
        }
Esempio n. 5
0
 //jesus f**k note to self: fix this
 private static void parseType(Globals.Amf0Types type, EndianBinaryReader reader,
     ref uint Nulls,
     List<double> Numbers = null,
     List<bool> Booleans = null,
     List<string> Strings = null,
     Dictionary<string, string> objectStrings = null,
     Dictionary<string, double> objectNumbers = null,
     Dictionary<string, bool> objectBooleans = null,
     string property = "")
 {
     switch (type)
     {
         case Globals.Amf0Types.Number:
             if (Numbers != null)
                 Numbers.Add(reader.ReadDouble());
             else
                 objectNumbers.Add(property, reader.ReadDouble());
             break;
         case Globals.Amf0Types.Boolean:
             if (Booleans != null)
                 Booleans.Add(reader.ReadBoolean());
             else
                 objectBooleans.Add(property, reader.ReadBoolean());
             break;
         case Globals.Amf0Types.String:
             {
                 var count = reader.ReadUInt16();
                 var pushString = "";
                 for (var i = 0; i < count; i++)
                 {
                     pushString += (char) reader.ReadByte();
                 }
                 if (Strings != null)
                     Strings.Add(pushString);
                 else
                     objectStrings.Add(property, pushString);
             }
             break;
         case Globals.Amf0Types.Null:
             Nulls++;
             break;
         case Globals.Amf0Types.Array:
             break;
         case Globals.Amf0Types.ObjectEnd:
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
Esempio n. 6
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);
 }