![]() |
vkmEngine 1.0.0
A C++ game engine · vkmengine.com
|
What one connection is known to hold, so the next snapshot says less. More...
#include <snapshot.h>
Classes | |
| struct | Confirmed |
| One component of one entity, as this connection last confirmed it. More... | |
| struct | Pending |
| What a written snapshot claimed, held until it is acknowledged. More... | |
Public Member Functions | |
| const Confirmed * | find (EntityId entity, uint32_t type) const |
What is confirmed for entity's component type, or null. | |
| void | hold (Pending &&pending) |
| Hold what a snapshot said until it is confirmed or given up on. | |
| void | confirm (uint16_t sequence) |
Fold the snapshot sequence said into what is confirmed. | |
| void | expire (uint16_t sequence) |
Give up on everything older than sequence by more than the window an acknowledgement can still arrive in. | |
| void | gatherLost (const Scene &scene, std::vector< EntityId > &out) const |
| Entities this connection was told about that are no longer alive. | |
| void | clear () |
| Forget every entity and every unconfirmed snapshot. | |
What one connection is known to hold, so the next snapshot says less.
A component is sent, whole, when its encoded bits differ from what this connection has confirmed receiving: the delta is on presence, never on values, so every entry decodes from the packet alone and a joiner's first snapshot is the whole world by the same rule.
Confirmed, not sent, or a lost packet would never be resent: what a snapshot said is held until acknowledged. Per connection, since clients lose different packets. Comparing encoded bits lets a settled world go quiet.
What is confirmed for entity's component type, or null.
By entity, not slot: a slot can be reused before the old occupant's record is freed, and the new one would be taken as already held.
| entity | The occupant asked about. |
| type | The component's index in the schema. |
| void Vkm::Engine::NetBaseline::confirm | ( | uint16_t | sequence | ) |
Fold the snapshot sequence said into what is confirmed.
A change is folded only when newer than what the slot holds, so a late acknowledgement cannot write stale bytes over fresh.
| sequence | The acknowledged snapshot; one not held is ignored. |
| void Vkm::Engine::NetBaseline::expire | ( | uint16_t | sequence | ) |
Give up on everything older than sequence by more than the window an acknowledgement can still arrive in.
What they said is never confirmed, so the next snapshot says it again.
| sequence | The snapshot about to be written. |
| void Vkm::Engine::NetBaseline::gatherLost | ( | const Scene & | scene, |
| std::vector< EntityId > & | out ) const |
Entities this connection was told about that are no longer alive.
Reported until confirmed, which makes destruction reliable. By entity, not slot: a slot reused between snapshots is alive both times.
| scene | The world, to ask what is still in it. |
| out | Filled with the entities, ascending by slot. |
|
inline |
Forget every entity and every unconfirmed snapshot.
For a world replaced under a live session: a replacement reuses slot and generation, defeating find's guard.