Add OK LoginResponse

Signed-off-by: Graham <gpe@openrs2.org>
master
Graham 3 months ago
parent 127f1801d7
commit b4454198e7
  1. 2
      protocol/src/main/kotlin/org/openrs2/protocol/ProtocolModule.kt
  2. 12
      protocol/src/main/kotlin/org/openrs2/protocol/login/downstream/LoginResponse.kt
  3. 59
      protocol/src/main/kotlin/org/openrs2/protocol/login/downstream/OkCodec.kt

@ -59,6 +59,7 @@ import org.openrs2.protocol.login.downstream.LoginServerOfflineCodec
import org.openrs2.protocol.login.downstream.MapMembersOnlyCodec
import org.openrs2.protocol.login.downstream.NeedMembersAccountCodec
import org.openrs2.protocol.login.downstream.NoReplyFromLoginServerCodec
import org.openrs2.protocol.login.downstream.OkCodec
import org.openrs2.protocol.login.downstream.ReconnectOkCodec
import org.openrs2.protocol.login.downstream.ServerFullCodec
import org.openrs2.protocol.login.downstream.ServiceUnavailableCodec
@ -141,6 +142,7 @@ public object ProtocolModule : AbstractModule() {
bindProtocol(
LoginDownstream::class.java,
ExchangeSessionKeyCodec::class.java,
OkCodec::class.java,
ShowVideoAdCodec::class.java,
InvalidUsernameOrPasswordCodec::class.java,
BannedCodec::class.java,

@ -5,6 +5,18 @@ import org.openrs2.protocol.Packet
public sealed class LoginResponse : Packet {
public data class ExchangeSessionKey(val key: Long) : LoginResponse()
public object ShowVideoAd : LoginResponse()
public data class Ok(
val staffModelLevel: Int,
val playerModLevel: Int,
val playerUnderage: Boolean,
val parentalChatConsent: Boolean,
val parentalAdvertConsent: Boolean,
val mapQuickChat: Boolean,
val recordMouseMovement: Boolean,
val playerId: Int,
val playerMember: Boolean,
val mapMembers: Boolean
) : LoginResponse()
public object InvalidUsernameOrPassword : LoginResponse()
public object Banned : LoginResponse()
public object Duplicate : LoginResponse()

@ -0,0 +1,59 @@
package org.openrs2.protocol.login.downstream
import io.netty.buffer.ByteBuf
import jakarta.inject.Singleton
import org.openrs2.crypto.StreamCipher
import org.openrs2.protocol.FixedPacketCodec
@Singleton
public class OkCodec : FixedPacketCodec<LoginResponse.Ok>(
type = LoginResponse.Ok::class.java,
opcode = 2,
length = 11
) {
override fun decode(
input: ByteBuf,
cipher: StreamCipher
): LoginResponse.Ok {
val staffModLevel = input.readUnsignedByte().toInt()
val playerModLevel = input.readUnsignedByte().toInt()
val playerUnderage = input.readBoolean()
val parentalChatConsent = input.readBoolean()
val parentalAdvertConsent = input.readBoolean()
val mapQuickChat = input.readBoolean()
val recordMouseMovement = input.readBoolean()
val playerId = input.readUnsignedShort().toInt()
val playerMember = input.readBoolean()
val mapMembers = input.readBoolean()
return LoginResponse.Ok(
staffModLevel,
playerModLevel,
playerUnderage,
parentalChatConsent,
parentalAdvertConsent,
mapQuickChat,
recordMouseMovement,
playerId,
playerMember,
mapMembers
)
}
override fun encode(
input: LoginResponse.Ok,
output: ByteBuf,
cipher: StreamCipher
) {
output.writeByte(input.staffModelLevel)
output.writeByte(input.playerModLevel)
output.writeBoolean(input.playerUnderage)
output.writeBoolean(input.parentalChatConsent)
output.writeBoolean(input.parentalAdvertConsent)
output.writeBoolean(input.mapQuickChat)
output.writeBoolean(input.recordMouseMovement)
output.writeShort(input.playerId)
output.writeBoolean(input.playerMember)
output.writeBoolean(input.mapMembers)
}
}
Loading…
Cancel
Save