From 47eba7d311185cdb809ffdf9f24510db4080e59c Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 17 Apr 2026 11:12:38 +0200 Subject: [PATCH] Add SERVER_TICK_END packet support for RSProxy live logging - Add ServerTickEndHandler to send tick end packets to all players - Send ServerTickEnd at the end of each game tick cycle in GameService - This enables RSProxy to properly timestamp packets for live logging UI --- .../game/message/ServerTickEndHandler.kt | 23 +++++++++++++++++++ .../org/alter/game/service/GameService.kt | 3 +++ 2 files changed, 26 insertions(+) create mode 100644 game-server/src/main/kotlin/org/alter/game/message/ServerTickEndHandler.kt diff --git a/game-server/src/main/kotlin/org/alter/game/message/ServerTickEndHandler.kt b/game-server/src/main/kotlin/org/alter/game/message/ServerTickEndHandler.kt new file mode 100644 index 00000000..ce6f0d02 --- /dev/null +++ b/game-server/src/main/kotlin/org/alter/game/message/ServerTickEndHandler.kt @@ -0,0 +1,23 @@ +package org.alter.game.message + +import net.rsprot.protocol.game.outgoing.misc.client.ServerTickEnd + +/** + * A message handler for ServerTickEnd which signals the end of a server tick cycle. + * This is used by RSProxy to properly timestamp packets for live logging. + */ +class ServerTickEndHandler { + companion object { + /** + * Send a server tick end message to all connected players. + * This should be called at the end of each game tick cycle. + */ + fun sendToAll(world: org.alter.game.model.World) { + world.players.forEach { player -> + if (player.initiated) { + player.write(ServerTickEnd) + } + } + } + } +} diff --git a/game-server/src/main/kotlin/org/alter/game/service/GameService.kt b/game-server/src/main/kotlin/org/alter/game/service/GameService.kt index dfbded63..88fc8a7e 100644 --- a/game-server/src/main/kotlin/org/alter/game/service/GameService.kt +++ b/game-server/src/main/kotlin/org/alter/game/service/GameService.kt @@ -9,6 +9,7 @@ import io.github.oshai.kotlinlogging.KotlinLogging import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.asCoroutineDispatcher +import org.alter.game.message.ServerTickEndHandler import org.alter.game.model.World import org.alter.game.task.* import java.util.concurrent.ConcurrentLinkedQueue @@ -191,6 +192,8 @@ class GameService : Service { } world.cycle() + ServerTickEndHandler.sendToAll(world) + /* * Calculate the time, in milliseconds, it took for this cycle to complete * and add it to [cycleTime].