diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/output.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/output.kt index 803e579a6..38077fe9e 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/output.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/output.kt @@ -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()