From 7692862c7ce9d8a2042bce47758011a680ef5576 Mon Sep 17 00:00:00 2001 From: Graham Date: Fri, 21 May 2021 19:52:47 +0100 Subject: [PATCH] Add RequestWorldList packet Signed-off-by: Graham --- .../kotlin/org/openrs2/protocol/Protocol.kt | 4 +++- .../openrs2/protocol/login/LoginRequest.kt | 1 + .../protocol/login/RequestWorldListCodec.kt | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 protocol/src/main/kotlin/org/openrs2/protocol/login/RequestWorldListCodec.kt diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/Protocol.kt b/protocol/src/main/kotlin/org/openrs2/protocol/Protocol.kt index cd7c13ff70..d3e7980822 100644 --- a/protocol/src/main/kotlin/org/openrs2/protocol/Protocol.kt +++ b/protocol/src/main/kotlin/org/openrs2/protocol/Protocol.kt @@ -5,6 +5,7 @@ import org.openrs2.protocol.login.InitJaggrabConnectionCodec import org.openrs2.protocol.login.InitJs5RemoteConnectionCodec import org.openrs2.protocol.login.IpLimitCodec import org.openrs2.protocol.login.Js5OkCodec +import org.openrs2.protocol.login.RequestWorldListCodec import org.openrs2.protocol.login.ServerFullCodec public class Protocol(vararg codecs: PacketCodec<*>) { @@ -30,7 +31,8 @@ public class Protocol(vararg codecs: PacketCodec<*>) { public companion object { public val LOGIN_UPSTREAM: Protocol = Protocol( InitJs5RemoteConnectionCodec, - InitJaggrabConnectionCodec + InitJaggrabConnectionCodec, + RequestWorldListCodec ) public val LOGIN_DOWNSTREAM: Protocol = Protocol( Js5OkCodec, diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/login/LoginRequest.kt b/protocol/src/main/kotlin/org/openrs2/protocol/login/LoginRequest.kt index 5e4ca46d0b..490fb66f2a 100644 --- a/protocol/src/main/kotlin/org/openrs2/protocol/login/LoginRequest.kt +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/LoginRequest.kt @@ -5,4 +5,5 @@ import org.openrs2.protocol.Packet public sealed class LoginRequest : Packet { public data class InitJs5RemoteConnection(public val build: Int) : LoginRequest() public object InitJaggrabConnection : LoginRequest() + public data class RequestWorldList(public val checksum: Int) : LoginRequest() } diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/login/RequestWorldListCodec.kt b/protocol/src/main/kotlin/org/openrs2/protocol/login/RequestWorldListCodec.kt new file mode 100644 index 0000000000..fb0392e542 --- /dev/null +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/RequestWorldListCodec.kt @@ -0,0 +1,19 @@ +package org.openrs2.protocol.login + +import io.netty.buffer.ByteBuf +import org.openrs2.protocol.PacketCodec + +public object RequestWorldListCodec : PacketCodec( + type = LoginRequest.RequestWorldList::class.java, + opcode = 23, + length = 4 +) { + override fun decode(input: ByteBuf): LoginRequest.RequestWorldList { + val checksum = input.readInt() + return LoginRequest.RequestWorldList(checksum) + } + + override fun encode(input: LoginRequest.RequestWorldList, output: ByteBuf) { + output.writeInt(input.checksum) + } +}