Skip to content

five-on-it / apps/server/src/run-host

apps/server/src/run-host ​

A run's room (TECHNICAL_SPECS §9.5): one mission played by the roster its run names, in a room of its own. The RunHost keeps what the room's game server does not: the run's phase (gathering its seats, a countdown that holds every car, live, then ended), each seat's connection (waiting for its player, present, dropped and given RUN_TIMING.graceS to come back, or gone for good), what the run measures of each seat (how long it was connected while the run was live, how long it stood idle past RUN_TIMING.afkS; the damage it did to its teammates, the most of it any one of them took as a share of their health, and the teammates it killed; whether the room voted it out, and how many of the yes votes came from outside its party) and the result it reports to the platform once it ends, with the attempts the missions say failed by its hit on one of the mission's people (its sabotage, @foi/missions' run view).

The phases: the run gathers until every seat has come, or RUN_TIMING.gatherS after the first came (it starts with whoever is there: a co-op run plays on with fewer than its minimum); the countdown lasts RUN_TIMING.countdownS and holds every car (the game server replaces the players' inputs with a held one, @foi/protocol's heldInput); live, the mission runs (@foi/missions' runtime, held by its stand-in holder 0); it ends when the runtime says the run did (complete, or failed with its retries used up; a versus run won by a team or a draw), or abandoned once no seat is present and none of the dropped ones may come back. A seat gone for good (its minute out, or not come by the time the run went live) is told to the missions (RunPoll.gone): in versus, a team left with nobody who may play forfeits.

Joining late (the mission's play.joinInProgress): a rostered seat may come until the countdown ends; one whose player has not come by the time the run goes live is gone for good (left, refused 4403 from then on). A seat that was present and dropped is not joining: it keeps its minute to come back. A live run of untilCheckpoint (until its mission saved a checkpoint) or always has open seats (RunHost.openSeats: @foi/missions' openSeats), which the room's status advertises; the platform fills one with a player of its own (RunHost.addSeat: a seat at the end of the roster, refused when the team has none open or the account is on the roster already), whose player has RUN_TIMING.graceS to come (else that seat is gone too). Each seat's span is in the result: when it joined (joinedS, a late seat's) and when it was given up (leftS, a seat gone for good: the moment its player dropped, or the start for one never come), so the platform judges presence and pays Respect against the time it was the seat's.

Idling: a seat is active when its inputs change (what moves the player, not where the mouse points), or when it holds a key that moves it and has really gone somewhere: at least AFK_PROGRESS_M from where it stood when it was last active. A key held down against a wall, or a car going round on a held throttle and a held lock, stands idle; a car pushed or respawned with no key held does too. A seat out of the run, watching a teammate, is never idle (RunHost.excuse): it has nothing left to do.

The report: the result goes to the run's reportUrl with its reportToken, tried again on a backoff (1 s doubling to 30 s) until the platform takes it, for up to RUN_TIMING.reportForS (a refusal, a 4xx, is final: sending it again changes nothing); the room closes RUN_TIMING.closeAfterS after the result once it was taken, or is held while it was not until the reporting gave up (logged: the platform counts the run lost). A room nobody came to closes RUN_TIMING.noShowS after it was ready to admit them (RunHost.ready, once its world warmed up: rooms.ts).

Time here is the process's clock (ms), not the room's ticks: an empty room is not ticked, and a dropped seat's minute runs all the same. A run's room is never frozen for a player who paused, even alone (GameServer.frozen): its clocks are the wall clock's.

Classes ​

Interfaces ​

Variables ​

Functions ​