Files
ReSkate/Extension/Multiplayer/developer_identity_fetch.cpp
T
AyeZeeBB 101e1af6e4 Official, staff and friends in the server browser; server tokens; Linux self-update
Server browser
- Official servers (the backend's "official_servers") sort first and are
  drawn in ReSkate blue
- Servers Steam friends are skating in sort next, drawn in green with the
  friends' names; searching a friend's name finds their server
- A player in a session they joined can join another server straight from
  the list; hosts still end their session first, and a Steam friend's join
  offer never replaces a session
- Joining a dedicated server from the list records it as the player's
  public session, so friends see it and the row shows HERE
- Blocked servers (the backend's "blocked_servers") are hidden and cannot
  be joined, by code either
- When the backend sets "server_tokens_required", dedicated servers that
  signed in without a login token are hidden, except on the player's own
  network
- A search that gets no internet list from Steam keeps the last list for
  two minutes, and waits six seconds before treating it as empty
Roles
- New Staff tag from the backend's "staff" list: green name, badge and
  item animation, ranked after Dev
- Staff can pick a rainbow for their items on the Special page; it is sent
  as a solid colour older builds can show, so the protocol is unchanged
Dedicated server
- steam_token: sign in with a Steam game server login token and keep the
  same Steam ID every start; empty signs in anonymously as before
- A listed server without a token says so at startup, and when the token
  rule starts or stops hiding it
- Linux servers update themselves from the release's "server_linux"
  tarball, with the machine's curl and tar, pinned by SHA-256, and carry
  on in the same process
Launcher
- Only create the MiniDumpWriteDump API-set shim under Wine/Proton
2026-10-07 00:19:56 -05:00

61 lines
2.6 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);
server_tokens_rule = parse_server_tokens_required(*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