```fun ByteBuf.readVarInt(): Int { var value =...
# announcements
c
Copy code
fun ByteBuf.readVarInt(): Int {
    var value = 0
    var i = 0
    var b: Int
    while ((b = byteBuf.readByte().toInt()) and 0x80 != 0) {
        value = value or (b and 0x7F shl i)
        i += 7
        if (i > 35) {
            throw IllegalArgumentException("Variable length quantity is too long")
        }
    }
    return value or (b shl i)
}