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

The ordered list of what replicates, agreed by both ends before play. More...

#include <schema.h>

Public Member Functions

template<typename T>
void replicate (std::string name)
 Add T to what replicates.
const std::vector< NetType > & types () const
 Everything registered, in wire order.
int indexOf (std::string_view name) const
 Wire index of name, or -1.
uint32_t fingerprint () const
 A number that differs when the lists differ, or the codecs' layout does.
std::string describe () const
 Every name in order, for the log line that follows a refusal.
void clear ()
 Drops everything.

Static Public Member Functions

static NetSchema & get ()
 The registry every end consults. Filled by ScriptModule::setupNetwork, read thereafter.

Static Public Attributes

static constexpr size_t MAX_TYPES = 32
 Most component types one game may replicate.

Detailed Description

The ordered list of what replicates, agreed by both ends before play.

A component's wire identity is its index, so both ends must build the same list in order; a fingerprint mismatch is refused at join. Rebuilt by ScriptModule::setupNetwork: the engine's types, then the project's from the module's vkmSetupNetwork export.

Member Function Documentation

◆ replicate()

template<typename T>
void Vkm::Engine::NetSchema::replicate ( std::string name)

Add T to what replicates.

Requires free netEncode(const T&, BitWriter&) and netDecode(T&, BitReader&) visible here, or by argument-dependent lookup.

Template Parameters
TThe component type.
Parameters
nameWire and diagnostic identity; unique.

◆ indexOf()

int Vkm::Engine::NetSchema::indexOf ( std::string_view name) const

Wire index of name, or -1.

A linear search, so not for a per-entity path.

Parameters
nameThe registered name.
Returns
The index, or -1 when nothing is registered under it.

◆ fingerprint()

uint32_t Vkm::Engine::NetSchema::fingerprint ( ) const

A number that differs when the lists differ, or the codecs' layout does.

Over order, names and the quantiser's steps and widths. Catches honest mismatches; not a security measure.

Returns
The fingerprint the Hello carries.

◆ describe()

std::string Vkm::Engine::NetSchema::describe ( ) const

Every name in order, for the log line that follows a refusal.

Returns
The names, comma-separated, or "nothing".

◆ clear()

void Vkm::Engine::NetSchema::clear ( )
inline

Drops everything.

For a game module being (re)loaded. Never mid-session: renumbering would decode every snapshot against the wrong type.

Member Data Documentation

◆ MAX_TYPES

size_t Vkm::Engine::NetSchema::MAX_TYPES = 32
staticconstexpr

Most component types one game may replicate.

One bit each in a snapshot entry's 32-bit mask.


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