Skip to content
Open
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
@@ -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)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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].
Expand Down