Exemplo n.º 1
0
 public static int DecodeInt(SendTableProperty prop, IBitStream reader)
 {
     if (prop.Flags.HasFlagFast(SendPropertyFlags.VarInt))
     {
         if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned))
         {
             return((int)reader.ReadVarInt());
         }
         else
         {
             Trace.WriteLine("signed varints are not implemented. BAAAAAAD.", "PropDecoder:DecodeInt()");
             return((int)reader.ReadVarInt());
         }
     }
     else
     {
         if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned))
         {
             return((int)reader.ReadInt(prop.NumberOfBits));
         }
         else
         {
             return(reader.ReadSignedInt(prop.NumberOfBits));
         }
     }
 }
Exemplo n.º 2
0
 public static int DecodeInt(SendTableProperty prop, IBitStream reader)
 {
     if (prop.Flags.HasFlagFast(SendPropertyFlags.VarInt))
     {
         if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned))
         {
             return((int)reader.ReadVarInt());
         }
         else
         {
             return((int)reader.ReadSignedVarInt());
         }
     }
     else
     {
         if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned))
         {
             return((int)reader.ReadInt(prop.NumberOfBits));
         }
         else
         {
             return(reader.ReadSignedInt(prop.NumberOfBits));
         }
     }
 }
Exemplo n.º 3
0
 static int DecodeInt(SendTableProperty prop, IBitStream reader)
 {
     if ((prop.Flags & SendPropertyFlags.VarInt) == SendPropertyFlags.VarInt)
     {
         if ((prop.Flags & SendPropertyFlags.Unsigned) == SendPropertyFlags.Unsigned)
         {
             return((int)reader.ReadVarInt());
         }
         else
         {
             // TODO implement
             throw new NotImplementedException("signed varints are not implemented. BAAAAAAD.");
             //return (int)reader.ReadVarInt();
         }
     }
     else
     {
         if ((prop.Flags & SendPropertyFlags.Unsigned) == SendPropertyFlags.Unsigned)
         {
             return((int)reader.ReadInt(prop.NumberOfBits));
         }
         else
         {
             return(reader.ReadSignedInt(prop.NumberOfBits));
         }
     }
 }
Exemplo n.º 4
0
        public uint ReadVarInt()
        {
            var a = A.ReadVarInt();
            var b = B.ReadVarInt();

            Verify(a, b);
            return(a);
        }
Exemplo n.º 5
0
 public static int DecodeInt(SendTableProperty prop, IBitStream reader)
 {
     if (prop.Flags.HasFlagFast(SendPropertyFlags.VarInt)) {
         if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned)) {
             return (int)reader.ReadVarInt();
         } else {
             Trace.WriteLine("signed varints are not implemented. BAAAAAAD.", "PropDecoder:DecodeInt()");
             return (int)reader.ReadVarInt();
         }
     } else {
         if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned)) {
             return (int)reader.ReadInt(prop.NumberOfBits);
         } else {
             return reader.ReadSignedInt(prop.NumberOfBits);
         }
     }
 }
Exemplo n.º 6
0
		public static int DecodeInt(SendTableProperty prop, IBitStream reader)
		{
			if (prop.Flags.HasFlagFast(SendPropertyFlags.VarInt)) {
				if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned)) {
					return (int)reader.ReadVarInt();
				} else {
					return (int)reader.ReadSignedVarInt();
				}
			} else {
				if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned)) {
					return (int)reader.ReadInt(prop.NumberOfBits);
				} else {
					return reader.ReadSignedInt(prop.NumberOfBits);
				}
			}
		}
Exemplo n.º 7
0
        public static long DecodeInt64(SendTableProperty prop, IBitStream reader)
        {
            if (prop.Flags.HasFlagFast(SendPropertyFlags.VarInt))
            {
                if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned))
                {
                    return(reader.ReadVarInt());
                }
                else
                {
                    return(reader.ReadSignedVarInt());
                }
            }
            else
            {
                bool isNegative = false;
                uint low        = 0;
                uint high       = 0;

                if (prop.Flags.HasFlag(SendPropertyFlags.Unsigned))
                {
                    low  = reader.ReadInt(32);
                    high = reader.ReadInt(prop.NumberOfBits - 32);
                }
                else
                {
                    isNegative = reader.ReadBit();
                    low        = reader.ReadInt(32);
                    high       = reader.ReadInt(prop.NumberOfBits - 32 - 1);
                }

                long result = ((long)high << 32) | low;

                if (isNegative)
                {
                    result = -result;
                }

                return(result);
            }
        }
Exemplo n.º 8
0
        public static uint ReadSignedVarInt(this IBitStream bs)
        {
            uint result = bs.ReadVarInt();

            return((uint)((result >> 1) ^ -(result & 1)));
        }