Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.2 KiB
30 lines
1.2 KiB
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
|
|
public class CreateCheckDateOfBirthCountryCodec : FixedPacketCodec<LoginRequest.CreateCheckDateOfBirthCountry>(
|
|
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)
|
|
}
|
|
}
|
|
|