Skip to content

Commit

Permalink
feat: misc user packets
Browse files Browse the repository at this point in the history
  • Loading branch information
Z-Kris committed Apr 5, 2024
1 parent c55ad95 commit da4219c
Show file tree
Hide file tree
Showing 27 changed files with 1,314 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.BugReport
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.metadata.Consistent
import net.rsprot.protocol.tools.MessageDecodingTools

@Consistent
public class BugReportDecoder : MessageDecoder<BugReport> {
override val prot: ClientProt = GameClientProt.BUG_REPORT

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): BugReport {
val type = buffer.g1()
val description = buffer.gjstr()
val instructions = buffer.gjstr()
check(description.length <= 500) {
"Bug report description length cannot exceed 500 characters."
}
check(instructions.length <= 500) {
"Bug report instructions length cannot exceed 500 characters."
}
return BugReport(
type,
description,
instructions,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.ClickWorldMap
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.internal.game.outgoing.info.CoordGrid
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.tools.MessageDecodingTools

public class ClickWorldMapDecoder : MessageDecoder<ClickWorldMap> {
override val prot: ClientProt = GameClientProt.CLICKWORLDMAP

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): ClickWorldMap {
val packed = buffer.g4Alt3()
return ClickWorldMap(CoordGrid(packed))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.ClientCheat
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.metadata.Consistent
import net.rsprot.protocol.tools.MessageDecodingTools

@Consistent
public class ClientCheatDecoder : MessageDecoder<ClientCheat> {
override val prot: ClientProt = GameClientProt.CLIENT_CHEAT

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): ClientCheat {
val command = buffer.gjstr()
return ClientCheat(command)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.CloseModal
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.tools.MessageDecodingTools

public class CloseModalDecoder : MessageDecoder<CloseModal> {
override val prot: ClientProt = GameClientProt.CLOSE_MODAL

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): CloseModal {
return CloseModal
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.HiscoreRequest
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.metadata.Consistent
import net.rsprot.protocol.tools.MessageDecodingTools

@Consistent
public class HiscoreRequestDecoder : MessageDecoder<HiscoreRequest> {
override val prot: ClientProt = GameClientProt.HISCORE_REQUEST

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): HiscoreRequest {
val type = buffer.g1()
val requestId = buffer.g1()
val name = buffer.gjstr()
return HiscoreRequest(
type,
requestId,
name,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.IfCrmViewClick
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.tools.MessageDecodingTools
import net.rsprot.protocol.util.gCombinedIdAlt1

public class IfCrmViewClickDecoder : MessageDecoder<IfCrmViewClick> {
override val prot: ClientProt = GameClientProt.IF_CRMVIEW_CLICK

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): IfCrmViewClick {
val serverTarget = buffer.g4Alt1()
val sub = buffer.g2()
val behaviour2 = buffer.g4()
val behaviour3 = buffer.g4()
val combinedId = buffer.gCombinedIdAlt1()
val behaviour1 = buffer.g4()
return IfCrmViewClick(
serverTarget,
combinedId,
sub,
behaviour1,
behaviour2,
behaviour3,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.MoveGameClick
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.tools.MessageDecodingTools

public class MoveGameClickDecoder : MessageDecoder<MoveGameClick> {
override val prot: ClientProt = GameClientProt.MOVE_GAMECLICK

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): MoveGameClick {
val x = buffer.g2()
val keyCombination = buffer.g1()
val z = buffer.g2Alt1()
return MoveGameClick(
x,
z,
keyCombination,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.MoveMinimapClick
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.tools.MessageDecodingTools

public class MoveMinimapClickDecoder : MessageDecoder<MoveMinimapClick> {
override val prot: ClientProt = GameClientProt.MOVE_MINIMAPCLICK

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): MoveMinimapClick {
// The x, z and keyCombination get scrambled between revisions
val x = buffer.g2()
val keyCombination = buffer.g1()
val z = buffer.g2()

// The arguments below are consistent across revisions
val minimapWidth = buffer.g1()
val minimapHeight = buffer.g1()
val cameraAngleY = buffer.g2()
val checkpoint1 = buffer.g1()
check(checkpoint1 == 57) {
"Invalid checkpoint 1: $checkpoint1"
}
val checkpoint2 = buffer.g1()
check(checkpoint2 == 0) {
"Invalid checkpoint 2: $checkpoint2"
}
val checkpoint3 = buffer.g1()
check(checkpoint3 == 0) {
"Invalid checkpoint 3: $checkpoint3"
}
val checkpoint4 = buffer.g1()
check(checkpoint4 == 89) {
"Invalid checkpoint 4: $checkpoint4"
}
val fineX = buffer.g2()
val fineZ = buffer.g2()
val checkpoint5 = buffer.g1()
check(checkpoint5 == 63) {
"Invalid checkpoint 5: $checkpoint5"
}
return MoveMinimapClick(
x,
z,
keyCombination,
minimapWidth,
minimapHeight,
cameraAngleY,
fineX,
fineZ,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.OculusLeave
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.metadata.Consistent
import net.rsprot.protocol.tools.MessageDecodingTools

@Consistent
public class OculusLeaveDecoder : MessageDecoder<OculusLeave> {
override val prot: ClientProt = GameClientProt.OCULUS_LEAVE

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): OculusLeave {
return OculusLeave
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.SendSnapshot
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.metadata.Consistent
import net.rsprot.protocol.tools.MessageDecodingTools

@Consistent
public class SendSnapshotDecoder : MessageDecoder<SendSnapshot> {
override val prot: ClientProt = GameClientProt.SEND_SNAPSHOT

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): SendSnapshot {
val name = buffer.gjstr()
val ruleId = buffer.g1()
val mute = buffer.g1() == 1
return SendSnapshot(
name,
ruleId,
mute,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.SetChatFilterSettings
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.metadata.Consistent
import net.rsprot.protocol.tools.MessageDecodingTools

@Consistent
public class SetChatFilterSettingsDecoder : MessageDecoder<SetChatFilterSettings> {
override val prot: ClientProt = GameClientProt.SET_CHATFILTERSETTINGS

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): SetChatFilterSettings {
val publicChatFilter = buffer.g1()
val privateChatFilter = buffer.g1()
val tradeChatFilter = buffer.g1()
return SetChatFilterSettings(
publicChatFilter,
privateChatFilter,
tradeChatFilter,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.Teleport
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.tools.MessageDecodingTools

public class TeleportDecoder : MessageDecoder<Teleport> {
override val prot: ClientProt = GameClientProt.TELEPORT

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): Teleport {
val oculusSyncValue = buffer.g4Alt2()
val x = buffer.g2Alt1()
val level = buffer.g1Alt1()
val z = buffer.g2Alt1()
return Teleport(
oculusSyncValue,
x,
z,
level,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package net.rsprot.protocol.game.incoming.codec.misc.user

import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.game.incoming.misc.user.UpdatePlayerModel
import net.rsprot.protocol.game.incoming.prot.GameClientProt
import net.rsprot.protocol.message.codec.MessageDecoder
import net.rsprot.protocol.metadata.Consistent
import net.rsprot.protocol.tools.MessageDecodingTools

@Consistent
public class UpdatePlayerModelDecoder : MessageDecoder<UpdatePlayerModel> {
override val prot: ClientProt = GameClientProt.UPDATE_PLAYER_MODEL

override fun decode(
buffer: JagByteBuf,
tools: MessageDecodingTools,
): UpdatePlayerModel {
val bodyType = buffer.g1()
val identKit = ByteArray(7)
for (i in identKit.indices) {
identKit[i] = buffer.g1().toByte()
}
val colours = ByteArray(5)
for (i in colours.indices) {
colours[i] = buffer.g1().toByte()
}
return UpdatePlayerModel(
bodyType,
identKit,
colours,
)
}
}
Loading

0 comments on commit da4219c

Please sign in to comment.