mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-08 09:10:11 +08:00
Fix length limitation
This commit is contained in:
parent
c854be95a7
commit
e30a1ea4b9
@ -41,7 +41,7 @@ inline fun BytePacketBuilder.writeShortLVByteArray(byteArray: ByteArray): Int {
|
||||
inline fun BytePacketBuilder.writeIntLVPacket(tag: UByte? = null, lengthOffset: ((Long) -> Long) = {it}, builder: BytePacketBuilder.() -> Unit): Int =
|
||||
BytePacketBuilder().apply(builder).build().use {
|
||||
if (tag != null) writeUByte(tag)
|
||||
val length = lengthOffset.invoke(it.remaining).coerceAtMostOrFail(0xFFFFL)
|
||||
val length = lengthOffset.invoke(it.remaining).coerceAtMostOrFail(0xFFFFFFFFL)
|
||||
writeInt(length.toInt())
|
||||
writePacket(it)
|
||||
return length.toInt()
|
||||
@ -50,7 +50,7 @@ inline fun BytePacketBuilder.writeIntLVPacket(tag: UByte? = null, lengthOffset:
|
||||
inline fun BytePacketBuilder.writeShortLVPacket(tag: UByte? = null, lengthOffset: ((Long) -> Long) = {it}, builder: BytePacketBuilder.() -> Unit): Int =
|
||||
BytePacketBuilder().apply(builder).build().use {
|
||||
if (tag != null) writeUByte(tag)
|
||||
val length = lengthOffset.invoke(it.remaining).coerceAtMostOrFail(0xFFFFL)
|
||||
val length = lengthOffset.invoke(it.remaining).coerceAtMostOrFail(0xFFFFFFFFL)
|
||||
writeUShort(length.toUShort())
|
||||
writePacket(it)
|
||||
return length.toInt()
|
||||
|
Loading…
Reference in New Issue
Block a user