Add InvType

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent 62abcbad8c
commit 60ecda74ec
  1. 24
      cache-550/src/main/kotlin/org/openrs2/cache/config/inv/InvType.kt
  2. 19
      cache-550/src/main/kotlin/org/openrs2/cache/config/inv/InvTypeList.kt

@ -0,0 +1,24 @@
package org.openrs2.cache.config.inv
import io.netty.buffer.ByteBuf
import org.openrs2.cache.config.ConfigType
public class InvType(id: Int) : ConfigType(id) {
public var size: Int = 0
override fun read(buf: ByteBuf, code: Int) {
when (code) {
2 -> size = buf.readUnsignedShort()
else -> throw IllegalArgumentException("Unsupported config code: $code")
}
}
override fun write(buf: ByteBuf) {
if (size != 0) {
buf.writeByte(2)
buf.writeShort(size)
}
buf.writeByte(0)
}
}

@ -0,0 +1,19 @@
package org.openrs2.cache.config.inv
import org.openrs2.cache.Cache
import org.openrs2.cache.Js5Archive
import org.openrs2.cache.Js5ConfigGroup
import org.openrs2.cache.config.GroupConfigTypeList
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
public class InvTypeList @Inject constructor(cache: Cache) : GroupConfigTypeList<InvType>(
cache,
archive = Js5Archive.CONFIG,
group = Js5ConfigGroup.INVTYPE
) {
override fun allocate(id: Int): InvType {
return InvType(id)
}
}
Loading…
Cancel
Save