Message types, payload layouts and value encodings shared by the client and the server (src/Common/Protocol).
More...
|
| struct | rtype::protocol::BigEndian< T > |
| | Unsigned integer stored as big-endian bytes, with an alignment of 1. More...
|
| |
| struct | rtype::protocol::DisconnectPayload |
| | Payload of a Disconnect message, 1 byte. More...
|
| |
| struct | rtype::protocol::CreateEntityPayload |
| | Payload of a CreateEntity message, 16 bytes, sent by the server to spawn an entity on a client. More...
|
| |
| struct | rtype::protocol::DestroyEntityPayload |
| | Payload of a DestroyEntity message, 9 bytes, sent by the server to remove an entity from a client. More...
|
| |
| struct | rtype::protocol::QueryEntityPayload |
| | Payload of a QueryEntity message, 4 bytes, sent by a client that received a snapshot for an entity it does not know. More...
|
| |
| struct | rtype::protocol::InputPayload |
| | Payload of an Input message, 9 bytes, sent by a client every frame with the actions currently held. More...
|
| |
| struct | rtype::protocol::SnapshotHeader |
| | Fixed part of a Snapshot message, 6 bytes. More...
|
| |
| struct | rtype::protocol::SnapshotEntityState |
| | State of one entity inside a Snapshot message, 11 bytes. More...
|
| |
| struct | rtype::protocol::SnapshotPayload |
| | Decoded Snapshot message: a SnapshotHeader followed by entityCount SnapshotEntityState records. More...
|
| |
|
| enum class | rtype::protocol::DisconnectReason : std::uint8_t { DisconnectReason::ClientQuit = 0x01
, DisconnectReason::Timeout = 0x02
, DisconnectReason::ProtocolError = 0x03
, DisconnectReason::ServerShutdown = 0x04
} |
| | Reason carried by a Disconnect message. More...
|
| |
| enum class | rtype::protocol::DestroyReason : std::uint8_t {
DestroyReason::Unknown = 0x00
, DestroyReason::Collision = 0x01
, DestroyReason::OutOfBounds = 0x02
, DestroyReason::PlayerDisconnected = 0x03
,
DestroyReason::GameEnded = 0x04
} |
| | Reason carried by a DestroyEntity message. More...
|
| |
| enum class | rtype::protocol::InputAction : std::uint8_t {
InputAction::NoneAction = 0x00
, InputAction::Up = 0x01
, InputAction::Down = 0x02
, InputAction::Left = 0x04
,
InputAction::Right = 0x08
, InputAction::Shoot = 0x10
} |
| | Bit flags of the actions held by a player. More...
|
| |
| enum class | rtype::protocol::MessageType : std::uint16_t {
MessageType::Invalid = 0
, MessageType::Input = 0x02
, MessageType::Ping = 0x03
, MessageType::Disconnect = 0x04
,
MessageType::QueryEntity = 0x13
, MessageType::Snapshot = 0x83
, MessageType::CreateEntity = 0x84
, MessageType::DestroyEntity = 0x85
,
MessageType::Pong = 0x86
} |
| | Type identifier of every message exchanged on a connection. More...
|
| |
|
| constexpr bool | rtype::protocol::isValid (const DisconnectPayload &payload) |
| | Checks that the reason is a known value.
|
| |
| constexpr bool | rtype::protocol::isValid (const CreateEntityPayload &payload) |
| | Checks that the entity id is not 0.
|
| |
| constexpr bool | rtype::protocol::isValid (const DestroyEntityPayload &payload) |
| | Checks the entity id and the destroy reason.
|
| |
| constexpr bool | rtype::protocol::isValid (const QueryEntityPayload &payload) |
| | Checks that the entity id is not 0.
|
| |
| CreateEntityPayload | rtype::protocol::createEntityPayload (std::uint32_t serverTick, std::uint32_t networkId, std::uint16_t entityType, float x, float y, float rotation=0.0f) |
| | Builds a CreateEntity payload from world values.
|
| |
| DestroyEntityPayload | rtype::protocol::destroyEntityPayload (std::uint32_t serverTick, std::uint32_t networkId, DestroyReason reason) |
| | Builds a DestroyEntity payload.
|
| |
| constexpr InputAction | rtype::protocol::operator| (InputAction left, InputAction right) |
| | Combines two action sets.
|
| |
| constexpr bool | rtype::protocol::hasAction (InputAction actions, InputAction action) |
| | Tells whether an action set contains an action.
|
| |
| constexpr std::uint16_t | rtype::protocol::toMessageId (MessageType type) |
| | Converts a message type to its wire identifier.
|
| |
template<typename T >
requires std::is_trivially_copyable_v<T> |
| bool | rtype::protocol::writePayload (PacketWriter &writer, const T &payload) |
| | Appends the raw bytes of a padding free payload struct.
|
| |
template<typename T >
requires std::is_trivially_copyable_v<T> |
| bool | rtype::protocol::readPayload (PacketReader &reader, T &payload) |
| | Reads the raw bytes of a padding free payload struct.
|
| |
| be16 | rtype::protocol::encodePosition (float position) |
| | Encodes a position as a 16-bit fixed point value.
|
| |
| float | rtype::protocol::decodePosition (be16 encoded) |
| | Decodes a position encoded by encodePosition().
|
| |
| be16 | rtype::protocol::encodeRotation (float radians) |
| | Encodes an angle as a fraction of a full turn on 16 bits.
|
| |
| float | rtype::protocol::decodeRotation (be16 encoded) |
| | Decodes an angle encoded by encodeRotation().
|
| |
| bool | rtype::protocol::writeSnapshot (PacketWriter &writer, const SnapshotPayload &payload) |
| | Encodes a snapshot.
|
| |
| bool | rtype::protocol::readSnapshot (PacketReader &reader, SnapshotPayload &payload) |
| | Decodes and validates a snapshot.
|
| |
|
|
constexpr float | rtype::protocol::POSITION_SCALE = 4.0f |
| | Number of encoded steps per pixel, giving a 0.25 pixel resolution.
|
| |
|
constexpr float | rtype::protocol::POSITION_OFFSET = 8192.0f |
| | Offset added before encoding so that negative positions fit.
|
| |
|
constexpr float | rtype::protocol::MIN_POSITION = -POSITION_OFFSET |
| | Smallest position that can be encoded, in pixels.
|
| |
| constexpr float | rtype::protocol::MAX_POSITION |
| | Largest position that can be encoded, in pixels.
|
| |
| constexpr std::size_t | rtype::protocol::SNAPSHOT_MAX_ENTITIES |
| | Largest number of entity states that fit in one Snapshot message.
|
| |
Message types, payload layouts and value encodings shared by the client and the server (src/Common/Protocol).