Files
ReSkate/Extension/Multiplayer/developer_identity_fetch.cpp
T
AyeZeeBB c930b512e6 Backend lists for tags, cosmetics and bans
- 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
2026-10-04 22:33:57 -05:00

60 lines
2.5 KiB
C++

#include "developer_identity.h"
#include "Engine/Core/Log/logging.h"
#include "Engine/Vfs/https_download.h"
#include <Windows.h>
#include <atomic>
#include <string>
#include <thread>
// The game's way of reading the lists: in the background, driven by the client tick.
namespace dingosdk::multiplayer {
namespace {
constexpr std::uint64_t max_bytes = 256 * 1024, refresh_ms = 10 * 60 * 1000, retry_ms = 60 * 1000;
std::atomic<bool> fetching{};
std::atomic<std::uint64_t> next_fetch{}; // GetTickCount64 time
void fetch() noexcept {
// The log says when the lists arrive, change or stop arriving, not every refresh.
static bool failing{};
bool ok{};
try {
https::Download download;
const auto answer = https::get_text(std::wstring(identity_lists_url.begin(), identity_lists_url.end()), max_bytes, 10,
L"ReSkate-Identity/1", &download);
if (answer) {
auto lists = parse_identity_lists(*answer);
const auto developers = lists[0].size(), homies = lists[1].size(), creators = lists[2].size(),
bans = lists[static_cast<std::size_t>(IdentityList::banned)].size();
if (publish_identity_lists(std::move(lists)) || failing)
logging::log(logging::Level::info, logging::Channel::runtime,
"Identity lists: {} developer(s), {} homie(s), {} content creator(s), {} banned.", developers,
homies, creators, bans);
ok = true;
} else if (!failing) {
logging::log(logging::Level::info, logging::Channel::runtime,
"Identity lists unavailable (HTTP {}, error {}); trying again every minute.", download.http_status,
download.error);
}
} catch (const std::exception &e) {
if (!failing)
logging::log(logging::Level::warning, logging::Channel::runtime,
"Identity lists are invalid ({}); trying again every minute.", e.what());
} catch (...) {}
failing = !ok;
// A failure keeps the lists already in use.
next_fetch = GetTickCount64() + (ok ? refresh_ms : retry_ms);
fetching = false;
}
} // namespace
void refresh_identity_lists() noexcept {
if (GetTickCount64() < next_fetch || fetching.exchange(true)) return;
try {
std::thread(fetch).detach();
} catch (...) {
next_fetch = GetTickCount64() + retry_ms;
fetching = false;
}
}
} // namespace dingosdk::multiplayer