mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-23 18:45:57 +02:00
- Split the single switch into "Show my tag" and "Show my items", and show the tag as chat and nametags draw it. - Color whatever is equipped instead of the one hoodie and pink board: top, bottoms, shoes, socks, hat, glasses, outfit, costume, deck, grip tape, trucks and wheels, each set on its own. - Each item can use its list's animation (rainbow, red or gold), a gradient between two picked colors, one solid color, or be off. - The choices travel with the player's appearance so everyone sees them. Protocol version 41.
59 lines
3.6 KiB
C++
59 lines
3.6 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 choices to go without their tag, and without their animated items
|
|
// (the menu's Special page, which only a listed player gets). Their appearance tells everyone
|
|
// else (Appearance::hide_tag, Appearance::hide_items).
|
|
inline std::atomic<bool> own_tag{true}, own_items{true};
|
|
inline bool own_tag_shown() noexcept { return own_tag.load(std::memory_order_relaxed); }
|
|
inline void show_own_tag(bool shown) noexcept { own_tag.store(shown, std::memory_order_relaxed); }
|
|
inline bool own_items_shown() noexcept { return own_items.load(std::memory_order_relaxed); }
|
|
inline void show_own_items(bool shown) noexcept { own_items.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
|