ISource2ModSnapshots

Snapshot inspector: what an entity sends to the clients, as the engine encodes it.

Schema reads tell what a field holds on the server. What a client gets is something else: only networked fields, through their encoders (quantized floats, packed vectors, handles), with the components (CBodyComponent, ...) flattened in. These calls encode the entity the way the engine does for a snapshot -- IFlattenedSerializers::Encode with the entity class's flattened serializer -- and read that back: every field that goes out, by its network name ("m_iHealth", "CBodyComponent.m_skeletonInstance.m_vecOrigin"), with the value as the engine prints it.

That is the full state a client would get for the entity now (a full update), before send proxies leave fields out for particular players. Encoding costs about what a snapshot of one entity does: fine for commands and checks, not for every entity every tick. Game thread only.

Got through the factory (g_pSource2ModSnapshots, filled by SOURCE2MOD_FILLGAMEVARS); null on a core without it.

Interface id ISource2ModSnapshots001 (SOURCE2MOD_SNAPSHOTS_INTERFACE) · Global g_pSource2ModSnapshots · Header source2mod/ISource2ModSnapshots.h

Types

SnapshotFieldCallback

using SnapshotFieldCallback = Source2ModCallback<void(uint32_t path, const char* name, const char* type, const char* value)>;

One field an entity sends.

SnapshotLineCallback

using SnapshotLineCallback = Source2ModCallback<void(const char* line)>;

One line of the engine's own dump of a serialized entity.

Methods

IsAvailable

virtual bool IsAvailable() = 0;

Whether the engine's serializer interfaces are there.

GetNetworkClassName

virtual const char* GetNetworkClassName(CEntityInstance* entity) = 0;

The entity's network class ("CCSPlayerPawn"); null for an entity that is not networked.

ParameterType
entityCEntityInstance*

GetFields

virtual int GetFields(CEntityInstance* entity, SnapshotFieldCallback callback) = 0;

Encodes the entity now and hands over every field that goes out.

ParameterType
entityCEntityInstance*
callbackSnapshotFieldCallback

Returns int — The number of fields, -1 when the entity cannot be encoded.

GetField

virtual bool GetField(CEntityInstance* entity, const char* name, char* value, size_t maxlen) = 0;

One field's encoded value by its network name (as GetFields() names it).

ParameterType
entityCEntityInstance*
nameconst char*
valuechar*
maxlensize_t

Returns bool — false when the entity does not send that field now.

Dump

virtual int Dump(CEntityInstance* entity, SnapshotLineCallback callback) = 0;

The engine's own dump of the encoded entity, line by line.

ParameterType
entityCEntityInstance*
callbackSnapshotLineCallback

Returns int — The number of lines, -1 when the entity cannot be encoded.

On this page