vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::NetCommandBuffer Class Reference

The commands one player has sent that the server has not yet run. More...

#include <command.h>

Public Member Functions

void accept (const InputCommand &command)
 Take one command, ignoring a sequence already seen.
InputCommand take (uint32_t tick)
 The command to run on the tick about to happen.
uint32_t newestRunTick () const
 The newest command tick actually run, in the client's numbering.
uint32_t newestSequence () const
 The newest sequence this buffer has accepted.
size_t pending () const
 How many commands are waiting.
size_t lowWater () const
 The fewest commands waiting at any take() since restartLowWater().
void restartLowWater ()
 Start measuring lowWater() again, once it has been said.
uint32_t repeatedTicks () const
 Ticks that ran on a repeat because nothing was waiting, since clear().
uint32_t skippedCommands () const
 Commands passed over unrun, since clear(): skipped down to MAX_DEPTH, or pushed out of a queue at MAX_QUEUED.

Static Public Attributes

static constexpr size_t MAX_DEPTH = 10
 Commands the queue may hold before the oldest are skipped, all at once.
static constexpr size_t MAX_QUEUED = 256
 Most commands held at once, however fast they arrive.
static constexpr uint32_t REPEAT_TICKS = NET_COMMAND_REDUNDANCY * 2
 Ticks a repeat may stand in for before it stops moving the body.

Detailed Description

The commands one player has sent that the server has not yet run.

One command per tick, in the player's order, each exactly once: the client predicted tick N with command N, so the server must run it as one whole tick. Queued, not addressed by tick: the two ends' tick clocks are unrelated. A duplicate is run once, or an edge fires twice.

Empty, the tick still runs on the last command's axes with its edges cleared. Past MAX_DEPTH the oldest are skipped in one tick, since a backlog is latency. NetPacing keeps the queue just above empty, from lowWater.

Member Function Documentation

◆ take()

InputCommand Vkm::Engine::NetCommandBuffer::take ( uint32_t tick)

The command to run on the tick about to happen.

A repeat claims the client tick it stood in for, so a snapshot's confirmation matches its pose; the real command for that tick is discarded when it turns up.

Parameters
tickThe server's own tick, stamped on what comes back.
Returns
The oldest command not yet run, or the last one run with its edges cleared when none is waiting; zeroed before any arrive.

◆ newestRunTick()

uint32_t Vkm::Engine::NetCommandBuffer::newestRunTick ( ) const
inline

The newest command tick actually run, in the client's numbering.

Not the server's clock. A snapshot carries it so the client knows which prediction to hold the snapshot against.

Returns
The client tick; zero before any command has run.

◆ newestSequence()

uint32_t Vkm::Engine::NetCommandBuffer::newestSequence ( ) const
inline

The newest sequence this buffer has accepted.

What arrived, ahead of newestRunTick() by the queue's depth. A snapshot carries it so the client stops resending (see firstCommandToSend).

Returns
The sequence; zero until one arrives.

◆ pending()

size_t Vkm::Engine::NetCommandBuffer::pending ( ) const
inline

How many commands are waiting.

Returns
The queue's depth now.

◆ lowWater()

size_t Vkm::Engine::NetCommandBuffer::lowWater ( ) const
inline

The fewest commands waiting at any take() since restartLowWater().

Counted before the take, so zero is a tick that ran on a repeat. The lowest point, because the depth now depends on whether a packet just landed.

Returns
The low water; with no take since the restart, the depth now.

◆ repeatedTicks()

uint32_t Vkm::Engine::NetCommandBuffer::repeatedTicks ( ) const
inline

Ticks that ran on a repeat because nothing was waiting, since clear().

Counted from the first command that ran.

Returns
The count.

◆ skippedCommands()

uint32_t Vkm::Engine::NetCommandBuffer::skippedCommands ( ) const
inline

Commands passed over unrun, since clear(): skipped down to MAX_DEPTH, or pushed out of a queue at MAX_QUEUED.

Returns
The count.

Member Data Documentation

◆ MAX_DEPTH

size_t Vkm::Engine::NetCommandBuffer::MAX_DEPTH = 10
staticconstexpr

Commands the queue may hold before the oldest are skipped, all at once.

A queue is input delay. Skipped edges are folded in; the same number bounds how far repeats may stand in, so the two cannot drift apart. NetPacing sets the standing depth; this is for a burst after a stall, set above the pacing cushion by its jitter again so a jittering link is never trimmed.

◆ MAX_QUEUED

size_t Vkm::Engine::NetCommandBuffer::MAX_QUEUED = 256
staticconstexpr

Most commands held at once, however fast they arrive.

Nothing else bounds what arrives between two take()s, and accept() is linear in it. Many packets' worth.

◆ REPEAT_TICKS

uint32_t Vkm::Engine::NetCommandBuffer::REPEAT_TICKS = NET_COMMAND_REDUNDANCY * 2
staticconstexpr

Ticks a repeat may stand in for before it stops moving the body.

Twice the redundancy window: that long with nothing means every copy of every recent command was lost, a link gone rather than jittering.


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