|
R-Type
Networked shoot'em up built on Aegis2D
|
R-Type game code, built on the Aegis2D engine. More...
Namespaces | |
| namespace | layer |
One bit per kind of entity, for ecs::Collider::layer and ecs::Collider::mask. | |
| namespace | mask |
| What each layer collides with. | |
| namespace | tuning |
| Values tuned for the game, in logical pixels, seconds and health points. | |
Classes | |
| class | AdminConsole |
| The commands of the server's administrator, on the engine's command system. More... | |
| class | BanList |
| The IP addresses that cannot log in, kept in a JSON file. More... | |
| class | Bot |
| A client without window nor sound: a ClientSession whose inputs are RandomInputs, or ScriptedInputs when its settings have a script. More... | |
| struct | BotOptions |
| Settings of a bot run, read from the command line. More... | |
| struct | BotSettings |
| What a bot needs to join a server. More... | |
| struct | BotStats |
| The link of one bot over its game, as the network benchmark reads it. More... | |
| class | ChatLog |
| The chat messages to show, newest last, each for shown_for. More... | |
| struct | ChatMessage |
Content of a ChatMessage. More... | |
| class | ChatRate |
| The chat rate of one session (RFC section 3.8): a token bucket. More... | |
| struct | ClientOptions |
| Settings of a client run, read from the command line. More... | |
| class | ClientSession |
| The client side of a session (RFC section 3). More... | |
| struct | ClientSettings |
| What the client needs to join a server. More... | |
| class | ClientWorld |
| The world as the server describes it (RFC sections 4.3 to 4.5). More... | |
| class | ConnectForm |
| What the player types on the connect screen, checked before joining. More... | |
| class | ConsoleInput |
| The lines typed on a stream, read on a thread of their own, for the network thread to take between two updates. More... | |
| struct | CreateRoomRequest |
Content of a CreateRoom. More... | |
| struct | DeathEvent |
| A player lost a life where its ship was. More... | |
| struct | DeltaSnapshot |
| One payload of a snapshot encoded against a baseline. More... | |
| struct | DestroyEvent |
| An entity disappears, at its last position. More... | |
| struct | DraftEnemy |
| An enemy of a wave, where and when the editor places it. More... | |
| struct | DraftWave |
| A wave of the editor. More... | |
| class | DropReport |
| Counts the datagrams dropped from each address, by reason, for a summary in the log at most every report_period per address (RFC section 6.7): a flood never becomes one log line per datagram. More... | |
| struct | EditorPointer |
| The mouse of a frame, in logical pixels of the screen. More... | |
| struct | EditorView |
| Where the editor draws the play area, shrunk to show the strip beyond its right edge where the enemies appear, and the timeline of the waves under it. More... | |
| class | EnemyScripts |
| The enemy types of a directory of Lua scripts, and the behaviors of their enemies. More... | |
| struct | EnemyType |
Values of an enemy type, as its script gives them to enemy { ... }. More... | |
| struct | EntityDelta |
| What a delta snapshot says of one entity. More... | |
| struct | EntityRecord |
| What a snapshot says of an entity. More... | |
| class | EventTracker |
| Finds what changed in the game at each tick, as events. More... | |
| class | GameInstance |
| The one game of the server, with up to tuning::max_players players. More... | |
| struct | GameRules |
| How a game plays: the rules of its room, as the gameplay reads them. More... | |
| class | GameServer |
Runs the games of its rooms for the players of its sockets, as r-type_server does. More... | |
| struct | InputRecord |
| One input of the player: the actions held at one tick of the client. More... | |
| struct | InputScript |
| A sequence of inputs, played in order, then again from the start. More... | |
| class | Lagometer |
| The last seconds of the network statistics, for the graphs of the lagometer. More... | |
| struct | LagSample |
| The figures of every graph at one time, in the unit of each graph. More... | |
| struct | LevelDraft |
| A waves file opened in the editor. More... | |
| class | LevelEditor |
| Places and moves the enemies of a wave with the mouse, and the waves in time. More... | |
| struct | LoginAccepted |
Content of a LoginAccepted. More... | |
| struct | LoginRequest |
Content of a LoginRequest. More... | |
| class | NetworkStats |
| Measures the loss and the jitter of the server's datagrams over a sliding window. More... | |
| struct | NetworkSummary |
| What the client received from the server over the last NetworkStats::window. More... | |
| struct | PlayerJoinedEvent |
| A player joined the game. More... | |
| struct | PlayerLeftEvent |
A player left the game; the Destroy of its ship follows if it had one. More... | |
| struct | PlayerNotice |
| A message about a player, shown for a few seconds. More... | |
| class | PlayerNotices |
Turns PlayerJoined and PlayerLeft events into messages for the players who stay. More... | |
| struct | PlayerRecord |
| What a snapshot says of a player. More... | |
| struct | PlayerState |
| What the game says of a player, for the snapshots. More... | |
| class | PositionHistory |
| The positions of the enemies over the last tuning::position_history_ticks ticks. More... | |
| class | RandomInputs |
| Random actions held for random times, like a player mashing the keys. More... | |
| class | RateLimiter |
| Counts the datagrams of each address in windows of one second. More... | |
| struct | RateLimits |
| Limits on the traffic of one IP address. More... | |
| struct | RemotePlayer |
| What the client knows of a player of the game. More... | |
| struct | Replicated |
| What the client knows of an entity of the server, next to its components. More... | |
| class | Room |
| One game of the server: its GameInstance, the Simulation thread that runs it, the EventTracker of what its clients learnt, and the names of its players. More... | |
| class | RoomListForm |
| What the player does on the room list screen. More... | |
| struct | RoomPlayer |
A player of a room, as a RoomPlayers describes it. More... | |
| struct | RoomPlayers |
Content of a RoomPlayers. More... | |
| struct | RoomRecord |
A room, as a RoomList describes it. More... | |
| struct | RoomRules |
How a room plays, chosen at its creation (CreateRoom, RFC section 3.6). More... | |
| class | Scoreboard |
| The max_entries best scores, best first, kept in a JSON file. More... | |
| struct | ScoreEntry |
| One score of the board. More... | |
| struct | ScoreRecord |
One score of a ScoreList. More... | |
| class | ScriptedInputs |
| Plays an input script from the first call to update(), looping at its end. More... | |
| struct | ScriptStep |
| One line of an input script: actions held for a time. More... | |
| class | ServerGame |
| One R-Type game on the server: the world, its systems in order, and the players. More... | |
| class | ServerNetwork |
| The two ports the server listens on, and the TCP side of the sessions. More... | |
| struct | ServerOptions |
| Settings of a server run, read from the command line. More... | |
| struct | Session |
| A logged-in player (RFC section 3). More... | |
| class | SessionTable |
| The sessions of the server and the rooms they are in. More... | |
| struct | ShipMotion |
| Where a player ship is and how it moves, after a step. More... | |
| class | ShipPrediction |
| Where the client's own ship is, before the server says so. More... | |
| class | Simulation |
| Runs a GameInstance on its own thread, tuning::tick_rate times per second. More... | |
| struct | Snapshot |
| The state of the world at one tick. More... | |
| class | SnapshotDecoder |
Rebuilds the snapshots of the server from the payloads of its Snapshot datagrams. More... | |
| class | SnapshotHistory |
| The last snapshots sent to one client, and the ones it acknowledged. More... | |
| struct | SpawnEvent |
| An entity appears, with its kind, position and velocity. More... | |
| struct | Trail |
| The latest positions of an entity, oldest first, to draw it between two of them. More... | |
| struct | TrailPoint |
One position of an entity, as a snapshot (or its Spawn) gave it. More... | |
| struct | WaveSpan |
| When a wave plays, in seconds from the start of the waves. More... | |
Typedefs | |
| using | GameEvent = std::variant< SpawnEvent, DestroyEvent, DeathEvent, PlayerJoinedEvent, PlayerLeftEvent > |
| One of the gameplay events the server sends. | |
Enumerations | |
| enum class | ChatRejection : std::uint8_t { TooLong = 1 , BadText = 2 , TooFast = 3 } |
Why a chat message is not relayed, the reason of ChatRejected. More... | |
| enum class | EntityChange : std::uint8_t { Updated = 0 , Added = 1 , Removed = 2 } |
| What a delta snapshot says of an entity. More... | |
| enum class | EntityField : std::uint8_t { X = 1U << 0U , Y = 1U << 1U , Velocity = 1U << 2U , Frame = 1U << 3U } |
| Fields of an EntityChange::Updated record, one bit each. More... | |
| enum class | EventType : std::uint8_t { Spawn = 1 , Destroy = 2 , Death = 3 , PlayerJoined = 4 , PlayerLeft = 5 , GameOver = 6 } |
| Type of an event, its first byte (RFC section 4.4). More... | |
| enum class | DestroyReason : std::uint8_t { Despawned = 0 , Killed = 1 , Consumed = 2 , PlayerLeft = 3 } |
| Why an entity was destroyed, which tells the client what to show. More... | |
| enum class | LeaveReason : std::uint8_t { Left = 0 , TimedOut = 1 , Kicked = 2 } |
Why a player left the game, in PlayerLeft. More... | |
| enum class | TcpKind : std::uint8_t { LoginRequest = 1 , LoginAccepted = 2 , LoginRejected = 3 , Logout = 4 , ListRooms = 5 , RoomList = 6 , CreateRoom = 7 , RoomCreated = 8 , RoomRejected = 9 , JoinRoom = 10 , RoomJoined = 11 , JoinRejected = 12 , LeaveRoom = 13 , SetReady = 14 , RoomPlayers = 15 , GameStart = 16 , ChatSend = 17 , ChatMessage = 18 , ChatRejected = 19 , ListScores = 20 , ScoreList = 21 } |
| First byte of every TCP message: what it is. More... | |
| enum class | LoginRejection : std::uint8_t { ServerFull = 1 , BadVersion = 2 , BadName = 3 , NameTaken = 4 , GameStarted = 5 , Banned = 6 } |
Why a login is refused, the reason of LoginRejected. More... | |
| enum class | LogoutReason : std::uint8_t { Left = 0 , Shutdown = 1 , TimedOut = 2 , ProtocolError = 3 , RoomClosed = 4 , Kicked = 5 , Banned = 6 } |
Why a session ends, the reason of Logout. More... | |
| enum class | RoomState : std::uint8_t { Waiting = 0 , Playing = 1 } |
What a room is doing, the state of a RoomList record. More... | |
| enum class | RoomRejection : std::uint8_t { NoRoomLeft = 1 , BadName = 2 , BadSize = 3 , BadLives = 4 , BadDifficulty = 5 , UnknownWaves = 6 , BadFriendlyFire = 7 } |
Why a room is not created, the reason of RoomRejected. More... | |
| enum class | Difficulty : std::uint8_t { Easy = 0 , Normal = 1 , Hard = 2 } |
| How hard the enemies of a room are: how often they come and how much they take. More... | |
| enum class | JoinRejection : std::uint8_t { NoSuchRoom = 1 , RoomFull = 2 , InGame = 3 } |
Why a room is not joined, the reason of JoinRejected. More... | |
| enum class | EntityKind : std::uint8_t { PlayerShip = 1 , PlayerMissile = 2 , BydosSlave = 3 , EnemyMissile = 4 } |
| Kind of an entity in snapshots and events (RFC section 4.1). More... | |
| enum class | ServerCommand : std::uint8_t { Run , Help , Version } |
| What the server was asked to do. More... | |
| enum class | BindResult : std::uint8_t { Bound , AlreadyBound , UnknownSession , Taken , NoRoom } |
What SessionTable::bind() did with a Connect. More... | |
| enum class | ClientCommand : std::uint8_t { Run , Help , Version } |
| What the client was asked to do. More... | |
| enum class | ClientState : std::uint8_t { Idle , Connecting , LoggingIn , Lobby , InRoom , Binding , InGame , Failed , Lost , Closed } |
| Where the client is in its session. More... | |
| enum class | ConnectField : std::uint8_t { Host , Port , Name } |
| A field of the connect screen. More... | |
| enum class | LagGraph : std::uint8_t { Rtt , Jitter , Loss , Interval , BytesIn , BytesOut , Corrections } |
| A graph of the lagometer. More... | |
| enum class | LagLevel : std::uint8_t { Good , Warning , Bad } |
| How a figure compares with a sound link. More... | |
| enum class | BotCommand : std::uint8_t { Run , Help , Version } |
| What the bot was asked to do. More... | |
Functions | |
| std::filesystem::path | default_enemies_directory () |
| Directory of the enemy scripts the server plays. | |
| std::vector< std::string > | enemy_types (const std::filesystem::path &directory=default_enemies_directory()) |
| The enemy types of a directory, as waves files name them. | |
| aegis2d::Vec2 | player_spawn (std::size_t slot) |
| Where a player slot starts and respawns. | |
| aegis2d::ecs::Entity | spawn_player (aegis2d::ecs::Registry ®istry, std::size_t slot) |
| Creates the ship of a player. | |
| aegis2d::ecs::Entity | spawn_player_missile (aegis2d::ecs::Registry ®istry, aegis2d::ecs::Entity shooter) |
| Creates a missile fired by a player, in front of its ship. | |
| aegis2d::ecs::Entity | spawn_enemy_missile (aegis2d::ecs::Registry ®istry, aegis2d::Vec2 position) |
| Creates a missile fired by an enemy. | |
| aegis2d::ecs::Entity | fire_enemy_missile (aegis2d::ecs::Registry ®istry, aegis2d::ecs::Entity shooter) |
| Creates the missile an enemy fires, in front of it (on its left). | |
| std::uint32_t | rewind_ticks (std::chrono::nanoseconds rtt, std::chrono::nanoseconds interpolation) noexcept |
| How many ticks back a player sees the enemies. | |
| void | find_rewound_contacts (aegis2d::ecs::Registry ®istry, const PositionHistory &history, std::uint64_t tick, const std::function< std::uint32_t(aegis2d::ecs::Entity)> &rewind_of, std::vector< aegis2d::ecs::Contact > &contacts) |
| Finds the contacts of the player missiles with the enemies as their shooters saw them. | |
| aegis2d::Vec2 | ship_velocity (aegis2d::ecs::PlayerInput input) noexcept |
| Velocity of a player ship holding an input. | |
| aegis2d::Vec2 | keep_ship_in_area (aegis2d::Vec2 position) noexcept |
| Keeps a player ship inside the play area. | |
| ShipMotion | step_ship (aegis2d::Vec2 position, aegis2d::ecs::PlayerInput input, float delta) noexcept |
| Moves a player ship by one tick. | |
| void | steer_ships (aegis2d::ecs::Registry ®istry, const aegis2d::ecs::Tick &tick) |
| System that sets the velocity of every player ship from its input. | |
| void | keep_ships_in_area (aegis2d::ecs::Registry ®istry, const aegis2d::ecs::Tick &tick) |
| System that keeps every player ship inside the play area. | |
| std::filesystem::path | default_waves_file () |
| Waves file played by the server when none is given. | |
| std::vector< std::string > | waves_names (const std::filesystem::path &directory) |
| The waves files of a directory, as a room names them (RFC section 3.6). | |
| aegis2d::ecs::WaveSchedule | load_waves (const std::filesystem::path &path, const std::vector< std::string > &types=enemy_types()) |
| Reads a waves file, accepting only the enemy types it is given. | |
| std::string_view | to_string (ChatRejection reason) noexcept |
| Short name of a rejection, for logs. | |
| std::optional< ChatRejection > | check_chat_text (std::string_view text) noexcept |
Checks a text against the rules of ChatSend, the length first. | |
| std::optional< std::string > | read_chat_send (std::span< const std::byte > message) |
Reads a ChatSend. | |
| std::optional< ChatMessage > | read_chat_message (std::span< const std::byte > message) |
Reads a ChatMessage. | |
| std::optional< std::uint8_t > | read_chat_rejected (std::span< const std::byte > message) noexcept |
Reads a ChatRejected. | |
| std::vector< std::byte > | write_chat_send (std::string_view text) |
Encodes a ChatSend. | |
| std::vector< std::byte > | write_chat_message (const ChatMessage &message) |
Encodes a ChatMessage. | |
| std::vector< std::byte > | write_chat_rejected (ChatRejection reason) |
Encodes a ChatRejected. | |
| std::int32_t | quantize_position (float position) noexcept |
| Rounds a position to the nearest 1/8 px, clamped to [position_min, position_max]. | |
| float | dequantize_position (std::int32_t steps) noexcept |
| Position of a number of steps. | |
| std::int32_t | quantize_velocity (float velocity) noexcept |
| Rounds a velocity to the nearest whole pixel per second, clamped to [velocity_min, velocity_max]. | |
| void | write_position (aegis2d::net::BitWriter &writer, float position) |
| Writes a position on position_bits bits, see quantize_position(). | |
| std::optional< float > | read_position (aegis2d::net::BitReader &reader) noexcept |
| Reads a position written by write_position(). | |
| void | write_velocity (aegis2d::net::BitWriter &writer, float velocity) |
| Writes a velocity on velocity_bits bits, see quantize_velocity(). | |
| std::optional< float > | read_velocity (aegis2d::net::BitReader &reader) noexcept |
| Reads a velocity written by write_velocity(). | |
| void | 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 > | read_varint (aegis2d::net::BitReader &reader) noexcept |
| Reads a varint written by write_varint(). | |
| std::size_t | varint_bits (std::uint32_t value) noexcept |
| Size of a varint. | |
| EntityRecord | quantized (const EntityRecord &entity) noexcept |
| A record as the client gets it: position and velocity rounded as compact.hpp does, frame at most 15. | |
| std::vector< std::vector< std::byte > > | write_delta_snapshot (const Snapshot &snapshot, const Snapshot *baseline) |
Encodes a snapshot against a baseline, as the payloads of Snapshot datagrams. | |
| std::optional< DeltaSnapshot > | read_delta_snapshot (std::span< const std::byte > payload) |
| Decodes one payload written by write_delta_snapshot(). | |
| std::optional< Snapshot > | apply_delta (const Snapshot *baseline, std::span< const DeltaSnapshot > parts) |
| Rebuilds a snapshot from its baseline and every payload of its tick. | |
| std::vector< std::byte > | write_event (const GameEvent &event) |
| Encodes an event as the bytes of RFC section 4.4: type, tick, then its fields. | |
| std::vector< std::vector< std::byte > > | write_events (std::span< const GameEvent > events) |
| Encodes events with write_event(), for ServerNetwork::send_events(). | |
| std::optional< GameEvent > | read_event (std::span< const std::byte > bytes) |
| Decodes the bytes of one event, as a client does (RFC section 6.4). | |
| constexpr std::size_t | 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 > | write_inputs (std::span< const InputRecord > inputs) |
Encodes the payload of an Input datagram, header excluded. | |
| std::optional< std::vector< InputRecord > > | read_inputs (std::span< const std::byte > payload) |
Decodes the payload of an Input datagram. | |
| std::string_view | to_string (LoginRejection reason) noexcept |
| Short name of a rejection, for logs. | |
| bool | valid_text (std::string_view text, std::size_t max_size) noexcept |
Tells whether a text is 1 to max_size bytes of valid UTF-8 without control characters, as player names and chat texts must be. | |
| bool | valid_player_name (std::string_view name) noexcept |
Tells whether a name follows the rules of LoginRequest. | |
| std::optional< TcpKind > | kind_of (std::span< const std::byte > message) noexcept |
| Kind of a TCP message. | |
| std::optional< LoginRequest > | read_login_request (std::span< const std::byte > message) |
Reads a LoginRequest. | |
| std::optional< LoginAccepted > | read_login_accepted (std::span< const std::byte > message) noexcept |
Reads a LoginAccepted. | |
| std::optional< std::uint8_t > | read_login_rejected (std::span< const std::byte > message) noexcept |
Reads a LoginRejected. | |
| std::optional< std::uint8_t > | read_logout (std::span< const std::byte > message) noexcept |
Reads a Logout. | |
| std::vector< std::byte > | write_login_request (const LoginRequest &request) |
Encodes a LoginRequest. | |
| std::vector< std::byte > | write_login_accepted (const LoginAccepted &accepted) |
Encodes a LoginAccepted. | |
| std::vector< std::byte > | write_login_rejected (LoginRejection reason) |
Encodes a LoginRejected. | |
| std::vector< std::byte > | write_logout (LogoutReason reason) |
Encodes a Logout. | |
| std::string_view | to_string (RoomRejection reason) noexcept |
| Short name of a rejection, for logs. | |
| bool | 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 > > | read_room_list (std::span< const std::byte > message) |
Reads a RoomList. | |
| std::optional< CreateRoomRequest > | read_create_room (std::span< const std::byte > message) |
Reads a CreateRoom. | |
| std::optional< std::uint8_t > | read_room_created (std::span< const std::byte > message) noexcept |
Reads a RoomCreated. | |
| std::optional< std::uint8_t > | read_room_rejected (std::span< const std::byte > message) noexcept |
Reads a RoomRejected. | |
| std::string_view | to_string (JoinRejection reason) noexcept |
| Short name of a rejection, for logs. | |
| std::optional< std::uint8_t > | read_join_room (std::span< const std::byte > message) noexcept |
Reads a JoinRoom. | |
| std::optional< std::pair< std::uint8_t, std::uint8_t > > | read_room_joined (std::span< const std::byte > message) noexcept |
Reads a RoomJoined. | |
| std::optional< std::uint8_t > | read_join_rejected (std::span< const std::byte > message) noexcept |
Reads a JoinRejected. | |
| bool | 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 > | read_set_ready (std::span< const std::byte > message) noexcept |
Reads a SetReady. | |
| std::optional< RoomPlayers > | read_room_players (std::span< const std::byte > message) |
Reads a RoomPlayers. | |
| bool | 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 > | write_list_rooms () |
Encodes a ListRooms. | |
| std::vector< std::byte > | write_room_list (std::span< const RoomRecord > rooms) |
Encodes a RoomList. | |
| std::vector< std::byte > | write_create_room (const CreateRoomRequest &request) |
Encodes a CreateRoom. | |
| std::vector< std::byte > | write_room_created (std::uint8_t room) |
Encodes a RoomCreated. | |
| std::vector< std::byte > | write_room_rejected (RoomRejection reason) |
Encodes a RoomRejected. | |
| std::vector< std::byte > | write_join_room (std::uint8_t room) |
Encodes a JoinRoom. | |
| std::vector< std::byte > | write_room_joined (std::uint8_t room, std::uint8_t player) |
Encodes a RoomJoined. | |
| std::vector< std::byte > | write_join_rejected (JoinRejection reason) |
Encodes a JoinRejected. | |
| std::vector< std::byte > | write_leave_room () |
Encodes a LeaveRoom. | |
| std::vector< std::byte > | write_set_ready (bool ready) |
Encodes a SetReady. | |
| std::vector< std::byte > | write_room_players (const RoomPlayers &players) |
Encodes a RoomPlayers. | |
| std::vector< std::byte > | write_game_start () |
Encodes a GameStart. | |
| bool | read_list_scores (std::span< const std::byte > message) noexcept |
Tells whether a message is a well-formed ListScores. | |
| std::optional< std::vector< ScoreRecord > > | read_score_list (std::span< const std::byte > message) |
Reads a ScoreList. | |
| std::vector< std::byte > | write_list_scores () |
Encodes a ListScores. | |
| std::vector< std::byte > | write_score_list (std::span< const ScoreRecord > scores) |
Encodes a ScoreList. | |
| std::size_t | entity_record_bits (std::uint32_t id_gap) noexcept |
| Size of an entity record. | |
| std::vector< std::vector< std::byte > > | write_snapshot (const Snapshot &snapshot) |
Encodes a snapshot as the payloads of Snapshot datagrams, header excluded. | |
| std::optional< Snapshot > | read_snapshot (std::span< const std::byte > payload) |
Decodes the payload of one Snapshot datagram. | |
| GameRules | game_rules (const RoomRules &rules) noexcept |
| The gameplay of the rules a room was created with. | |
| aegis2d::net::Endpoint | address_of (const aegis2d::net::Endpoint &endpoint) noexcept |
| The address of an endpoint, its port set to 0: the key of the limits. | |
| std::variant< ServerOptions, std::string > | parse_server_options (std::span< const std::string_view > args) |
Reads the command line of r-type_server. | |
| bool | install_stop_handlers () |
Handles SIGINT and SIGTERM: the first one asks the server to stop cleanly (stop_requested() becomes true), a second one ends the process at once with forced_exit_status. | |
| bool | stop_requested () noexcept |
| Tells whether a stop was asked by a signal. Thread-safe. | |
| void | request_stop () noexcept |
Asks the server to stop, as a first Ctrl+C does: stop_requested() becomes true. | |
| std::optional< EntityKind > | kind_of_layer (std::uint32_t layer) noexcept |
| Kind of the entities of a collision layer, for snapshots and events. | |
| constexpr bool | snapshot_due (std::uint64_t tick) noexcept |
| Tells whether a snapshot is due after a tick. | |
| Snapshot | take_snapshot (GameInstance &instance) |
| Takes the state of the game, on the simulation thread. | |
| std::string | chat_rejection_text (std::uint8_t reason) |
| Sentence telling why a message was not sent. | |
| std::optional< std::uint16_t > | parse_port (std::string_view text) noexcept |
Reads a TCP port, as --port and the connect screen take it. | |
| std::variant< ClientOptions, std::string > | parse_client_options (std::span< const std::string_view > args) |
Reads the command line of r-type_client. | |
| std::string_view | to_string (ClientState state) noexcept |
| Short name of a state, for logs. | |
| aegis2d::Vec2 | interpolate (const Trail &trail, double tick) noexcept |
| Position of an entity at a tick, between the positions of its trail. | |
| LagSample | measure_lag (const aegis2d::net::RttEstimator &rtt, const aegis2d::net::TrafficCounters &traffic, const NetworkStats &stats, std::chrono::steady_clock::time_point now) |
| Reads the network statistics of the client into a sample. | |
| LagLevel | lag_level (LagGraph graph, double value) noexcept |
| Level of a value of a graph: the RTT is bad above 200 ms, the loss above 5 %... | |
| std::string | lag_label (LagGraph graph, double value) |
Label of a value of a graph, for the overlay: "RTT 152 MS", "LOSS 2.5 %". | |
| std::vector< std::string > | lag_lines (const LagSample &sample) |
| The figures of a sample as lines of the engine's metrics overlay, so that the frame metrics (F12) show the network too, with or without the lagometer (F6). | |
| std::string | left_message (const std::string &name, LeaveReason reason) |
| Sentence telling why a player left. | |
| std::vector< BotSettings > | bot_team (const BotSettings &base, std::size_t count) |
The settings of count bots that play together, for --count. | |
| std::variant< BotOptions, std::string > | parse_bot_options (std::span< const std::string_view > args) |
Reads the command line of r-type_bot. | |
| BotStats | measure_bot (const Bot &bot, std::string name, std::chrono::steady_clock::duration played, std::chrono::steady_clock::time_point now) |
| Reads what a bot measured, before it leaves. | |
| std::string | bot_stats_line (const BotStats &stats) |
One line of a --stats file, in the order of bot_stats_header, without its end. | |
| std::variant< InputScript, std::string > | parse_input_script (std::string_view text) |
| Reads an input script. | |
| std::variant< InputScript, std::string > | load_input_script (const std::filesystem::path &file) |
| Reads an input script from a file. | |
Variables | |
| constexpr std::size_t | max_chat_size = 200 |
| Longest chat text, in bytes of UTF-8. | |
| constexpr std::uint8_t | lobby_player = 255 |
player of a ChatMessage whose sender is in the lobby, with no player number. | |
| constexpr std::uint8_t | server_player = 254 |
player of a ChatMessage of the server itself, such as its administrator's say: no player has it (RFC section 3.8). | |
| constexpr std::string_view | server_name = "server" |
name of a ChatMessage of the server itself. | |
| constexpr std::int32_t | position_scale = 8 |
| Steps of a position per logical pixel: positions are sent to the 1/8 px. | |
| constexpr unsigned | position_bits = 15 |
| Bits of a position, sign included. | |
| constexpr float | position_min |
| Smallest position sent, in logical pixels: -2048. | |
| constexpr float | position_max |
| Largest position sent, in logical pixels: 2047.875. | |
| constexpr float | position_max_error = 0.5F / position_scale |
| Largest error of a position within [position_min, position_max]: 1/16 px. | |
| constexpr unsigned | velocity_bits = 12 |
| Bits of a velocity, sign included; velocities are sent in whole pixels per second. | |
| constexpr float | velocity_min = -static_cast<float>(std::int32_t{1} << (velocity_bits - 1U)) |
| Smallest velocity sent, in logical pixels per second: -2048. | |
| constexpr float | velocity_max |
| Largest velocity sent, in logical pixels per second: 2047. | |
| constexpr float | velocity_max_error = 0.5F |
| Largest error of a velocity within [velocity_min, velocity_max]: 0.5 px/s. | |
| constexpr unsigned | varint_group_bits = 7 |
| Bits of each group of a varint, followed by one continuation bit. | |
| constexpr std::size_t | varint_max_groups = 5 |
| Most groups of a varint: 5, for 32 bits. | |
| constexpr unsigned | change_bits = 2 |
| Bits of the change of a delta record. | |
| constexpr unsigned | entity_field_bits = 4 |
| Bits of the fields of an EntityChange::Updated record. | |
| constexpr std::uint8_t | no_player = 255 |
Player number meaning "no player", as the owner of an enemy. | |
| constexpr std::size_t | spawn_event_size = 27 |
Size of a Spawn event, type and tick included. | |
| constexpr std::size_t | destroy_event_size = 18 |
Size of a Destroy event, type and tick included. | |
| constexpr std::size_t | death_event_size = 15 |
Size of a Death event, type and tick included. | |
| constexpr std::size_t | player_left_event_size = 7 |
Size of a PlayerLeft event, type and tick included. | |
| constexpr std::uint8_t | 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 | 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. | |
| constexpr std::uint8_t | protocol_version = 1 |
Protocol version the server speaks, in LoginRequest and in the UDP header. | |
| constexpr std::size_t | max_name_size = 16 |
| Longest player name, in bytes of UTF-8. | |
| constexpr std::size_t | max_listed_rooms = 64 |
Most rooms a server may have, and a RoomList may hold. | |
| constexpr std::uint8_t | max_room_lives = 9 |
| Most lives a room may give its players. | |
| constexpr std::size_t | max_listed_scores = 10 |
Most scores in a ScoreList. | |
| constexpr std::uint32_t | no_entity = 0xFFFFFFFF |
| Network id that names no entity, for a player out of lives. | |
| constexpr std::size_t | snapshot_fixed_bits = 32 + 3 + 16 |
| Bits of the tick, the player count and the entity count of a snapshot payload. | |
| constexpr unsigned | id_low_bits = 24 |
| Low bits of a network id, sent as their gap to those of the previous record: the index of the engine's Entity handles, small and dense among live entities. | |
| constexpr unsigned | id_high_bits = 8 |
| High bits of a network id, sent as they are: the generation of Entity handles. | |
| constexpr unsigned | kind_bits = 3 |
| Bits of the kind of an entity record: kinds 0 to 7. | |
| constexpr unsigned | frame_bits = 4 |
| Bits of the frame of an entity record: frames above 15 are sent as 15. | |
| constexpr std::size_t | entity_record_fixed_bits |
| Bits of an entity record besides the gap of its id's low bits: the id's high bits, kind, position, velocity and frame (69). | |
| constexpr std::uint32_t | short_id_gap = (std::uint32_t{1} << varint_group_bits) - 1U |
| Largest gap between the low bits of two records' ids that keeps a record within 10 bytes (77 bits). | |
| constexpr std::uint16_t | default_tcp_port = 4242 |
TCP port the server listens on when --tcp-port is not given. | |
| constexpr std::uint16_t | default_udp_port = 4243 |
UDP port the server listens on when --udp-port is not given. | |
| constexpr std::uint32_t | default_packet_rate = 300 |
Datagrams accepted per second from one address when --max-packet-rate is not given; see RateLimits. | |
| constexpr std::uint32_t | default_max_rooms = 4 |
Rooms played at once when --max-rooms is not given; see GameServer. | |
| constexpr std::string_view | default_scores_file = "scores.json" |
| File of the best scores, in the folder the server runs from. | |
| constexpr std::string_view | default_bans_file = "bans.json" |
| File of the banned addresses, in the folder the server runs from. | |
| constexpr std::string_view | server_usage |
Usage line printed by --help and after a command line error. | |
| constexpr std::uint32_t | no_room = 0xFFFFFFFFU |
Room of a session in the lobby, out of every room (LeaveRoom, RFC section 3.7). | |
| constexpr int | forced_exit_status = 130 |
| Exit status of a server stopped by a second signal, before its clean stop ended. | |
| constexpr std::string_view | client_usage |
Usage line printed by --help and after a command line error. | |
| constexpr std::size_t | connect_field_count = 3 |
| Number of fields of ConnectField. | |
| constexpr std::size_t | lag_graph_count = 7 |
| Number of graphs: LagGraph values are 0 to lag_graph_count - 1. | |
| constexpr std::string_view | bot_usage |
Usage line printed by --help and after a command line error. | |
| constexpr std::uint32_t | max_bots = 64 |
Most bots --count runs in one process. | |
| constexpr std::string_view | bot_stats_header |
First line of a --stats file: the names of the columns of bot_stats_line(). | |
R-Type game code, built on the Aegis2D engine.
| using rtype::GameEvent = typedef std::variant<SpawnEvent, DestroyEvent, DeathEvent, PlayerJoinedEvent, PlayerLeftEvent> |
One of the gameplay events the server sends.
|
strong |
What SessionTable::bind() did with a Connect.
|
strong |
|
strong |
|
strong |
|
strong |
Where the client is in its session.
| Enumerator | |
|---|---|
| Idle | Not started. |
| Connecting | Opening the TCP connection. |
| LoggingIn |
|
| Lobby | Logged in with ClientSettings::choose_room: choosing a room (RFC 3.6, 3.7). |
| InRoom | In the room joined from the lobby, until all its players are ready (RFC 3.7). |
| Binding | Logged in, sending |
| InGame | UDP endpoint bound: the game may start. |
| Failed | The session could not start; error() says why. |
| Lost | The session was running and ended: the server stopped, went silent, closed the connection or ended the session; error() says why, for the connection-lost screen. |
| Closed | The player left with leave(). |
|
strong |
|
strong |
Why an entity was destroyed, which tells the client what to show.
The values are part of the protocol: never renumber them.
| Enumerator | |
|---|---|
| Despawned | It left the play area: no effect. |
| Killed | It was destroyed: an explosion. |
| Consumed | A missile that hit its target: it vanishes. |
| PlayerLeft | The ship of a player who left the game. |
|
strong |
|
strong |
What a delta snapshot says of an entity.
The values are part of the payload: never renumber them.
| Enumerator | |
|---|---|
| Updated | Some fields changed since the baseline; EntityDelta::fields says which. |
| Added | Not in the baseline (or no baseline): every field is sent. |
| Removed | In the baseline, gone since. |
|
strong |
Fields of an EntityChange::Updated record, one bit each.
| Enumerator | |
|---|---|
| X |
|
| Y |
|
| Velocity |
|
| Frame |
|
|
strong |
|
strong |
Type of an event, its first byte (RFC section 4.4).
The values are part of the protocol: never renumber them.
|
strong |
|
strong |
A graph of the lagometer.
| Enumerator | |
|---|---|
| Rtt | Smoothed round trip time, in milliseconds. |
| Jitter | Jitter of the snapshots' arrivals, in milliseconds. |
| Loss | Share of the server's datagrams lost, in percent. |
| Interval | Mean time between two snapshots, in milliseconds. |
| BytesIn | Bytes received per second. |
| BytesOut | Bytes sent per second. |
| Corrections | Corrections of the predicted ship per second (ShipPrediction::corrections()). |
|
strong |
|
strong |
Why a player left the game, in PlayerLeft.
The values are part of the protocol: never renumber them.
|
strong |
Why a login is refused, the reason of LoginRejected.
|
strong |
Why a session ends, the reason of Logout.
|
strong |
Why a room is not created, the reason of RoomRejected.
|
strong |
|
strong |
|
strong |
First byte of every TCP message: what it is.
The values are part of the protocol: never renumber them.
|
noexcept |
The address of an endpoint, its port set to 0: the key of the limits.
| endpoint | Source of a datagram or a connection. |
| std::optional< Snapshot > rtype::apply_delta | ( | const Snapshot * | baseline, |
| std::span< const DeltaSnapshot > | parts | ||
| ) |
Rebuilds a snapshot from its baseline and every payload of its tick.
| baseline | The snapshot of DeltaSnapshot::baseline, as the client rebuilt it, or nullptr for a full snapshot. |
| parts | Every payload of the tick, in any order. |
std::nullopt if parts is empty, mixes ticks or baselines, does not match baseline, or updates or removes an entity the baseline does not have. | std::string rtype::bot_stats_line | ( | const BotStats & | stats | ) |
One line of a --stats file, in the order of bot_stats_header, without its end.
| stats | Figures of a bot. |
| std::vector< BotSettings > rtype::bot_team | ( | const BotSettings & | base, |
| std::size_t | count | ||
| ) |
The settings of count bots that play together, for --count.
One bot keeps base. Several are named after it with their number from 1 (bot1, bot2...), so the server takes them all, and the random ones each get their own seed: base's plus their index. They share the script, if any.
| base | Settings of the first bot. |
| count | Number of bots, at least 1. |
| std::string rtype::chat_rejection_text | ( | std::uint8_t | reason | ) |
Sentence telling why a message was not sent.
| reason | reason of a ChatRejected, unknown values included. |
"Message not sent: too long", "... too fast"...
|
noexcept |
Checks a text against the rules of ChatSend, the length first.
| text | Bytes received. |
std::nullopt if the text may be relayed, or ChatRejection::TooLong or ChatRejection::BadText. | std::filesystem::path rtype::default_enemies_directory | ( | ) |
Directory of the enemy scripts the server plays.
core::asset_path("enemies"): assets/enemies of the repository, copied next to r-type_server by the build. | std::filesystem::path rtype::default_waves_file | ( | ) |
Waves file played by the server when none is given.
core::asset_path("waves/stage1.json"): assets/waves/stage1.json of the repository, copied next to r-type_server by the build.
|
noexcept |
Position of a number of steps.
| steps | Position in 1/8 px. |
| std::vector< std::string > rtype::enemy_types | ( | const std::filesystem::path & | directory = default_enemies_directory() | ) |
The enemy types of a directory, as waves files name them.
| directory | Directory of the scripts. |
.lua files without their extension, sorted; none if the directory cannot be read.
|
noexcept |
Size of an entity record.
| id_gap | The low id_low_bits bits of its id minus those of the record before it in the payload, or those bits themselves for the first record. |
id_gap as a varint: 77 bits up to short_id_gap. | void rtype::find_rewound_contacts | ( | aegis2d::ecs::Registry & | registry, |
| const PositionHistory & | history, | ||
| std::uint64_t | tick, | ||
| const std::function< std::uint32_t(aegis2d::ecs::Entity)> & | rewind_of, | ||
| std::vector< aegis2d::ecs::Contact > & | contacts | ||
| ) |
Finds the contacts of the player missiles with the enemies as their shooters saw them.
Each entity of the player_missile layer with an ecs::Owner whose rewind is above 0 is tested, at its position now, against each enemy of history at tick - rewind that is still alive, with the enemy's collider. The contacts found are added to contacts as ecs::find_contacts() writes them, so ecs::apply_damage() counts them with the others; a missile that hits both now and then is consumed by the first.
| registry | World of the game. |
| history | Positions of the enemies at the last ticks. |
| tick | Number the current state will have in history once recorded. |
| rewind_of | Rewind of a shooter, from rewind_ticks(); 0 for no compensation. |
| contacts | Contacts of the tick, to add to. |
| aegis2d::ecs::Entity rtype::fire_enemy_missile | ( | aegis2d::ecs::Registry & | registry, |
| aegis2d::ecs::Entity | shooter | ||
| ) |
Creates the missile an enemy fires, in front of it (on its left).
A spawn_enemy_missile() just left of the enemy's sprite (or of its center without one), with ecs::Owner set to the enemy.
| registry | World of the game. |
| shooter | Enemy that fires; it must have a Transform. |
| std::out_of_range | If shooter has no Transform. |
The gameplay of the rules a room was created with.
Easy and Hard take the enemy health and the spawn intervals of their tuning::easy_* and tuning::hard_* values; Normal, and anything else, the game as tuned. The waves file is not part of it: GameServer picks the waves of the room.
| rules | Rules checked by SessionTable::create_room(). |
|
constexprnoexcept |
Size of the payload of an Input datagram carrying count inputs: the sequence of the newest, the count, then the actions of each.
| count | Number of inputs, 1 to max_inputs_per_datagram. |
3 + count bytes. | bool rtype::install_stop_handlers | ( | ) |
Handles SIGINT and SIGTERM: the first one asks the server to stop cleanly (stop_requested() becomes true), a second one ends the process at once with forced_exit_status.
The handler only sets a lock-free atomic flag, or calls std::_Exit(): nothing else is safe in a signal handler. Windows has no SIGTERM from the system, but Ctrl+C raises SIGINT.
false if a handler could not be installed: that signal then ends the process.
|
noexcept |
Position of an entity at a tick, between the positions of its trail.
Between two positions, the linear interpolation; before the oldest, the oldest; after the newest, the newest (the entity is not pushed past what the server said). Ticks may be fractional, the time between two ticks.
| trail | Positions of the entity, at least one. |
| tick | Server tick to draw. |
|
noexcept |
Keeps a player ship inside the play area.
Its box (tuning::player_size) must fit in ServerGame::play_area(): holding a direction against an edge stops the ship there, and it can leave the edge at once.
| position | Center of the ship. |
| void rtype::keep_ships_in_area | ( | aegis2d::ecs::Registry & | registry, |
| const aegis2d::ecs::Tick & | tick | ||
| ) |
System that keeps every player ship inside the play area.
keep_ship_in_area() for each entity with shmup::PlayerShip and ecs::Transform; run it after ecs::apply_velocity().
| registry | World holding the ships. |
| tick | Unused. |
|
noexcept |
Kind of a TCP message.
| message | Message received, length prefix excluded. |
std::nullopt if it is empty or its kind is reserved.
|
noexcept |
Kind of the entities of a collision layer, for snapshots and events.
Each layer holds one kind of entity for now.
| layer | ecs::Collider::layer, one of the values of rtype::layer. |
std::nullopt for a layer whose entities are not replicated. | std::string rtype::lag_label | ( | LagGraph | graph, |
| double | value | ||
| ) |
Label of a value of a graph, for the overlay: "RTT 152 MS", "LOSS 2.5 %".
| graph | Graph of the value. |
| value | Value, in the unit of the graph. |
Level of a value of a graph: the RTT is bad above 200 ms, the loss above 5 %...
The bandwidth is always Good: how much is too much depends on the link.
| graph | Graph of the value. |
| value | Value, in the unit of the graph. |
| std::vector< std::string > rtype::lag_lines | ( | const LagSample & | sample | ) |
The figures of a sample as lines of the engine's metrics overlay, so that the frame metrics (F12) show the network too, with or without the lagometer (F6).
| sample | Figures, such as Lagometer::latest(). |
"RTT 42 MS JITTER 3 MS LOSS 0.0 %", "IN 1.5 KB/S OUT 0.8 KB/S" and "SNAPSHOTS 50 MS CORRECTED 0/S". | std::string rtype::left_message | ( | const std::string & | name, |
| LeaveReason | reason | ||
| ) |
Sentence telling why a player left.
| name | Name of the player. |
| reason | Why it left, as PlayerLeft gives it. |
"<name> left the game", "<name> lost the connection" or "<name> was removed from the game". | std::variant< InputScript, std::string > rtype::load_input_script | ( | const std::filesystem::path & | file | ) |
Reads an input script from a file.
| file | Script file. |
| aegis2d::ecs::WaveSchedule rtype::load_waves | ( | const std::filesystem::path & | path, |
| const std::vector< std::string > & | types = enemy_types() |
||
| ) |
Reads a waves file, accepting only the enemy types it is given.
| path | JSON file in the format of ecs::WaveSchedule. |
| types | Enemy types it may name: by default, the scripts of default_enemies_directory(). |
ServerGame::play_waves(). | aegis2d::core::ConfigError | If the file cannot be read or is not valid waves (an unknown type included); the message names the file and the faulty value. |
| BotStats rtype::measure_bot | ( | const Bot & | bot, |
| std::string | name, | ||
| std::chrono::steady_clock::duration | played, | ||
| std::chrono::steady_clock::time_point | now | ||
| ) |
Reads what a bot measured, before it leaves.
| bot | The bot. |
| name | Its player name. |
| played | Time it spent in game. |
| now | Current time, the end of the windows of the loss and the snapshot jitter. |
| LagSample rtype::measure_lag | ( | const aegis2d::net::RttEstimator & | rtt, |
| const aegis2d::net::TrafficCounters & | traffic, | ||
| const NetworkStats & | stats, | ||
| std::chrono::steady_clock::time_point | now | ||
| ) |
Reads the network statistics of the client into a sample.
| rtt | Round trip time to the server (ClientSession::rtt()). |
| traffic | Datagrams exchanged (ClientSession::traffic()): the last whole second. |
| stats | Loss and snapshots (ClientSession::network_stats()): the last 2 seconds. |
| now | Current time. |
| std::variant< BotOptions, std::string > rtype::parse_bot_options | ( | std::span< const std::string_view > | args | ) |
Reads the command line of r-type_bot.
Options may come in any order; a repeated option keeps its last value. --help and --version stop the reading. The port is a number from 1 to 65535, the seconds a number from 1, the count a number from 1 to max_bots, the seed any 32-bit number; the address and the name are checked when the bot joins (ClientSession::start()), the script when it is loaded.
| args | Arguments after the program name. |
| std::variant< ClientOptions, std::string > rtype::parse_client_options | ( | std::span< const std::string_view > | args | ) |
Reads the command line of r-type_client.
Options may come in any order; a repeated option keeps its last value. --help and --version stop the reading. The port is a number from 1 to 65535, the frames a number from 1; the address and the name are checked when the client joins (ClientSession::start()).
| args | Arguments after the program name. |
| std::variant< InputScript, std::string > rtype::parse_input_script | ( | std::string_view | text | ) |
Reads an input script.
One step per line: a duration in milliseconds, then the actions held, as the letters U (up), D (down), L (left), R (right) and F (fire), or - for none:
Blank lines and lines starting with # are skipped; spaces and tabs separate the fields.
| text | Contents of the script. |
|
noexcept |
Reads a TCP port, as --port and the connect screen take it.
| text | Decimal digits only: no sign, space or base prefix. |
| std::variant< ServerOptions, std::string > rtype::parse_server_options | ( | std::span< const std::string_view > | args | ) |
Reads the command line of r-type_server.
Options may come in any order; a repeated option keeps its last value. --help and --version stop the reading: what follows them is not checked. A port is a decimal number from 0 to 65535, 0 asking the system for a free port.
| args | Arguments after the program name. |
| aegis2d::Vec2 rtype::player_spawn | ( | std::size_t | slot | ) |
Where a player slot starts and respawns.
Slots are spread over the height of the play area, at tuning::player_spawn_x.
| slot | Player slot, from 0 to tuning::max_players - 1. |
| std::out_of_range | If slot is not a valid slot. |
|
noexcept |
Rounds a position to the nearest 1/8 px, clamped to [position_min, position_max].
| position | Position in logical pixels; NaN gives 0. |
|
noexcept |
Rounds a velocity to the nearest whole pixel per second, clamped to [velocity_min, velocity_max].
| velocity | Velocity in logical pixels per second; NaN gives 0. |
|
noexcept |
A record as the client gets it: position and velocity rounded as compact.hpp does, frame at most 15.
| entity | Record of the server. |
| std::optional< ChatMessage > rtype::read_chat_message | ( | std::span< const std::byte > | message | ) |
Reads a ChatMessage.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed ChatMessage.
|
noexcept |
Reads a ChatRejected.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed ChatRejected. | std::optional< std::string > rtype::read_chat_send | ( | std::span< const std::byte > | message | ) |
Reads a ChatSend.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed ChatSend. | std::optional< CreateRoomRequest > rtype::read_create_room | ( | std::span< const std::byte > | message | ) |
Reads a CreateRoom.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed CreateRoom. | std::optional< DeltaSnapshot > rtype::read_delta_snapshot | ( | std::span< const std::byte > | payload | ) |
Decodes one payload written by write_delta_snapshot().
| payload | Bytes after the header. |
std::nullopt if it is malformed (as read_snapshot(), plus a baseline not older than the tick, a change of 3, an update of no field, or a removal without baseline). | std::optional< GameEvent > rtype::read_event | ( | std::span< const std::byte > | bytes | ) |
Decodes the bytes of one event, as a client does (RFC section 6.4).
| bytes | Bytes of the event, as handed over by ReliableChannel::read_events(). |
std::nullopt if its type is not one of the five above or its bytes do not match the type: a wrong size, a non-finite position or velocity, an owner other than 0 to 3 and 255, a player above 3, or a name that breaks the rules of valid_player_name(). Unknown kinds and reasons are kept, for the caller to apply its rules.
|
noexcept |
Tells whether a message is a well-formed GameStart: its kind alone.
| message | Message received, length prefix excluded. |
true if it is. | std::optional< std::vector< InputRecord > > rtype::read_inputs | ( | std::span< const std::byte > | payload | ) |
Decodes the payload of an Input datagram.
| payload | Bytes after the header. |
std::nullopt if the count is 0 or above max_inputs_per_datagram, the payload is not input_payload_size() bytes for it, or an input sets a bit outside valid_actions.
|
noexcept |
Reads a JoinRejected.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed JoinRejected.
|
noexcept |
Reads a JoinRoom.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed JoinRoom.
|
noexcept |
Tells whether a message is a well-formed LeaveRoom: its kind alone.
| message | Message received, length prefix excluded. |
true if it is.
|
noexcept |
Tells whether a message is a well-formed ListRooms: its kind alone.
| message | Message received, length prefix excluded. |
true if it is.
|
noexcept |
Tells whether a message is a well-formed ListScores.
| message | Message received, length prefix excluded. |
true for a ListScores, with no field.
|
noexcept |
Reads a LoginAccepted.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed LoginAccepted.
|
noexcept |
Reads a LoginRejected.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed LoginRejected. | std::optional< LoginRequest > rtype::read_login_request | ( | std::span< const std::byte > | message | ) |
Reads a LoginRequest.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed LoginRequest: another kind, a field past the end, or bytes after the name.
|
noexcept |
Reads a Logout.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed Logout.
|
noexcept |
Reads a position written by write_position().
| reader | Source. |
|
noexcept |
Reads a RoomCreated.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed RoomCreated.
|
noexcept |
Reads a RoomJoined.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed RoomJoined. | std::optional< std::vector< RoomRecord > > rtype::read_room_list | ( | std::span< const std::byte > | message | ) |
Reads a RoomList.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed RoomList: another kind, more than max_listed_rooms rooms, a field past the end, or bytes after the last room. | std::optional< RoomPlayers > rtype::read_room_players | ( | std::span< const std::byte > | message | ) |
Reads a RoomPlayers.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed RoomPlayers: another kind, more than 4 players, a ready other than 0 or 1, a field past the end, or bytes after the last player.
|
noexcept |
Reads a RoomRejected.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed RoomRejected. | std::optional< std::vector< ScoreRecord > > rtype::read_score_list | ( | std::span< const std::byte > | message | ) |
Reads a ScoreList.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed ScoreList (a count above max_listed_scores included).
|
noexcept |
Reads a SetReady.
| message | Message received, length prefix excluded. |
std::nullopt if the message is not a well-formed SetReady, its ready being 0 or 1. | std::optional< Snapshot > rtype::read_snapshot | ( | std::span< const std::byte > | payload | ) |
Decodes the payload of one Snapshot datagram.
| payload | Bytes after the header. |
std::nullopt if the payload is malformed (a record past the end, bytes or bits other than the padding after the last one, more than 4 players, a varint with another encoding than write_varint()'s, or the low bits of an id beyond id_low_bits).
|
noexcept |
Reads a varint written by write_varint().
A varint has a single encoding: one with a last group of 0 bits (other than a lone first group), more than varint_max_groups groups or a value above 32 bits is rejected.
| reader | Source; it fails on a rejected varint. |
|
noexcept |
Reads a velocity written by write_velocity().
| reader | Source. |
|
noexcept |
Asks the server to stop, as a first Ctrl+C does: stop_requested() becomes true.
Thread-safe; the admin console's stop calls it.
|
noexcept |
How many ticks back a player sees the enemies.
The enemies reach its screen half a round trip after the server moved them, then wait its interpolation delay; its missile reaches the server half a round trip after it fired. So the player aims at the enemies of rtt + interpolation ago, rounded to the tick, and never further back than the history keeps (PositionHistory::capacity): a slower link is not compensated beyond 500 ms.
| rtt | Round trip time to the player, smoothed. |
| interpolation | How far behind the server the player's client draws the world. |
|
noexcept |
Velocity of a player ship holding an input.
Its held directions at tuning::player_speed, diagonals as fast as straight lines (ecs::direction_of()); opposite directions cancel out.
| input | Held actions. |
|
constexprnoexcept |
Tells whether a snapshot is due after a tick.
tuning::snapshot_rate times per second: every third tick at 60 ticks per second.
| tick | Number of ticks run, ServerGame::ticks(). |
true every tuning::tick_rate / tuning::snapshot_rate ticks. | aegis2d::ecs::Entity rtype::spawn_enemy_missile | ( | aegis2d::ecs::Registry & | registry, |
| aegis2d::Vec2 | position | ||
| ) |
Creates a missile fired by an enemy.
It flies left, hits only players, is consumed by its first hit and is destroyed once past the left edge.
| registry | World of the game. |
| position | Center of the missile. |
| aegis2d::ecs::Entity rtype::spawn_player | ( | aegis2d::ecs::Registry & | registry, |
| std::size_t | slot | ||
| ) |
Creates the ship of a player.
The ship is steered by its ecs::PlayerInput, kept in the play area, fires every tuning::player_fire_cooldown seconds while fire is held, has one health point, tuning::player_lives lives respawning at player_spawn(), a Score, a NetworkId, and rams enemies.
| registry | World of the game. |
| slot | Player slot, from 0 to tuning::max_players - 1. |
| std::out_of_range | If slot is not a valid slot. |
| aegis2d::ecs::Entity rtype::spawn_player_missile | ( | aegis2d::ecs::Registry & | registry, |
| aegis2d::ecs::Entity | shooter | ||
| ) |
Creates a missile fired by a player, in front of its ship.
The missile flies right, hits only enemies, is consumed by its first hit, credits its kill to shooter (ecs::Owner) and is destroyed once past the right edge (ecs::OffscreenDespawn).
| registry | World of the game. |
| shooter | Player ship that fires; it must have a Transform. |
| std::out_of_range | If shooter has no Transform. |
| void rtype::steer_ships | ( | aegis2d::ecs::Registry & | registry, |
| const aegis2d::ecs::Tick & | tick | ||
| ) |
System that sets the velocity of every player ship from its input.
ship_velocity() for each entity with shmup::PlayerShip, ecs::PlayerInput and ecs::Velocity; ecs::apply_velocity() then moves it.
| registry | World holding the ships. |
| tick | Unused: the speed is per second. |
|
noexcept |
Moves a player ship by one tick.
The velocity of its input (ship_velocity()), the position moved by it for delta seconds, then kept inside the play area (keep_ship_in_area()): what the server's steering, movement and play_area systems do to the ship, with the same arithmetic, so a client that runs it on its inputs finds the server's positions.
| position | Center of the ship before the tick. |
| input | Actions held during the tick. |
| delta | Duration of the tick in seconds, ecs::Tick::delta(). |
|
noexcept |
Tells whether a stop was asked by a signal. Thread-safe.
true once SIGINT or SIGTERM was received. | Snapshot rtype::take_snapshot | ( | GameInstance & | instance | ) |
Takes the state of the game, on the simulation thread.
Players in their number order; entities with a NetworkId, a Transform and a Collider whose layer gives their kind (entities of another layer are left out).
| instance | Game to read; the scores of players out of lives are the last ones seen. |
|
noexcept |
Short name of a rejection, for logs.
| reason | Reason to name. |
"too long", "bad text", "too fast" or "unknown".
|
noexcept |
Short name of a state, for logs.
| state | State to name. |
"idle", "connecting", "logging in"... or "unknown".
|
noexcept |
Short name of a rejection, for logs.
| reason | Reason to name. |
"no such room", "room full", "in game" or "unknown".
|
noexcept |
Short name of a rejection, for logs.
| reason | Reason to name. |
"server full", "bad version"... or "unknown".
|
noexcept |
Short name of a rejection, for logs.
| reason | Reason to name. |
"no room left", "bad name", "bad size", "bad lives"... or "unknown".
|
noexcept |
Tells whether a name follows the rules of LoginRequest.
1 to max_name_size bytes of valid UTF-8 (no overlong form, surrogate or code point above U+10FFFF), without control characters (below U+0020, and U+007F).
| name | Bytes received. |
true if the name can be given to a player.
|
noexcept |
Tells whether a text is 1 to max_size bytes of valid UTF-8 without control characters, as player names and chat texts must be.
No overlong form, surrogate or code point above U+10FFFF, and no control character (below U+0020, and U+007F).
| text | Bytes received. |
| max_size | Most bytes allowed. |
true if the text follows these rules.
|
noexcept |
Size of a varint.
| value | Value to write. |
value. | std::vector< std::string > rtype::waves_names | ( | const std::filesystem::path & | directory | ) |
The waves files of a directory, as a room names them (RFC section 3.6).
| directory | Directory to look in, such as the parent of default_waves_file(). |
.json files without their extension, sorted; none if the directory cannot be read. | std::vector< std::byte > rtype::write_chat_message | ( | const ChatMessage & | message | ) |
Encodes a ChatMessage.
| message | Sender and text; the strings must fit a string. |
| std::vector< std::byte > rtype::write_chat_rejected | ( | ChatRejection | reason | ) |
Encodes a ChatRejected.
| reason | Why the message was not relayed. |
| std::vector< std::byte > rtype::write_chat_send | ( | std::string_view | text | ) |
Encodes a ChatSend.
| text | Text to send; it must fit a string. |
| std::vector< std::byte > rtype::write_create_room | ( | const CreateRoomRequest & | request | ) |
Encodes a CreateRoom.
| request | Name, number of players and rules; the strings must fit a string. |
| std::vector< std::vector< std::byte > > rtype::write_delta_snapshot | ( | const Snapshot & | snapshot, |
| const Snapshot * | baseline | ||
| ) |
Encodes a snapshot against a baseline, as the payloads of Snapshot datagrams.
Entities whose quantized fields are all the same as in the baseline are skipped; changed ones carry only the fields that changed; new ones carry every field; those of the baseline that are gone are listed as removed. Without a baseline, every entity is added: a full snapshot. Records go by increasing index, as in write_snapshot(), and each payload holds the tick, the baseline, every player record and as many records as fit a datagram.
| snapshot | State to send. |
| baseline | A snapshot the client acknowledged, older than snapshot, or nullptr. |
| std::invalid_argument | if a field does not fit, as write_snapshot(), or if baseline is not older than snapshot. |
| std::vector< std::byte > rtype::write_event | ( | const GameEvent & | event | ) |
Encodes an event as the bytes of RFC section 4.4: type, tick, then its fields.
| event | Event to encode. |
PlayerJoined. | std::vector< std::vector< std::byte > > rtype::write_events | ( | std::span< const GameEvent > | events | ) |
Encodes events with write_event(), for ServerNetwork::send_events().
| events | Events to encode, in order. |
| std::vector< std::byte > rtype::write_game_start | ( | ) |
Encodes a GameStart.
| std::vector< std::byte > rtype::write_inputs | ( | std::span< const InputRecord > | inputs | ) |
Encodes the payload of an Input datagram, header excluded.
The sequence of the newest input (u16), the number of inputs (u8), then the actions of each (u8), newest first; actions outside valid_actions are cleared.
| inputs | 1 to max_inputs_per_datagram inputs of consecutive sequences, oldest first. |
| std::invalid_argument | if inputs is empty, too long, or not consecutive. |
| std::vector< std::byte > rtype::write_join_rejected | ( | JoinRejection | reason | ) |
Encodes a JoinRejected.
| reason | Why the room is not joined. |
| std::vector< std::byte > rtype::write_join_room | ( | std::uint8_t | room | ) |
Encodes a JoinRoom.
| room | Number of the room to join. |
| std::vector< std::byte > rtype::write_leave_room | ( | ) |
Encodes a LeaveRoom.
| std::vector< std::byte > rtype::write_list_rooms | ( | ) |
Encodes a ListRooms.
| std::vector< std::byte > rtype::write_list_scores | ( | ) |
Encodes a ListScores.
| std::vector< std::byte > rtype::write_login_accepted | ( | const LoginAccepted & | accepted | ) |
Encodes a LoginAccepted.
| accepted | Token, player and port. |
| std::vector< std::byte > rtype::write_login_rejected | ( | LoginRejection | reason | ) |
Encodes a LoginRejected.
| reason | Why the login failed. |
| std::vector< std::byte > rtype::write_login_request | ( | const LoginRequest & | request | ) |
Encodes a LoginRequest.
| request | Version and name; the name must fit a string. |
| std::vector< std::byte > rtype::write_logout | ( | LogoutReason | reason | ) |
Encodes a Logout.
| reason | Why the session ends. |
| void rtype::write_position | ( | aegis2d::net::BitWriter & | writer, |
| float | position | ||
| ) |
Writes a position on position_bits bits, see quantize_position().
| writer | Destination. |
| position | Position in logical pixels. |
| std::vector< std::byte > rtype::write_room_created | ( | std::uint8_t | room | ) |
Encodes a RoomCreated.
| room | Number of the room created. |
| std::vector< std::byte > rtype::write_room_joined | ( | std::uint8_t | room, |
| std::uint8_t | player | ||
| ) |
Encodes a RoomJoined.
| room | Number of the room joined. |
| player | Number of the player there. |
| std::vector< std::byte > rtype::write_room_list | ( | std::span< const RoomRecord > | rooms | ) |
Encodes a RoomList.
| rooms | The rooms, at most max_listed_rooms, their names fitting a string. |
| std::invalid_argument | If there are more than max_listed_rooms rooms. |
| std::vector< std::byte > rtype::write_room_players | ( | const RoomPlayers & | players | ) |
Encodes a RoomPlayers.
| players | The room and its players, at most 4, their names fitting a string. |
| std::invalid_argument | If there are more than 4 players. |
| std::vector< std::byte > rtype::write_room_rejected | ( | RoomRejection | reason | ) |
Encodes a RoomRejected.
| reason | Why the room is not created. |
| std::vector< std::byte > rtype::write_score_list | ( | std::span< const ScoreRecord > | scores | ) |
Encodes a ScoreList.
| scores | Best first; only the first max_listed_scores are written, and the names must fit a string. |
| std::vector< std::byte > rtype::write_set_ready | ( | bool | ready | ) |
Encodes a SetReady.
| ready | Whether the player is ready to start. |
| std::vector< std::vector< std::byte > > rtype::write_snapshot | ( | const Snapshot & | snapshot | ) |
Encodes a snapshot as the payloads of Snapshot datagrams, header excluded.
Fields are packed bit by bit (RFC section 4.3): positions to the 1/8 px and velocities to the pixel per second, see compact.hpp, and the entities in increasing order of the low bits of their id (then of the id), each id written as the gap of its low bits to the previous record's and its high bits. Each payload holds the tick, every player record and as many entity records as fit a datagram; a snapshot with no entity still gives one payload.
| snapshot | State to send: at most 7 player records, player numbers below 4 and entity kinds below 8. |
| std::invalid_argument | if a player count, player number or entity kind does not fit its field. |
| 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.
An id below 128 takes 8 bits, below 16384 16 bits, and 40 bits at most.
| writer | Destination. |
| value | Value to write. |
| void rtype::write_velocity | ( | aegis2d::net::BitWriter & | writer, |
| float | velocity | ||
| ) |
Writes a velocity on velocity_bits bits, see quantize_velocity().
| writer | Destination. |
| velocity | Velocity in logical pixels per second. |
|
inlineconstexpr |
First line of a --stats file: the names of the columns of bot_stats_line().
|
inlineconstexpr |
Usage line printed by --help and after a command line error.
|
inlineconstexpr |
Bits of the change of a delta record.
|
inlineconstexpr |
Usage line printed by --help and after a command line error.
|
inlineconstexpr |
Number of fields of ConnectField.
|
inlineconstexpr |
Size of a Death event, type and tick included.
|
inlineconstexpr |
File of the banned addresses, in the folder the server runs from.
|
inlineconstexpr |
Rooms played at once when --max-rooms is not given; see GameServer.
|
inlineconstexpr |
Datagrams accepted per second from one address when --max-packet-rate is not given; see RateLimits.
|
inlineconstexpr |
File of the best scores, in the folder the server runs from.
|
inlineconstexpr |
TCP port the server listens on when --tcp-port is not given.
|
inlineconstexpr |
UDP port the server listens on when --udp-port is not given.
|
inlineconstexpr |
Size of a Destroy event, type and tick included.
|
inlineconstexpr |
Bits of the fields of an EntityChange::Updated record.
|
inlineconstexpr |
Bits of an entity record besides the gap of its id's low bits: the id's high bits, kind, position, velocity and frame (69).
|
inlineconstexpr |
Exit status of a server stopped by a second signal, before its clean stop ended.
|
inlineconstexpr |
Bits of the frame of an entity record: frames above 15 are sent as 15.
|
inlineconstexpr |
High bits of a network id, sent as they are: the generation of Entity handles.
|
inlineconstexpr |
Low bits of a network id, sent as their gap to those of the previous record: the index of the engine's Entity handles, small and dense among live entities.
|
inlineconstexpr |
Bits of the kind of an entity record: kinds 0 to 7.
|
inlineconstexpr |
Number of graphs: LagGraph values are 0 to lag_graph_count - 1.
|
inlineconstexpr |
player of a ChatMessage whose sender is in the lobby, with no player number.
|
inlineconstexpr |
Most bots --count runs in one process.
|
inlineconstexpr |
Longest chat text, in bytes of UTF-8.
|
inlineconstexpr |
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.
|
inlineconstexpr |
Most rooms a server may have, and a RoomList may hold.
|
inlineconstexpr |
Most scores in a ScoreList.
|
inlineconstexpr |
Longest player name, in bytes of UTF-8.
|
inlineconstexpr |
Most lives a room may give its players.
|
inlineconstexpr |
Network id that names no entity, for a player out of lives.
|
inlineconstexpr |
Player number meaning "no player", as the owner of an enemy.
|
inlineconstexpr |
Room of a session in the lobby, out of every room (LeaveRoom, RFC section 3.7).
|
inlineconstexpr |
Size of a PlayerLeft event, type and tick included.
|
inlineconstexpr |
Bits of a position, sign included.
|
inlineconstexpr |
Largest position sent, in logical pixels: 2047.875.
|
inlineconstexpr |
Largest error of a position within [position_min, position_max]: 1/16 px.
|
inlineconstexpr |
Smallest position sent, in logical pixels: -2048.
The play area (0 to tuning::area_width, 0 to tuning::area_height) and the entities just beyond its edges lie well within [position_min, position_max].
|
inlineconstexpr |
Steps of a position per logical pixel: positions are sent to the 1/8 px.
|
inlineconstexpr |
Protocol version the server speaks, in LoginRequest and in the UDP header.
|
inlineconstexpr |
name of a ChatMessage of the server itself.
|
inlineconstexpr |
player of a ChatMessage of the server itself, such as its administrator's say: no player has it (RFC section 3.8).
|
inlineconstexpr |
Usage line printed by --help and after a command line error.
|
inlineconstexpr |
Largest gap between the low bits of two records' ids that keeps a record within 10 bytes (77 bits).
|
inlineconstexpr |
Bits of the tick, the player count and the entity count of a snapshot payload.
|
inlineconstexpr |
Size of a Spawn event, type and tick included.
|
inlineconstexpr |
Bits of the actions of an Input: up, down, left, right and fire; bits 5 to 7 must be clear.
|
inlineconstexpr |
Bits of each group of a varint, followed by one continuation bit.
|
inlineconstexpr |
Most groups of a varint: 5, for 32 bits.
|
inlineconstexpr |
Bits of a velocity, sign included; velocities are sent in whole pixels per second.
|
inlineconstexpr |
Largest velocity sent, in logical pixels per second: 2047.
|
inlineconstexpr |
Largest error of a velocity within [velocity_min, velocity_max]: 0.5 px/s.
|
inlineconstexpr |
Smallest velocity sent, in logical pixels per second: -2048.