mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-23 07:45:53 +02:00
- Read Dev / Creator / Homie Steam IDs from api.reskate.dev instead of the hardcoded list
- Creator (red) and Homie (gold) tags and hoodie/board colours; Admin tag is now pink
- Global bans: lobby hosts and dedicated servers turn banned players away
("global_bans": false in ReSkateServer.json opts a server out)
- SPECIAL menu page for listed players to hide their own tag and items
- Fix hoodie and board keeping the animated colour after the animation turns off
- Multiplayer protocol 39 -> 40
56 lines
3.3 KiB
C++
56 lines
3.3 KiB
C++
#pragma once
|
|
#include <array>
|
|
#include <atomic>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
namespace dingosdk::multiplayer {
|
|
// Who the ReSkate backend lists in each of its Steam ID categories, and who it
|
|
// has banned. The lists are kept in its admin panel and read from
|
|
// api.reskate.dev, so they change without a release. Steam authenticates these
|
|
// identities. Each category has its tag in chat and on nametags (player_role)
|
|
// and its animation on the marked hoodie and board (developer_hoodie_material.h).
|
|
enum class IdentityList : std::uint8_t { developer, homie, content_creator, banned, count };
|
|
using IdentityLists = std::array<std::vector<std::uint64_t>, static_cast<std::size_t>(IdentityList::count)>;
|
|
inline constexpr std::string_view identity_lists_url = "https://api.reskate.dev/api/v1/steam-ids";
|
|
|
|
// The game's way of reading them (the dedicated server's is Server/global_bans.h). Called
|
|
// every client tick: reads the lists in the background, at startup and every ten
|
|
// minutes after (a minute after a failure). Offline mode reads them too, for the
|
|
// player's own hoodie and board.
|
|
void refresh_identity_lists() noexcept;
|
|
// Any thread. Nobody is listed until the first answer has arrived.
|
|
bool identity_listed(std::uint64_t id, IdentityList list) noexcept;
|
|
// Shared by the developer tag and the rainbow hoodie and board.
|
|
inline bool reskate_developer(std::uint64_t id) noexcept { return identity_listed(id, IdentityList::developer); }
|
|
// The category a player's tag and items come from: a developer's before a content creator's
|
|
// before a homie's. Most players are in none.
|
|
inline std::optional<IdentityList> identity_mark(std::uint64_t id) noexcept {
|
|
for (const auto list : {IdentityList::developer, IdentityList::content_creator, IdentityList::homie})
|
|
if (identity_listed(id, list)) return list;
|
|
return std::nullopt;
|
|
}
|
|
// The local player's own choice to go without their marks (the menu's Special page, which
|
|
// only a listed player gets). Their appearance tells everyone else (Appearance::unmarked).
|
|
inline std::atomic<bool> own_marks{true};
|
|
inline bool own_marks_shown() noexcept { return own_marks.load(std::memory_order_relaxed); }
|
|
inline void show_own_marks(bool shown) noexcept { own_marks.store(shown, std::memory_order_relaxed); }
|
|
// A global ban is enforced by whoever a player would play with: a host and a dedicated server
|
|
// turn them away, and a guest leaves a lobby they host, which their own game does not start
|
|
// either (session_receive.cpp, Server/server_host.cpp). A server can opt out ("global_bans"),
|
|
// so a banned player's own game still lets them try to join. Nobody is banned while the lists
|
|
// cannot be read.
|
|
inline bool reskate_banned(std::uint64_t id) noexcept { return identity_listed(id, IdentityList::banned); }
|
|
inline constexpr std::string_view banned_notice = "You are banned from ReSkate multiplayer.";
|
|
|
|
// The API's answer, {"categories":{"dev":["7656119..."],"homie":[],...},"banned":[]},
|
|
// as sorted lists. A category this build does not know is ignored and a list the
|
|
// answer leaves out is empty; an entry that is not a player's SteamID64 throws.
|
|
IdentityLists parse_identity_lists(std::string_view json);
|
|
// Puts sorted lists in use. False when they are the ones already in use.
|
|
bool publish_identity_lists(IdentityLists lists);
|
|
} // namespace dingosdk::multiplayer
|