R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
input.hpp File Reference

Inputs of a player sent to the server (RFC section 4.2). More...

#include <cstddef>
#include <cstdint>
#include <optional>
#include <span>
#include <vector>

Go to the source code of this file.

Classes

struct  rtype::InputRecord
 One input of the player: the actions held at one tick of the client. More...
 

Namespaces

namespace  rtype
 R-Type game code, built on the Aegis2D engine.
 

Functions

constexpr std::size_t rtype::input_payload_size (std::size_t count) noexcept
 Size of the payload of an Input datagram carrying count inputs: the sequence of the newest, the count, then the actions of each.
 
std::vector< std::byte > rtype::write_inputs (std::span< const InputRecord > inputs)
 Encodes the payload of an Input datagram, header excluded.
 
std::optional< std::vector< InputRecord > > rtype::read_inputs (std::span< const std::byte > payload)
 Decodes the payload of an Input datagram.
 

Variables

constexpr std::uint8_t rtype::valid_actions = 0x1FU
 Bits of the actions of an Input: up, down, left, right and fire; bits 5 to 7 must be clear.
 
constexpr std::size_t rtype::max_inputs_per_datagram = 4
 Inputs an Input datagram carries at most: the newest and the 3 before it, so a lost datagram's input arrives with one of the next three.
 

Detailed Description

Inputs of a player sent to the server (RFC section 4.2).