KailleraGame

class KailleraGame(val id: Int, val romName: String, val owner: KailleraUser, val server: KailleraServer, val bufferSize: Int, flags: RuntimeFlags, clock: Clock) : KoinComponent

Represents a game instance on the server.

Synchronization Handshake

The game uses a lock-step synchronization model with an initial handshake to establish lag compensation. The handshake consists of three phases verified by E2E tests:

  1. Buffering (Frames 1-6): The server buffers incoming packets from the client to build up a delay buffer (determined by totalDelay). During this phase, the server sends back "Zero Packets" (packets of the same size as input but zeroed) to the client.

  2. Draining (Frames 7-12): Once the buffer is full, the server begins "draining" the buffer. It processes and fans out the old packets stored during Phase 1. Crucially, strictly "new" inputs received during this draining phase are DROPPED to allow the stream to align with the buffered history.

  3. Synced (Frames 13+): The buffer is now managing the flow. The server fans out packets in real-time order, effectively delayed by the buffer size. Received[T] == Sent[T] (relative to the shifted timeline).

Constructors

Link copied to clipboard
constructor(id: Int, romName: String, owner: KailleraUser, server: KailleraServer, bufferSize: Int, flags: RuntimeFlags, clock: Clock)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The total duration that the game has drifted over the lagstat measurement window.

Link copied to clipboard

Record of all game log events.

Link copied to clipboard
Link copied to clipboard
val id: Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Frame delay is synced with others users in the same game (see /samedelay).

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var startN: Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Whether the game is holding data for the current frame, waiting on one or more players before fanning out.

Link copied to clipboard

If waitingOnPlayerNumber[playerNumber - 1] is true, we are waiting on data for that player.

Functions

Link copied to clipboard
fun addData(user: KailleraUser, playerNumber: Int, data: ByteBuf): AddDataResult

Adds data and suspends until all data is available, at which time it returns the sends new data back to the client.

Link copied to clipboard
fun announce(announcement: String, toUser: KailleraUser? = null)
Link copied to clipboard
fun chat(user: KailleraUser, message: String)
Link copied to clipboard
Link copied to clipboard
fun drop(user: KailleraUser, playerNumber: Int)
Link copied to clipboard
Link copied to clipboard
open fun getKoin(): Koin
Link copied to clipboard
fun getPlayer(playerNumber: Int): KailleraUser?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun kick(requester: KailleraUser, userID: Int)
Link copied to clipboard

Checks if any user has a full set of new data to send.

Link copied to clipboard
fun quit(user: KailleraUser, playerNumber: Int)
Link copied to clipboard
fun ready(user: KailleraUser, playerNumber: Int)
Link copied to clipboard
fun resetLag()
Link copied to clipboard
fun setGameFps(fps: Double)

Sets the game framerate for lag measuring purposes.

Link copied to clipboard
Link copied to clipboard
open override fun toString(): String