nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
nanommo::Inputs Class Reference

#include <inputs.h>

Public Member Functions

void Take (World &land, uint32_t id, const protocol::Input &input)
void Apply (const std::function< World *(uint32_t)> &land_of)
 Each player's next waiting keys, a tick's worth, in their land.
std::optional< uint32_t > acked (uint32_t id) const
 The last of the player's numbered inputs applied, if any.
void Leave (uint32_t id)
 Forgets a player who's left.

Static Public Attributes

static constexpr std::size_t kMostQueued = 5
static constexpr std::size_t kMostBehind = 3
static constexpr std::size_t kMostSteady = 2
static constexpr int kSteadyTicks = 20
static constexpr std::chrono::milliseconds kMostRewind {200}

Detailed Description

What each player's inputs do to the world, whoever runs it: a world server, or a client that plays on its own. A numbered input's keys wait for their tick, so that the client knows which tick each of its inputs moved it in.

Definition at line 22 of file inputs.h.

Member Function Documentation

◆ acked()

std::optional< uint32_t > nanommo::Inputs::acked ( uint32_t id) const

The last of the player's numbered inputs applied, if any.

Definition at line 71 of file inputs.cc.

◆ Apply()

void nanommo::Inputs::Apply ( const std::function< World *(uint32_t)> & land_of)

Each player's next waiting keys, a tick's worth, in their land.

Definition at line 44 of file inputs.cc.

◆ Leave()

void nanommo::Inputs::Leave ( uint32_t id)

Forgets a player who's left.

Definition at line 79 of file inputs.cc.

◆ Take()

void nanommo::Inputs::Take ( World & land,
uint32_t id,
const protocol::Input & input )

The input's keys: a numbered one's wait for their tick, and others are set at once, unless the player numbers theirs, when one that isn't is a copy of the last, sent with something else.

Definition at line 31 of file inputs.cc.

Member Data Documentation

◆ kMostBehind

std::size_t nanommo::Inputs::kMostBehind = 3
staticconstexpr

A client sends one a tick, but a slow frame sends two or three together, so up to three waiting is a client a little ahead of our tick. More means some came late and we're behind it, so each tick skips one, until we've caught up.

Definition at line 33 of file inputs.h.

◆ kMostQueued

std::size_t nanommo::Inputs::kMostQueued = 5
staticconstexpr

A client sends an input a tick, so a few queue up only when the network holds some back and lets them through together. More than this, and the oldest go, so that a player doesn't fall further and further behind.

Definition at line 27 of file inputs.h.

◆ kMostRewind

std::chrono::milliseconds nanommo::Inputs::kMostRewind {200}
staticconstexpr

A numbered input says when, on our clock, its client drew everyone else, and its player's blows on a duel opponent are checked against where the opponent was then. A client draws them 100 milliseconds before the newest world it has, and the world's way to it and the input's way back are a round trip more, so this is enough for a round trip of up to 100. A time further back is taken as this, so that a client can't hit its opponent wherever they once were, and a time ahead of ours as now.

Definition at line 50 of file inputs.h.

◆ kMostSteady

std::size_t nanommo::Inputs::kMostSteady = 2
staticconstexpr

Inputs come in as fast as they go out, so a queue a burst filled stays that full, each input a tick late for each one ahead of it. If two or more waited at the start of each tick for a second, the queue's kept more than it needs, and it drops one, until one waiting is the most it keeps for long.

Definition at line 40 of file inputs.h.

◆ kSteadyTicks

int nanommo::Inputs::kSteadyTicks = 20
staticconstexpr

Definition at line 41 of file inputs.h.


The documentation for this class was generated from the following files: