|
R-Type
Networked shoot'em up built on Aegis2D
|
Compact encoders of snapshot fields: fixed-point positions, integer velocities and varint ids, written bit by bit (RFC section 4.3). More...
#include <aegis2d/net/bits.hpp>#include <cstddef>#include <cstdint>#include <optional>Go to the source code of this file.
Namespaces | |
| namespace | rtype |
| R-Type game code, built on the Aegis2D engine. | |
Functions | |
| std::int32_t | rtype::quantize_position (float position) noexcept |
| Rounds a position to the nearest 1/8 px, clamped to [position_min, position_max]. | |
| float | rtype::dequantize_position (std::int32_t steps) noexcept |
| Position of a number of steps. | |
| std::int32_t | rtype::quantize_velocity (float velocity) noexcept |
| Rounds a velocity to the nearest whole pixel per second, clamped to [velocity_min, velocity_max]. | |
| void | rtype::write_position (aegis2d::net::BitWriter &writer, float position) |
| Writes a position on position_bits bits, see quantize_position(). | |
| std::optional< float > | rtype::read_position (aegis2d::net::BitReader &reader) noexcept |
| Reads a position written by write_position(). | |
| void | rtype::write_velocity (aegis2d::net::BitWriter &writer, float velocity) |
| Writes a velocity on velocity_bits bits, see quantize_velocity(). | |
| std::optional< float > | rtype::read_velocity (aegis2d::net::BitReader &reader) noexcept |
| Reads a velocity written by write_velocity(). | |
| void | rtype::write_varint (aegis2d::net::BitWriter &writer, std::uint32_t value) |
| Writes an id as a varint: groups of varint_group_bits bits, lowest first, each followed by a continuation bit set when another group follows. | |
| std::optional< std::uint32_t > | rtype::read_varint (aegis2d::net::BitReader &reader) noexcept |
| Reads a varint written by write_varint(). | |
| std::size_t | rtype::varint_bits (std::uint32_t value) noexcept |
| Size of a varint. | |
Variables | |
| constexpr std::int32_t | rtype::position_scale = 8 |
| Steps of a position per logical pixel: positions are sent to the 1/8 px. | |
| constexpr unsigned | rtype::position_bits = 15 |
| Bits of a position, sign included. | |
| constexpr float | rtype::position_min |
| Smallest position sent, in logical pixels: -2048. | |
| constexpr float | rtype::position_max |
| Largest position sent, in logical pixels: 2047.875. | |
| constexpr float | rtype::position_max_error = 0.5F / position_scale |
| Largest error of a position within [position_min, position_max]: 1/16 px. | |
| constexpr unsigned | rtype::velocity_bits = 12 |
| Bits of a velocity, sign included; velocities are sent in whole pixels per second. | |
| constexpr float | rtype::velocity_min = -static_cast<float>(std::int32_t{1} << (velocity_bits - 1U)) |
| Smallest velocity sent, in logical pixels per second: -2048. | |
| constexpr float | rtype::velocity_max |
| Largest velocity sent, in logical pixels per second: 2047. | |
| constexpr float | rtype::velocity_max_error = 0.5F |
| Largest error of a velocity within [velocity_min, velocity_max]: 0.5 px/s. | |
| constexpr unsigned | rtype::varint_group_bits = 7 |
| Bits of each group of a varint, followed by one continuation bit. | |
| constexpr std::size_t | rtype::varint_max_groups = 5 |
| Most groups of a varint: 5, for 32 bits. | |
Compact encoders of snapshot fields: fixed-point positions, integer velocities and varint ids, written bit by bit (RFC section 4.3).