From 0a998139324d4c3fe11f7d172de9de0988a7bb2a Mon Sep 17 00:00:00 2001 From: Graham Date: Tue, 26 Jul 2022 08:45:05 +0100 Subject: [PATCH] Don't use LocalDate to represent date of birth in packets The client's UI makes it easy to submit invalid dates not supported by LocalDate. Rather than throwing an exception in a codec, it'd be good to support representing these for: * Allowing the development of a debugging proxy server that sits between the client and game server. * Making it easier to send the invalid date of birth response to the creation request. We'll still switch to LocalDate as early as possible in the packet handler in the future. Signed-off-by: Graham --- .../protocol/login/upstream/CreateAccountCodec.kt | 11 ++++++----- .../upstream/CreateCheckDateOfBirthCountryCodec.kt | 11 +++++------ .../openrs2/protocol/login/upstream/LoginRequest.kt | 9 ++++++--- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/CreateAccountCodec.kt b/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/CreateAccountCodec.kt index 7c4c7f3588..53ace7c7da 100644 --- a/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/CreateAccountCodec.kt +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/CreateAccountCodec.kt @@ -16,7 +16,6 @@ import org.openrs2.crypto.xteaDecrypt import org.openrs2.crypto.xteaEncrypt import org.openrs2.protocol.VariableShortPacketCodec import org.openrs2.util.Base37 -import java.time.LocalDate import javax.inject.Inject import javax.inject.Singleton @@ -68,7 +67,9 @@ public class CreateAccountCodec @Inject constructor( username, password, affiliate, - dateOfBirth = LocalDate.of(year, month + 1, day), + year, + month, + day, country, email ) @@ -100,10 +101,10 @@ public class CreateAccountCodec @Inject constructor( plaintext.writeString(input.password) plaintext.writeInt(xteaKey.k1) plaintext.writeShort(input.affiliate) - plaintext.writeByte(input.dateOfBirth.dayOfMonth) - plaintext.writeByte(input.dateOfBirth.monthValue - 1) + plaintext.writeByte(input.day) + plaintext.writeByte(input.month) plaintext.writeInt(xteaKey.k2) - plaintext.writeShort(input.dateOfBirth.year) + plaintext.writeShort(input.year) plaintext.writeShort(input.country) plaintext.writeInt(xteaKey.k3) 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 index 08eac51689..7884b21cad 100644 --- a/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/CreateCheckDateOfBirthCountryCodec.kt +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/CreateCheckDateOfBirthCountryCodec.kt @@ -3,7 +3,6 @@ package org.openrs2.protocol.login.upstream import io.netty.buffer.ByteBuf import org.openrs2.crypto.StreamCipher import org.openrs2.protocol.FixedPacketCodec -import java.time.LocalDate import javax.inject.Singleton @Singleton @@ -14,17 +13,17 @@ public class CreateCheckDateOfBirthCountryCodec : FixedPacketCodec