Commit 493c52ce authored by Him188's avatar Him188

Try to fix VerifyError

parent 01963f35
...@@ -67,13 +67,15 @@ abstract class PacketFactory<out TPacket : Packet, TDecrypter : Decrypter>(val d ...@@ -67,13 +67,15 @@ abstract class PacketFactory<out TPacket : Packet, TDecrypter : Decrypter>(val d
companion object { companion object {
private val sequenceId: AtomicInt = atomic(1) private val sequenceId: AtomicInt = atomic(1)
fun atomicNextSequenceId(): UShort { fun atomicNextSequenceId(): UShort = atomicNextSequenceId0().toUShort()
private fun atomicNextSequenceId0(): Int {
val id = sequenceId.getAndAdd(1) val id = sequenceId.getAndAdd(1)
if (id > Short.MAX_VALUE.toInt() * 2) { if (id > Short.MAX_VALUE.toInt() * 2) {
sequenceId.value = 0 sequenceId.value = 0
return atomicNextSequenceId() return sequenceId.getAndAdd(1)
} }
return id.toUShort() return id
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment