diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/ProtocolModule.kt b/protocol/src/main/kotlin/org/openrs2/protocol/ProtocolModule.kt index 8417994b..25c38b71 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 00000000..579ea321 --- /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 a83d7255..8468fff8 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,