Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revision 228 #45

Merged
merged 8 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprox.protocol.game.outgoing.model.util.OpFlags
import net.rsprox.protocol.game.outgoing.model.zone.payload.LocAddChange
import net.rsprox.protocol.game.outgoing.model.zone.payload.LocAddChangeV1
import net.rsprox.protocol.game.outgoing.model.zone.payload.util.CoordInZone
import net.rsprox.protocol.game.outgoing.model.zone.payload.util.LocProperties
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.v223.game.outgoing.decoder.prot.GameServerProt

internal class LocAddChangeDecoder : ProxyMessageDecoder<LocAddChange> {
internal class LocAddChangeDecoder : ProxyMessageDecoder<LocAddChangeV1> {
override val prot: ClientProt = GameServerProt.LOC_ADD_CHANGE

override fun decode(
buffer: JagByteBuf,
session: Session,
): LocAddChange {
): LocAddChangeV1 {
val locProperties = LocProperties(buffer.g1Alt2())
val opFlags = OpFlags(buffer.g1Alt3())
val coordInZone = CoordInZone(buffer.g1Alt3())
val id = buffer.g2Alt2()
return LocAddChange(
return LocAddChangeV1(
id,
coordInZone,
locProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprox.protocol.game.outgoing.model.util.OpFlags
import net.rsprox.protocol.game.outgoing.model.zone.payload.LocAddChange
import net.rsprox.protocol.game.outgoing.model.zone.payload.LocAddChangeV1
import net.rsprox.protocol.game.outgoing.model.zone.payload.util.CoordInZone
import net.rsprox.protocol.game.outgoing.model.zone.payload.util.LocProperties
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.v224.game.outgoing.decoder.prot.GameServerProt

internal class LocAddChangeDecoder : ProxyMessageDecoder<LocAddChange> {
internal class LocAddChangeDecoder : ProxyMessageDecoder<LocAddChangeV1> {
override val prot: ClientProt = GameServerProt.LOC_ADD_CHANGE

override fun decode(
buffer: JagByteBuf,
session: Session,
): LocAddChange {
): LocAddChangeV1 {
val locProperties = LocProperties(buffer.g1Alt2())
val coordInZone = CoordInZone(buffer.g1())
val opFlags = OpFlags(buffer.g1Alt2())
val id = buffer.g2Alt1()
return LocAddChange(
return LocAddChangeV1(
id,
coordInZone,
locProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprox.protocol.game.outgoing.model.util.OpFlags
import net.rsprox.protocol.game.outgoing.model.zone.payload.LocAddChange
import net.rsprox.protocol.game.outgoing.model.zone.payload.LocAddChangeV1
import net.rsprox.protocol.game.outgoing.model.zone.payload.util.CoordInZone
import net.rsprox.protocol.game.outgoing.model.zone.payload.util.LocProperties
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.v225.game.outgoing.decoder.prot.GameServerProt

internal class LocAddChangeDecoder : ProxyMessageDecoder<LocAddChange> {
internal class LocAddChangeDecoder : ProxyMessageDecoder<LocAddChangeV1> {
override val prot: ClientProt = GameServerProt.LOC_ADD_CHANGE

override fun decode(
buffer: JagByteBuf,
session: Session,
): LocAddChange {
): LocAddChangeV1 {
val id = buffer.g2Alt2()
val opFlags = OpFlags(buffer.g1Alt2())
val locProperties = LocProperties(buffer.g1Alt2())
val coordInZone = CoordInZone(buffer.g1Alt2())
return LocAddChange(
return LocAddChangeV1(
id,
coordInZone,
locProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprox.protocol.game.outgoing.model.util.OpFlags
import net.rsprox.protocol.game.outgoing.model.zone.payload.LocAddChange
import net.rsprox.protocol.game.outgoing.model.zone.payload.LocAddChangeV1
import net.rsprox.protocol.game.outgoing.model.zone.payload.util.CoordInZone
import net.rsprox.protocol.game.outgoing.model.zone.payload.util.LocProperties
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.v226.game.outgoing.decoder.prot.GameServerProt

internal class LocAddChangeDecoder : ProxyMessageDecoder<LocAddChange> {
internal class LocAddChangeDecoder : ProxyMessageDecoder<LocAddChangeV1> {
override val prot: ClientProt = GameServerProt.LOC_ADD_CHANGE

override fun decode(
buffer: JagByteBuf,
session: Session,
): LocAddChange {
): LocAddChangeV1 {
val locProperties = LocProperties(buffer.g1Alt3())
val opFlags = OpFlags(buffer.g1Alt3())
val id = buffer.g2Alt1()
val coordInZone = CoordInZone(buffer.g1Alt1())
return LocAddChange(
return LocAddChangeV1(
id,
coordInZone,
locProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprox.protocol.game.outgoing.model.util.OpFlags
import net.rsprox.protocol.game.outgoing.model.zone.payload.LocAddChange
import net.rsprox.protocol.game.outgoing.model.zone.payload.LocAddChangeV1
import net.rsprox.protocol.game.outgoing.model.zone.payload.util.CoordInZone
import net.rsprox.protocol.game.outgoing.model.zone.payload.util.LocProperties
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.v227.game.outgoing.decoder.prot.GameServerProt

internal class LocAddChangeDecoder : ProxyMessageDecoder<LocAddChange> {
internal class LocAddChangeDecoder : ProxyMessageDecoder<LocAddChangeV1> {
override val prot: ClientProt = GameServerProt.LOC_ADD_CHANGE

override fun decode(
buffer: JagByteBuf,
session: Session,
): LocAddChange {
): LocAddChangeV1 {
val opFlags = OpFlags(buffer.g1Alt1())
val id = buffer.g2()
val locProperties = LocProperties(buffer.g1Alt3())
val coordInZone = CoordInZone(buffer.g1())
return LocAddChange(
return LocAddChangeV1(
id,
coordInZone,
locProperties,
Expand Down
14 changes: 14 additions & 0 deletions protocol/osrs-228/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
dependencies {
implementation(platform(rootProject.libs.netty.bom))
implementation(rootProject.libs.netty.buffer)
implementation(rootProject.libs.netty.transport)
implementation(rootProject.libs.netty.handler)
implementation(rootProject.libs.rsprot.buffer)
implementation(rootProject.libs.rsprot.compression)
implementation(rootProject.libs.rsprot.protocol)
implementation(rootProject.libs.rsprot.crypto)
implementation(platform(rootProject.libs.log4j.bom))
implementation(rootProject.libs.bundles.log4j)
implementation(projects.protocol)
implementation(projects.cache.cacheApi)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.rsprox.protocol.v228

import net.rsprot.buffer.JagByteBuf
import net.rsprot.compression.HuffmanCodec
import net.rsprot.protocol.message.IncomingMessage
import net.rsprox.protocol.ClientPacketDecoder
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.v228.game.incoming.decoder.prot.ClientMessageDecoderRepository

public class ClientPacketDecoderServiceV228(
huffmanCodec: HuffmanCodec,
) : ClientPacketDecoder {
@OptIn(ExperimentalStdlibApi::class)
private val repository = ClientMessageDecoderRepository.build(huffmanCodec)

override fun decode(
opcode: Int,
payload: JagByteBuf,
session: Session,
): IncomingMessage {
return repository
.getDecoder(opcode)
.decode(payload, session)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package net.rsprox.protocol.v228

import net.rsprox.protocol.ProtProvider
import net.rsprox.protocol.v228.game.incoming.decoder.prot.GameClientProt

public data object GameClientProtProviderV228 : ProtProvider<GameClientProt> {
override fun get(opcode: Int): GameClientProt {
return GameClientProt.entries.firstOrNull { it.opcode == opcode }
?: throw IllegalArgumentException("Unknown game client prot: $opcode")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package net.rsprox.protocol.v228

import net.rsprox.protocol.ProtProvider
import net.rsprox.protocol.v228.game.outgoing.decoder.prot.GameServerProt

public data object GameServerProtProviderV228 : ProtProvider<GameServerProt> {
override fun get(opcode: Int): GameServerProt {
return GameServerProt.entries.firstOrNull { it.opcode == opcode }
?: throw IllegalArgumentException("Unknown game server prot: $opcode")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.rsprox.protocol.v228

import net.rsprot.buffer.JagByteBuf
import net.rsprot.compression.HuffmanCodec
import net.rsprot.protocol.message.IncomingMessage
import net.rsprox.cache.api.CacheProvider
import net.rsprox.protocol.ServerPacketDecoder
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.v228.game.outgoing.decoder.prot.ServerMessageDecoderRepository

public class ServerPacketDecoderServiceV228(
huffmanCodec: HuffmanCodec,
cache: CacheProvider,
) : ServerPacketDecoder {
@OptIn(ExperimentalStdlibApi::class)
private val repository =
ServerMessageDecoderRepository.build(
huffmanCodec,
cache,
)

override fun decode(
opcode: Int,
payload: JagByteBuf,
session: Session,
): IncomingMessage {
return repository
.getDecoder(opcode)
.decode(payload, session)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.rsprox.protocol.v228.game.incoming.decoder.codec.buttons

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.game.incoming.model.buttons.If1Button
import net.rsprox.protocol.v228.game.incoming.decoder.prot.GameClientProt
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprot.protocol.metadata.Consistent
import net.rsprot.protocol.util.gCombinedId

@Consistent
public class If1ButtonDecoder : ProxyMessageDecoder<If1Button> {
override val prot: ClientProt = GameClientProt.IF_BUTTON

override fun decode(
buffer: JagByteBuf,
session: Session,
): If1Button {
val combinedId = buffer.gCombinedId()
return If1Button(combinedId)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.rsprox.protocol.v228.game.incoming.decoder.codec.buttons

import net.rsprot.buffer.JagByteBuf
import net.rsprox.protocol.game.incoming.model.buttons.If3Button
import net.rsprox.protocol.v228.game.incoming.decoder.prot.GameClientProt
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprot.protocol.metadata.Consistent
import net.rsprot.protocol.util.gCombinedId
import net.rsprox.protocol.session.Session

@Consistent
public class If3ButtonDecoder(
override val prot: GameClientProt,
private val op: Int,
) : ProxyMessageDecoder<If3Button> {
override fun decode(
buffer: JagByteBuf,
session: Session,
): If3Button {
val combinedId = buffer.gCombinedId()
val sub = buffer.g2()
val obj = buffer.g2()
return If3Button(
combinedId,
sub,
obj,
op,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.rsprox.protocol.v228.game.incoming.decoder.codec.buttons

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.game.incoming.model.buttons.IfButtonD
import net.rsprox.protocol.v228.game.incoming.decoder.prot.GameClientProt
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprot.protocol.util.gCombinedId

public class IfButtonDDecoder : ProxyMessageDecoder<IfButtonD> {
override val prot: ClientProt = GameClientProt.IF_BUTTOND

override fun decode(
buffer: JagByteBuf,
session: Session,
): IfButtonD {
val selectedObj = buffer.g2()
val targetSub = buffer.g2Alt2()
val selectedSub = buffer.g2Alt2()
val targetCombinedId = buffer.gCombinedId()
val targetObj = buffer.g2()
val selectedCombinedId = buffer.gCombinedId()
return IfButtonD(
selectedCombinedId,
selectedSub,
selectedObj,
targetCombinedId,
targetSub,
targetObj,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package net.rsprox.protocol.v228.game.incoming.decoder.codec.buttons

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.game.incoming.model.buttons.IfButtonT
import net.rsprox.protocol.v228.game.incoming.decoder.prot.GameClientProt
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprot.protocol.util.gCombinedIdAlt1
import net.rsprot.protocol.util.gCombinedIdAlt2

public class IfButtonTDecoder : ProxyMessageDecoder<IfButtonT> {
override val prot: ClientProt = GameClientProt.IF_BUTTONT

override fun decode(
buffer: JagByteBuf,
session: Session,
): IfButtonT {
val selectedCombinedId = buffer.gCombinedIdAlt1()
val targetSub = buffer.g2()
val targetCombinedId = buffer.gCombinedIdAlt2()
val selectedSub = buffer.g2Alt3()
val targetObj = buffer.g2Alt3()
val selectedObj = buffer.g2()
return IfButtonT(
selectedCombinedId,
selectedSub,
selectedObj,
targetCombinedId,
targetSub,
targetObj,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.rsprox.protocol.v228.game.incoming.decoder.codec.buttons

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.game.incoming.model.buttons.IfSubOp
import net.rsprox.protocol.v228.game.incoming.decoder.prot.GameClientProt
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprot.protocol.metadata.Consistent
import net.rsprot.protocol.util.gCombinedId

@Consistent
public class IfSubOpDecoder : ProxyMessageDecoder<IfSubOp> {
override val prot: ClientProt = GameClientProt.IF_SUBOP

override fun decode(
buffer: JagByteBuf,
session: Session,
): IfSubOp {
val combinedId = buffer.gCombinedId()
val sub = buffer.g2()
val obj = buffer.g2()
val subop = buffer.g1()
val op = buffer.g1()
return IfSubOp(
combinedId,
sub,
obj,
op + 1,
subop,
)
}
}
Loading
Loading