Aegis2D
Modular C++26 2D game engine for networked games
Loading...
Searching...
No Matches
sequence.hpp
Go to the documentation of this file.
1
5#pragma once
6#include <cstdint>
7
8namespace aegis2d::net {
9
12inline constexpr std::uint16_t sequence_half_range = 32768;
13
23[[nodiscard]] constexpr bool sequence_greater_than(std::uint16_t a, std::uint16_t b) noexcept {
24 return (a > b && a - b < sequence_half_range) || (a < b && b - a > sequence_half_range);
25}
26
32[[nodiscard]] constexpr bool sequence_less_than(std::uint16_t a, std::uint16_t b) noexcept {
33 return sequence_greater_than(b, a);
34}
35
36} // namespace aegis2d::net
Binary serialization, UDP/TCP sockets and the network thread.
Definition binary.hpp:14
constexpr std::uint16_t sequence_half_range
Half the range of a 16-bit sequence: the largest gap at which two sequences are still ordered is one ...
Definition sequence.hpp:12
constexpr bool sequence_less_than(std::uint16_t a, std::uint16_t b) noexcept
Whether sequence a was sent before sequence b, the counter having possibly wrapped in between.
Definition sequence.hpp:32
constexpr bool sequence_greater_than(std::uint16_t a, std::uint16_t b) noexcept
Whether sequence a was sent after sequence b, the counter having possibly wrapped in between.
Definition sequence.hpp:23