|
R-Type
Networked shoot'em up built on Aegis2D
|
Rebuilds the snapshots of the server from the payloads of its Snapshot datagrams.
More...
#include </__w/project-rtype/project-rtype/client/network/include/rtype/snapshot_decoder.hpp>
Public Member Functions | |
| bool | decodable (const DeltaSnapshot &part) const noexcept |
| Tells whether a payload can be decoded: a full snapshot, or a delta whose baseline is kept. | |
| std::optional< Snapshot > | decode (const DeltaSnapshot &part) |
| Rebuilds the snapshot of a payload, with the payloads of its tick received so far. | |
| const Snapshot * | find (std::uint32_t tick) const noexcept |
| A snapshot kept. | |
| std::size_t | size () const noexcept |
| Number of snapshots kept. | |
| std::uint64_t | dropped () const noexcept |
| Number of payloads dropped by decode(). | |
Static Public Attributes | |
| static constexpr std::size_t | capacity = 32 |
| Snapshots kept, as many as the server keeps per client. | |
Rebuilds the snapshots of the server from the payloads of its Snapshot datagrams.
Each payload is encoded against a baseline the client acknowledged, or none (write_delta_snapshot()). The decoder keeps the last capacity snapshots it rebuilt, as the baselines of the next ones, and the payloads of each one, as a snapshot may come in several datagrams. A payload whose baseline it no longer has, or that does not match it, is dropped: the datagram that carried it must not be acknowledged, so that the server never picks that snapshot as a baseline.
|
noexcept |
Tells whether a payload can be decoded: a full snapshot, or a delta whose baseline is kept.
| part | A payload read by read_delta_snapshot(). |
true if decode() can rebuild its snapshot. | std::optional< Snapshot > rtype::SnapshotDecoder::decode | ( | const DeltaSnapshot & | part | ) |
Rebuilds the snapshot of a payload, with the payloads of its tick received so far.
The snapshot is kept, replacing the one of the same tick, and the oldest beyond capacity is forgotten. Call it once per datagram: a duplicate would count twice.
| part | A payload read by read_delta_snapshot(). |
std::nullopt if the payload is dropped (counted by dropped()).
|
noexcept |
Number of payloads dropped by decode().
|
noexcept |
A snapshot kept.
| tick | Its tick. |
nullptr if none of that tick is kept.
|
noexcept |
Number of snapshots kept.
|
staticconstexpr |
Snapshots kept, as many as the server keeps per client.