From 7c6ccbf5562668880cf1cec916ab56c950b629b5 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 24 Jul 2022 17:23:23 +0100 Subject: [PATCH] Add CreateCheckDateOfBirthCountry packet --- .../org/openrs2/protocol/ProtocolModule.kt | 2 ++ .../CreateCheckDateOfBirthCountryCodec.kt | 30 +++++++++++++++++++ .../protocol/login/upstream/LoginRequest.kt | 5 ++++ 3 files changed, 37 insertions(+) create mode 100644 protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/CreateCheckDateOfBirthCountryCodec.kt diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/ProtocolModule.kt b/protocol/src/main/kotlin/org/openrs2/protocol/ProtocolModule.kt index 8417994b21..25c38b7161 100644 --- a/protocol/src/main/kotlin/org/openrs2/protocol/ProtocolModule.kt +++ b/protocol/src/main/kotlin/org/openrs2/protocol/ProtocolModule.kt @@ -13,6 +13,7 @@ import org.openrs2.protocol.login.downstream.Js5OkCodec import org.openrs2.protocol.login.downstream.LoginDownstream import org.openrs2.protocol.login.downstream.ServerFullCodec import org.openrs2.protocol.login.upstream.CheckWorldSuitabilityCodec +import org.openrs2.protocol.login.upstream.CreateCheckDateOfBirthCountryCodec import org.openrs2.protocol.login.upstream.InitCrossDomainConnectionCodec import org.openrs2.protocol.login.upstream.InitGameConnectionCodec import org.openrs2.protocol.login.upstream.InitJaggrabConnectionCodec @@ -32,6 +33,7 @@ public object ProtocolModule : AbstractModule() { InitGameConnectionCodec::class.java, InitJs5RemoteConnectionCodec::class.java, InitJaggrabConnectionCodec::class.java, + CreateCheckDateOfBirthCountryCodec::class.java, RequestWorldListCodec::class.java, CheckWorldSuitabilityCodec::class.java, InitCrossDomainConnectionCodec::class.java diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/CreateCheckDateOfBirthCountryCodec.kt b/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/CreateCheckDateOfBirthCountryCodec.kt new file mode 100644 index 0000000000..579ea3212f --- /dev/null +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/CreateCheckDateOfBirthCountryCodec.kt @@ -0,0 +1,30 @@ +package org.openrs2.protocol.login.upstream + +import io.netty.buffer.ByteBuf +import org.openrs2.crypto.StreamCipher +import org.openrs2.protocol.PacketCodec +import java.time.LocalDate +import javax.inject.Singleton + +@Singleton +public class CreateCheckDateOfBirthCountryCodec : PacketCodec( + type = LoginRequest.CreateCheckDateOfBirthCountry::class.java, + opcode = 20, + length = 6 +) { + override fun decode(input: ByteBuf, cipher: StreamCipher): LoginRequest.CreateCheckDateOfBirthCountry { + val day = input.readUnsignedByte().toInt() + val month = input.readUnsignedByte().toInt() + 1 + val year = input.readUnsignedShort() + val country = input.readUnsignedShort() + + return LoginRequest.CreateCheckDateOfBirthCountry(LocalDate.of(year, month, day), country) + } + + override fun encode(input: LoginRequest.CreateCheckDateOfBirthCountry, output: ByteBuf, cipher: StreamCipher) { + output.writeByte(input.dateOfBirth.dayOfMonth) + output.writeByte(input.dateOfBirth.monthValue - 1) + output.writeShort(input.dateOfBirth.year) + output.writeShort(input.country) + } +} diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/LoginRequest.kt b/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/LoginRequest.kt index a83d725562..8468fff8fb 100644 --- a/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/LoginRequest.kt +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/LoginRequest.kt @@ -1,11 +1,16 @@ package org.openrs2.protocol.login.upstream import org.openrs2.protocol.Packet +import java.time.LocalDate public sealed class LoginRequest : Packet { public data class InitGameConnection(public val usernameHash: Int) : LoginRequest() public data class InitJs5RemoteConnection(public val build: Int) : LoginRequest() public object InitJaggrabConnection : LoginRequest() + public data class CreateCheckDateOfBirthCountry( + public val dateOfBirth: LocalDate, + public val country: Int + ) : LoginRequest() public data class RequestWorldList(public val checksum: Int) : LoginRequest() public data class CheckWorldSuitability( public val build: Int,