R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
scores.hpp
Go to the documentation of this file.
1
3#pragma once
4#include <cstddef>
5#include <cstdint>
6#include <optional>
7#include <span>
8#include <string>
9#include <vector>
10
11namespace rtype {
12
14inline constexpr std::size_t max_listed_scores = 10;
15
19 std::string name;
21 std::uint32_t score = 0;
22
25 bool operator==(const ScoreRecord&) const = default;
26};
27
31[[nodiscard]] bool read_list_scores(std::span<const std::byte> message) noexcept;
32
37[[nodiscard]] std::optional<std::vector<ScoreRecord>>
38read_score_list(std::span<const std::byte> message);
39
42[[nodiscard]] std::vector<std::byte> write_list_scores();
43
48[[nodiscard]] std::vector<std::byte> write_score_list(std::span<const ScoreRecord> scores);
49
50} // namespace rtype
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
constexpr std::size_t max_listed_scores
Most scores in a ScoreList.
Definition scores.hpp:14
std::optional< std::vector< ScoreRecord > > read_score_list(std::span< const std::byte > message)
Reads a ScoreList.
std::vector< std::byte > write_score_list(std::span< const ScoreRecord > scores)
Encodes a ScoreList.
std::vector< std::byte > write_list_scores()
Encodes a ListScores.
bool read_list_scores(std::span< const std::byte > message) noexcept
Tells whether a message is a well-formed ListScores.
One score of a ScoreList.
Definition scores.hpp:17
std::uint32_t score
Its points at the end of its game.
Definition scores.hpp:21
std::string name
Name of the player, as received: see valid_player_name().
Definition scores.hpp:19
bool operator==(const ScoreRecord &) const =default
Field-by-field equality.