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

TCP messages of the rooms (RFC sections 3.6 and 3.7): listing them, creating one, joining and leaving one, and starting its game. More...

#include <cstddef>
#include <cstdint>
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  rtype::RoomRules
 How a room plays, chosen at its creation (CreateRoom, RFC section 3.6). More...
 
struct  rtype::RoomPlayer
 A player of a room, as a RoomPlayers describes it. More...
 
struct  rtype::RoomPlayers
 Content of a RoomPlayers. More...
 
struct  rtype::RoomRecord
 A room, as a RoomList describes it. More...
 
struct  rtype::CreateRoomRequest
 Content of a CreateRoom. More...
 

Namespaces

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

Enumerations

enum class  rtype::RoomState : std::uint8_t { rtype::Waiting = 0 , rtype::Playing = 1 }
 What a room is doing, the state of a RoomList record. More...
 
enum class  rtype::RoomRejection : std::uint8_t {
  rtype::NoRoomLeft = 1 , rtype::BadName = 2 , rtype::BadSize = 3 , rtype::BadLives = 4 ,
  rtype::BadDifficulty = 5 , rtype::UnknownWaves = 6 , rtype::BadFriendlyFire = 7
}
 Why a room is not created, the reason of RoomRejected. More...
 
enum class  rtype::Difficulty : std::uint8_t { rtype::Easy = 0 , rtype::Normal = 1 , rtype::Hard = 2 }
 How hard the enemies of a room are: how often they come and how much they take. More...
 
enum class  rtype::JoinRejection : std::uint8_t { rtype::NoSuchRoom = 1 , rtype::RoomFull = 2 , rtype::InGame = 3 }
 Why a room is not joined, the reason of JoinRejected. More...
 

Functions

std::string_view rtype::to_string (RoomRejection reason) noexcept
 Short name of a rejection, for logs.
 
bool rtype::read_list_rooms (std::span< const std::byte > message) noexcept
 Tells whether a message is a well-formed ListRooms: its kind alone.
 
std::optional< std::vector< RoomRecord > > rtype::read_room_list (std::span< const std::byte > message)
 Reads a RoomList.
 
std::optional< CreateRoomRequest > rtype::read_create_room (std::span< const std::byte > message)
 Reads a CreateRoom.
 
std::optional< std::uint8_t > rtype::read_room_created (std::span< const std::byte > message) noexcept
 Reads a RoomCreated.
 
std::optional< std::uint8_t > rtype::read_room_rejected (std::span< const std::byte > message) noexcept
 Reads a RoomRejected.
 
std::string_view rtype::to_string (JoinRejection reason) noexcept
 Short name of a rejection, for logs.
 
std::optional< std::uint8_t > rtype::read_join_room (std::span< const std::byte > message) noexcept
 Reads a JoinRoom.
 
std::optional< std::pair< std::uint8_t, std::uint8_t > > rtype::read_room_joined (std::span< const std::byte > message) noexcept
 Reads a RoomJoined.
 
std::optional< std::uint8_t > rtype::read_join_rejected (std::span< const std::byte > message) noexcept
 Reads a JoinRejected.
 
bool rtype::read_leave_room (std::span< const std::byte > message) noexcept
 Tells whether a message is a well-formed LeaveRoom: its kind alone.
 
std::optional< bool > rtype::read_set_ready (std::span< const std::byte > message) noexcept
 Reads a SetReady.
 
std::optional< RoomPlayers > rtype::read_room_players (std::span< const std::byte > message)
 Reads a RoomPlayers.
 
bool rtype::read_game_start (std::span< const std::byte > message) noexcept
 Tells whether a message is a well-formed GameStart: its kind alone.
 
std::vector< std::byte > rtype::write_list_rooms ()
 Encodes a ListRooms.
 
std::vector< std::byte > rtype::write_room_list (std::span< const RoomRecord > rooms)
 Encodes a RoomList.
 
std::vector< std::byte > rtype::write_create_room (const CreateRoomRequest &request)
 Encodes a CreateRoom.
 
std::vector< std::byte > rtype::write_room_created (std::uint8_t room)
 Encodes a RoomCreated.
 
std::vector< std::byte > rtype::write_room_rejected (RoomRejection reason)
 Encodes a RoomRejected.
 
std::vector< std::byte > rtype::write_join_room (std::uint8_t room)
 Encodes a JoinRoom.
 
std::vector< std::byte > rtype::write_room_joined (std::uint8_t room, std::uint8_t player)
 Encodes a RoomJoined.
 
std::vector< std::byte > rtype::write_join_rejected (JoinRejection reason)
 Encodes a JoinRejected.
 
std::vector< std::byte > rtype::write_leave_room ()
 Encodes a LeaveRoom.
 
std::vector< std::byte > rtype::write_set_ready (bool ready)
 Encodes a SetReady.
 
std::vector< std::byte > rtype::write_room_players (const RoomPlayers &players)
 Encodes a RoomPlayers.
 
std::vector< std::byte > rtype::write_game_start ()
 Encodes a GameStart.
 

Variables

constexpr std::size_t rtype::max_listed_rooms = 64
 Most rooms a server may have, and a RoomList may hold.
 
constexpr std::uint8_t rtype::max_room_lives = 9
 Most lives a room may give its players.
 

Detailed Description

TCP messages of the rooms (RFC sections 3.6 and 3.7): listing them, creating one, joining and leaving one, and starting its game.