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
         {
             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.º 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
        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);
            }
        }