forked from openrs2/openrs2
parent
8052561dcf
commit
f6324198ef
@ -0,0 +1,31 @@ |
||||
package org.openrs2.archive.world |
||||
|
||||
import io.netty.buffer.ByteBuf |
||||
import org.openrs2.buffer.readString |
||||
|
||||
public data class World( |
||||
public val id: Int, |
||||
public val flags: Int, |
||||
public val hostname: String, |
||||
public val activity: String, |
||||
public val country: Int, |
||||
public val players: Int |
||||
) { |
||||
public val isBeta: Boolean |
||||
get() = (flags and FLAG_BETA) != 0 |
||||
|
||||
public companion object { |
||||
private const val FLAG_BETA = 0x10000 |
||||
|
||||
public fun read(buf: ByteBuf): World { |
||||
val id = buf.readUnsignedShort() |
||||
val flags = buf.readInt() |
||||
val hostname = buf.readString() |
||||
val activity = buf.readString() |
||||
val country = buf.readUnsignedByte().toInt() |
||||
val players = buf.readShort().toInt() |
||||
|
||||
return World(id, flags, hostname, activity, country, players) |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,22 @@ |
||||
package org.openrs2.archive.world |
||||
|
||||
import io.netty.buffer.ByteBuf |
||||
|
||||
public data class WorldList( |
||||
public val worlds: List<World> |
||||
) { |
||||
public companion object { |
||||
public fun read(buf: ByteBuf): WorldList { |
||||
buf.skipBytes(4) |
||||
|
||||
val count = buf.readUnsignedShort() |
||||
val worlds = buildList(count) { |
||||
for (i in 0 until count) { |
||||
add(World.read(buf)) |
||||
} |
||||
} |
||||
|
||||
return WorldList(worlds) |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue