public static UInt64 ReadLengthedDataFromStream(EndianBinaryReader reader, Byte type)
        {
            if (type <= 1)
            {
                if (reader.CanRead(1))
                {
                    byte a = reader.ReadByte();
                    if (a <= 127)
                    {
                        return(a);
                    }

                    if ((Byte)(a + 80) <= 15)
                    {
                        return(GetLong(reader.ReadBytes(a - 175)));
                    }
                }
                return(0);
            }

            if (!reader.CanRead(1))
            {
                return(0);
            }

            byte b = reader.ReadByte();

            if (b <= 191)
            {
                return(b);
            }

            return((Byte)(b + 56) > 7 ? 0 : GetLong(reader.ReadBytes(b - 199)));
        }
        public static UInt64 ReadLengthedDataFromStream2(EndianBinaryReader reader, Byte type)
        {
            if (type <= 1)
            {
                if (reader.CanRead(1))
                {
                    byte b = reader.ReadByte();
                    if (b <= 127)
                    {
                        return(b);
                    }

                    if ((Byte)(b + 96) <= 15)
                    {
                        return(GetLong(reader.ReadBytes(b - 159)));
                    }

                    if ((Byte)(b + 112) <= 15)
                    {
                        return(GetLong(reader.ReadBytes(b - 143)));
                    }

                    if (b == 143)
                    {
                        return(0x8000000000000000);
                    }
                }
                return(0);
            }

            if (reader.CanRead(1))
            {
                byte b = reader.ReadByte();
                if (b <= 191)
                {
                    return(b);
                }

                if ((Byte)(b + 56) <= 7)
                {
                    return(GetLong(reader.ReadBytes(b - 199)));
                }

                if ((Byte)(b + 64) > 7)
                {
                    return(b == 208 ? 0x8000000000000000 : 0);
                }

                return(GetLong(reader.ReadBytes(b - 191)));
            }
            return(0);
        }
        public static Boolean ReadUnkBool(EndianBinaryReader reader, Byte type)
        {
            if (type > 1)
            {
                if (reader.CanRead(1))
                {
                    return(reader.ReadByte() == 1);
                }

                return(false);
            }

            if (reader.CanRead(1))
            {
                return(reader.ReadByte() == 129);
            }

            return(false);
        }
        public static Boolean ReadPayload(EndianBinaryReader reader, Byte type, out Byte[] data)
        {
            UInt64 a;

            if (type > 1)
            {
                a = ReadLengthedDataFromStream(reader, type);
                if (a == 0)
                {
                    data = new Byte[0];
                    return(true);
                }
            }
            else
            {
                byte b = reader.ReadByte();
                if (b == 133)
                {
                    a = ReadLengthedDataFromStream(reader, type);
                    if (a == 0)
                    {
                        data = new Byte[0];
                        return(true);
                    }
                }
                else
                {
                    data = new Byte[0];
                    return(false);
                }
            }

            if (reader.CanRead((UInt32)a))
            {
                data = reader.ReadBytes((Int32)a);
                return(true);
            }

            data = new Byte[0];
            return(false);
        }