Open-source multiplayer game server compatible with the RuneScape client https://www.openrs2.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

33 lines
914 B

package org.openrs2.cache.config.varbit
import io.netty.buffer.ByteBuf
import org.openrs2.cache.config.ConfigType
public class VarbitType(id: Int) : ConfigType(id) {
public var baseVar: Int = 0
public var startBit: Int = 0
public var endBit: Int = 0
override fun read(buf: ByteBuf, code: Int) {
when (code) {
1 -> {
baseVar = buf.readUnsignedShort()
startBit = buf.readUnsignedByte().toInt()
endBit = buf.readUnsignedByte().toInt()
}
else -> throw IllegalArgumentException("Unsupported config code: $code")
}
}
override fun write(buf: ByteBuf) {
if (baseVar != 0 || startBit != 0 || endBit != 0) {
buf.writeByte(1)
buf.writeShort(baseVar)
buf.writeByte(startBit)
buf.writeByte(endBit)
}
buf.writeByte(0)
}
}