mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 15:09:58 -04:00
Bring public main's Steam co-op, the removal of the old co-op and the launcher's Steam library file into the 0.10.0 line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "cheats.h"
|
||||
#include "coop.h"
|
||||
#include "cheats.h"
|
||||
#include "fs.h"
|
||||
#include "kernel.h"
|
||||
#include "ipc.h"
|
||||
@@ -325,7 +325,7 @@ void rt_frame_presented(const tex_t *t, uint64_t n) {
|
||||
stats_line();
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
coop_shutdown(); // LEAVE and BYE to the room, before the process ends
|
||||
coop_shutdown(); // leaves the room, before the process ends
|
||||
input_rumble_hd_stop(); // a controller on HD rumble gets the neutral value before the exit
|
||||
fs_save_flush();
|
||||
vk_pipeline_prewarm_marker_clear(); // an orderly end, not a driver crash in the boot's builds (vk_pipeline.c pm_skipped)
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#include "cfg.h"
|
||||
#include "cfg_private.h"
|
||||
#include "coop_app.h"
|
||||
#include "discord_app.h"
|
||||
#include "host.h"
|
||||
#include "platform/platform.h"
|
||||
@@ -84,12 +83,12 @@ static const char *const known[] = {
|
||||
"VMA_BLOCK_MB", "SYNC_WAKE_ALL", "LOG_ASYNC", "DEVICE_LOST_AT", "STAGING_FAIL_AT", "VRAM_BALLAST_MB",
|
||||
"TEX_COMPACT", "TEX_COMPACT_MIN_MB", "TEX_COMPACT_FRAME_MB", // texture compaction (vk_texture.c); no menu row
|
||||
"STANDIN_FILTER", // the filter of the scene upscaler's stand-in (vk_tonemap.c); no menu row
|
||||
"COOP", "COOP_BETA", "COOP_NAME", "COOP_SERVER", "COOP_PORT", "COOP_ROOM", "COOP_AUTO", "COOP_DROP", // co-op (coop.c); the last three have no menu row
|
||||
"COOP_PROGRESS", "COOP_ITEMS", "COOP_SONGS", "COOP_QUEST", "COOP_KEYS", "COOP_RUPEES", "COOP_AMMO", // the room's rules (coop_game.c)
|
||||
"COOP_TEST_SET", // test: sets flags by hash at given frames (coop_game.c); no menu row
|
||||
"COOP_ACCEPT", // accepts a co-op room's members and rules before anything of it is applied (coop_game.c)
|
||||
"COOP_REMOVE", // the room's maker removes a member: its id (coop.c), or a key's fingerprint (coop_game.c); no row (the Co-op tab's Remove)
|
||||
"COOP_RESET_POOLS", // the room's maker resets the pools when it changes to a value other than 0 (coop_game.c); no row (the tab's Reset the pools)
|
||||
"COOP", "COOP_SHARE", "COOP_NAMES", "COOP_CHAT", // co-op (coop.c, coop_game.c, ui/coop_page.cpp)
|
||||
// retired: the settings of the co-op of versions up to 0.9.2; read by nothing, listed so that a file which still
|
||||
// sets them logs no unknown key
|
||||
"COOP_BETA", "COOP_NAME", "COOP_SERVER", "COOP_PORT", "COOP_ROOM", "COOP_AUTO", "COOP_DROP",
|
||||
"COOP_PROGRESS", "COOP_ITEMS", "COOP_SONGS", "COOP_QUEST", "COOP_KEYS", "COOP_RUPEES", "COOP_AMMO",
|
||||
"COOP_TEST_SET", "COOP_ACCEPT", "COOP_REMOVE", "COOP_RESET_POOLS",
|
||||
};
|
||||
|
||||
// The nx2navi.ini section a key cfg_set may write goes to when the file lacks it (nx2navi.ini.example's sections).
|
||||
@@ -118,9 +117,7 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"LOW_LATENCY", "display"},
|
||||
{"DEVICE_PROFILE", "display"}, {"ASSUME_FOCUS", "display"},
|
||||
{"DISCORD_RPC", "discord"}, {"DISCORD_APP_ID", "discord"}, {"DISCORD_IMAGE", "discord"},
|
||||
{"COOP", "coop"}, {"COOP_BETA", "coop"}, {"COOP_NAME", "coop"}, {"COOP_SERVER", "coop"}, {"COOP_PORT", "coop"},
|
||||
{"COOP_PROGRESS", "coop"}, {"COOP_ITEMS", "coop"}, {"COOP_SONGS", "coop"}, {"COOP_QUEST", "coop"}, {"COOP_KEYS", "coop"},
|
||||
{"COOP_RUPEES", "coop"}, {"COOP_AMMO", "coop"}, {"COOP_ACCEPT", "coop"},
|
||||
{"COOP", "coop"}, {"COOP_SHARE", "coop"}, {"COOP_NAMES", "coop"}, {"COOP_CHAT", "coop"},
|
||||
{"SHADOW_SCALE", "display"}, {"SHADOW_RANGE", "display"}, {"CONTACT_SHADOWS", "display"},
|
||||
{"PCSS", "display"},
|
||||
{"MODS_DIR", "mods"}, {"MODS_ORDER", "mods"}, {"MODS_DISABLED", "mods"}, {"MODS_REBUILD", "mods"},
|
||||
@@ -280,18 +277,11 @@ static const CfgMeta metas[] = {
|
||||
{"DISCORD_RPC", "1", "0|1", LIVE},
|
||||
{"DISCORD_APP_ID", NX2NAVI_DISCORD_APP_ID_DEFAULT, NULL, LIVE},
|
||||
{"DISCORD_IMAGE", NX2NAVI_DISCORD_IMAGE_DEFAULT, NULL, LIVE},
|
||||
// Co-op (coop.c): off until the player turns it on. The server is host[:port] of a relay (tools/coop_relay.py), and has no
|
||||
// default until coop_app.h names one; the name is at most 24 bytes, empty for Player-xxxx; the port is the local UDP port
|
||||
// (0: any). COOP_ROOM, COOP_AUTO, COOP_DROP and COOP_TEST_SET are read with cfg_get, no row.
|
||||
{"COOP", "0", "0|1", LIVE}, {"COOP_BETA", "0", "0|1", LIVE}, {"COOP_NAME", "", NULL, LIVE},
|
||||
{"COOP_SERVER", NX2NAVI_COOP_SERVER_DEFAULT, NULL, LIVE}, {"COOP_PORT", "0", "0..65535", RESTART},
|
||||
// The rules a room made by this player syncs by (coop_state.h, docs/coop.md); a joiner's own are not used in the room.
|
||||
{"COOP_PROGRESS", "shared", "shared|own", LIVE}, {"COOP_ITEMS", "shared", "shared|own", LIVE},
|
||||
{"COOP_SONGS", "shared", "shared|own", LIVE}, {"COOP_QUEST", "shared", "shared|own", LIVE},
|
||||
{"COOP_KEYS", "pool", "pool|own", LIVE}, {"COOP_RUPEES", "own", "own|pool", LIVE}, {"COOP_AMMO", "own", "own|pool", LIVE},
|
||||
// Nothing from a room is applied before its members and rules are accepted (coop_game.c): ask (the log names the
|
||||
// offer's number, which this setting or the menu accepts), always (every room, the save still copied first), or a number.
|
||||
{"COOP_ACCEPT", "ask", NULL, LIVE},
|
||||
// Co-op (coop.c): off until the player turns it on; then the game signs in to Steam as its test app and can make
|
||||
// or join a room. In a room: COOP_SHARE shares progress, items and songs with the other players (coop_game.c),
|
||||
// COOP_NAMES shows the other players' names where they stand, COOP_CHAT shows the chat's lines over the game.
|
||||
{"COOP", "0", "0|1", LIVE}, {"COOP_SHARE", "1", "0|1", LIVE}, {"COOP_NAMES", "1", "0|1", LIVE},
|
||||
{"COOP_CHAT", "1", "0|1", LIVE},
|
||||
// Advanced: scheduling
|
||||
{"ASYNC_PREEMPT", "1", "0|1|2", RESTART}, {"REPLAY_ASYNC", "0", "0|1", RESTART},
|
||||
{"REPLAY_PIPE", "0", "0..4", RESTART},
|
||||
@@ -1196,7 +1186,7 @@ static void log_file_settings(void) {
|
||||
char key[64];
|
||||
snprintf(key, sizeof key, "%s", entries[i].key);
|
||||
for (char *p = key; *p; p++) *p = (char)tolower((unsigned char)*p);
|
||||
// a co-op room's secret, the relay, the player's name: only that they are set (cfg_private.h)
|
||||
// a private setting (cfg_private.h): only that it is set
|
||||
const char *value = cfg_private_key(entries[i].key) && entries[i].value[0] ? CFG_PRIVATE_SHOWN : entries[i].value;
|
||||
size_t vl = strlen(value);
|
||||
if (vl > 200) vl = 200; // a long value (a list of mods) is cut: the line shows that the key is set
|
||||
@@ -1228,43 +1218,6 @@ static void load_ini(void) {
|
||||
}
|
||||
}
|
||||
|
||||
int cfg_ini_read(const char *path, const char *key, char *out, size_t cap) {
|
||||
if (cap) out[0] = 0;
|
||||
uint64_t size = 0;
|
||||
uint8_t *data = plat_file_read(path, &size);
|
||||
if (!data || !size) { // gone or empty for a moment (an editor saving it), or locked: no reading, not "no value"
|
||||
free(data);
|
||||
return -1;
|
||||
}
|
||||
int found = 0;
|
||||
char *p = (char *)data;
|
||||
if (size >= 3 && !memcmp(p, "\xEF\xBB\xBF", 3)) p += 3; // as cfg_load: editors add a BOM
|
||||
for (;;) {
|
||||
char *eol = strchr(p, '\n');
|
||||
if (eol) *eol = 0;
|
||||
char *s = trim(p), *eq = strchr(s, '=');
|
||||
if (*s && *s != '#' && *s != ';' && *s != '[' && eq) {
|
||||
*eq = 0;
|
||||
const char *k = trim(s);
|
||||
size_t i = 0;
|
||||
while (k[i] && key[i] && tolower((unsigned char)k[i]) == tolower((unsigned char)key[i])) i++;
|
||||
if (!k[i] && !key[i]) { // as cfg_load: a repeated key's later line wins, quotes go, "key =" sets nothing
|
||||
char *v = trim(eq + 1);
|
||||
size_t vl = strlen(v);
|
||||
if (vl >= 2 && v[0] == '"' && v[vl - 1] == '"') v[vl - 1] = 0, v++;
|
||||
snprintf(out, cap, "%s", v);
|
||||
found = *v != 0;
|
||||
}
|
||||
}
|
||||
if (!eol) break;
|
||||
p = eol + 1;
|
||||
}
|
||||
free(data);
|
||||
return found;
|
||||
}
|
||||
|
||||
int cfg_ini_now(const char *key, char *out, size_t cap) { return find_ini() ? cfg_ini_read(ini_path, key, out, cap) : 0; }
|
||||
|
||||
void cfg_init(void) {
|
||||
load_ini();
|
||||
__atomic_store_n(&lowend, -1, __ATOMIC_RELEASE); // asked before the file was read: decided again (lowend_of)
|
||||
|
||||
@@ -24,13 +24,6 @@ unsigned cfg_version(void);
|
||||
int cfg_setenv(const char *name, const char *value);
|
||||
// 1 when the environment sets name: cfg_set cannot change what cfg_get returns (the menu greys the setting out).
|
||||
int cfg_from_env(const char *name);
|
||||
// The value of key, as nx2navi.ini spells it ("coop_accept"), in nx2navi.ini as the file is now: the file is read again,
|
||||
// for the few settings that act while the game runs without the menu (co-op's acceptance and the room maker's
|
||||
// remedies; everything else is read at start). Read as at start: a BOM is skipped, a repeated key's later line wins,
|
||||
// quotes go and "key =" sets nothing. 1 and the value in out when the file sets it, 0 when it does not, -1 when the
|
||||
// file cannot be read now or is empty (an editor saving it, a lock): the caller skips that reading.
|
||||
int cfg_ini_now(const char *key, char *out, size_t cap);
|
||||
int cfg_ini_read(const char *path, const char *key, char *out, size_t cap); // the same, of the file at path
|
||||
// 1 when the player set name (the environment or nx2navi.ini), 0 when cfg_get gives a device profile's default or NULL.
|
||||
int cfg_is_set(const char *name);
|
||||
int cfg_low_end_active(void); // the low-end GPU mode was on when the game started (cfg.c LOWEND)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Settings whose values stay on the player's PC: a co-op room's secret and the offer number made for it, the relay's
|
||||
// address, the player's name, the key a maker removes, and the menu's test hook (which can carry a secret). The log's
|
||||
// Settings whose values stay on the player's PC: the menu's test hook, and what the co-op of versions up to 0.9.2 kept
|
||||
// in nx2navi.ini, which a player's file may still hold (a room's secret and the offer number made for it, the relay's
|
||||
// address, the player's name, the key a maker removed). The log's
|
||||
// line of what nx2navi.ini sets (cfg.c log_file_settings), "Copy system info" (sysinfo.c) and the copy of nx2navi.ini a
|
||||
// bug report takes along (save_share.c; launcher/saves.py has the same list) show only that such a key is set.
|
||||
// Header only, so that the tests that build one of those files alone need nothing else.
|
||||
|
||||
1878
runtime/coop.c
1878
runtime/coop.c
File diff suppressed because it is too large
Load Diff
227
runtime/coop.h
227
runtime/coop.h
@@ -1,143 +1,124 @@
|
||||
// Co-op session layer: one host thread, "coop", owns a UDP socket to a relay (tools/coop_relay.py), keeps the player in a
|
||||
// room of up to 8 and carries the messages the players send each other (coop_proto.h: the wire format). It never holds a
|
||||
// virtual core and never touches game state: progress sync is a layer above this one, which send
|
||||
// with coop_send and receive with coop_on_message. The game's own nn::socket stays offline.
|
||||
// Co-op (coop.c): each player runs their own game; a room connects up to four of them through Steam (steam.h). The
|
||||
// room is a Steam lobby, its maker's game is the host, and the games send each other where their Link is, chat lines
|
||||
// and what the game layer shares (coop_game.c). docs/coop.md is the players' and the reviewers' description.
|
||||
//
|
||||
// Threads. Everything below the "process" heading may be called from any thread; the callbacks run on the coop thread
|
||||
// (keep them short, they hold up the socket) and must not call coop_command. coop_send copies the message into an outbox the
|
||||
// coop thread flushes within about 8 ms; coop_view_get and coop_command take a lock the coop thread holds only to copy.
|
||||
//
|
||||
// The session is off until the COOP setting (nx2navi.ini [coop], the menu) is on; docs/coop.md has the settings.
|
||||
// One host thread (the co-op thread) owns Steam and the room. The menu and the game's thread never wait for it: they
|
||||
// read the view it publishes at each step and hand it commands it carries out at its next one.
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "coop_proto.h"
|
||||
#include "steam.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
COOP_PROTOCOL = 1, // games of another number do not play together
|
||||
COOP_PLAYERS = 4,
|
||||
COOP_NAME_CAP = STEAM_NAME_CAP,
|
||||
COOP_SCENE_CAP = 48,
|
||||
COOP_CHAT_CAP = 200, // bytes of a chat line, UTF-8
|
||||
COOP_CHAT_LINES = 8,
|
||||
COOP_FRIENDS = 64,
|
||||
COOP_GAME_KIND = 16, // message kinds from here on belong to the game layer (coop_game.c)
|
||||
COOP_MESSAGE_MAX = STEAM_MESSAGE_MAX - 1, // bytes of a message after its kind
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
COOP_OFF, // the COOP setting is off: no socket, no thread work
|
||||
COOP_LEFT, // on, in no room (the status says why after a failure)
|
||||
COOP_CONNECTING, // reaching the relay to create or join a room
|
||||
COOP_JOINED, // in a room
|
||||
COOP_RECONNECTING, // the relay went silent; joining the same room again as the same member
|
||||
COOP_OFF, // the setting is off: no thread work, Steam untouched
|
||||
COOP_NO_STEAM, // on, but Steam is not there (note says why); tried again every few seconds and at coop_retry
|
||||
COOP_READY, // Steam is up, in no room
|
||||
COOP_ENTERING, // making or joining a room, or waiting for its host to answer
|
||||
COOP_IN_ROOM,
|
||||
} CoopState;
|
||||
|
||||
typedef enum { COOP_CMD_CREATE = 1, COOP_CMD_JOIN, COOP_CMD_LEAVE } CoopCmd;
|
||||
// Why the last attempt ended, for the menu's status line (ui/coop_page.cpp has the texts).
|
||||
typedef enum {
|
||||
COOP_NOTE_NONE,
|
||||
COOP_NOTE_NO_LIBRARY, COOP_NOTE_OLD_LIBRARY, COOP_NOTE_NO_CLIENT, COOP_NOTE_OTHER_OS,
|
||||
COOP_NOTE_CREATE_FAILED, COOP_NOTE_NO_ROOM, COOP_NOTE_FULL, COOP_NOTE_REFUSED, COOP_NOTE_NOT_OURS,
|
||||
COOP_NOTE_OTHER_VERSION, COOP_NOTE_REMOVED, COOP_NOTE_HOST_SILENT, COOP_NOTE_LOST, COOP_NOTE_BAD_CODE,
|
||||
COOP_NOTE_LEFT,
|
||||
} CoopNote;
|
||||
|
||||
// Where a player's Link is, as their game last said.
|
||||
enum { COOP_POSE_ADULT = 1, COOP_POSE_PAUSED = 2 };
|
||||
typedef struct {
|
||||
float pos[3]; // metres, the game's world
|
||||
float vel[3]; // metres a second
|
||||
float yaw; // radians about the up axis, the way Link faces
|
||||
uint8_t flags; // COOP_POSE_*
|
||||
char scene[COOP_SCENE_CAP]; // the area's name as the game has it; "": not in the world (title screen, loading)
|
||||
} CoopPose;
|
||||
|
||||
typedef struct {
|
||||
uint8_t id; // member id 1..8
|
||||
uint8_t away; // the relay has not heard from the member for a while
|
||||
uint8_t maker; // made the room (the relay says so); the rules are the ones its key signs (coop_state.h)
|
||||
char name[COOP_NAME_MAX + 1];
|
||||
uint64_t session; // its session in the room, as the relay lists it (progress sync binds its identity to it)
|
||||
uint32_t heard_ms; // milliseconds since the last message of this member that opened with the room's key;
|
||||
// UINT32_MAX never (a member the relay lists but that has not shown it knows the secret)
|
||||
} CoopPeer;
|
||||
uint64_t id;
|
||||
char name[COOP_NAME_CAP];
|
||||
uint8_t self, host;
|
||||
uint8_t has_pose;
|
||||
uint32_t pose_ms; // how long ago the pose arrived
|
||||
CoopPose pose;
|
||||
} CoopPlayer;
|
||||
|
||||
typedef struct {
|
||||
char name[COOP_NAME_CAP];
|
||||
char text[COOP_CHAT_CAP + 1];
|
||||
uint64_t at_ms; // plat_now_ms when it arrived
|
||||
uint8_t notice; // a line of the room itself ("... joined"): name holds the player, text is empty
|
||||
uint8_t joined; // for a notice: 1 joined, 0 left
|
||||
} CoopChatLine;
|
||||
|
||||
typedef struct {
|
||||
CoopState state;
|
||||
unsigned version; // changes with the state, the room, the roster and the status text
|
||||
char code[COOP_SECRET_TEXT + 1]; // the room's secret, XXXXXX-XXXXXX-XXXXXX, in a room or while joining one; else ""
|
||||
char label[8]; // its first characters, for logs ("XXX…")
|
||||
int self; // this player's member id; 0 outside a room
|
||||
int maker; // the member id of the room's maker, 0 when the maker is not in the room
|
||||
int made; // this player's session made the room (its own CREATE, not the relay's mark: its
|
||||
// settings are the room's rules, coop_state.h)
|
||||
uint64_t session; // this player's session in the room, the one it joined with (0 outside a room); a roster
|
||||
// may list another for it, which progress sync does not sign for
|
||||
char name[COOP_NAME_MAX + 1]; // this player's own name (COOP_NAME, cleaned), whatever the relay's roster says
|
||||
int n; // members of the room, this player included, by id
|
||||
CoopPeer member[COOP_MAX_MEMBERS];
|
||||
uint32_t ping_ms; // round trip to the relay; 0 until measured
|
||||
char status[96]; // what is going on or what went wrong, in words
|
||||
uint32_t tx, rx, lost; // datagrams sent, accepted, and received but not accepted (bad tag, wrong sender, replay)
|
||||
CoopNote note;
|
||||
char steam_says[160]; // with COOP_NO_STEAM: the Steam layer's own sentence, for the log's reader
|
||||
char code[STEAM_CODE_CAP]; // the room's id, "" outside a room
|
||||
uint8_t host; // this game is the room's host
|
||||
uint8_t overlay; // Steam's own invite window can be shown
|
||||
uint8_t local; // the test stand-in for Steam is in use (two games on one PC)
|
||||
int n;
|
||||
CoopPlayer players[COOP_PLAYERS];
|
||||
uint64_t invite_room; // a friend invites this player to a room (0 none) ...
|
||||
char invite_from[COOP_NAME_CAP];
|
||||
int nchat;
|
||||
CoopChatLine chat[COOP_CHAT_LINES]; // oldest first
|
||||
uint32_t friends_serial; // changes when coop_friends has a new list
|
||||
} CoopView;
|
||||
|
||||
// ---- the process's session (the one the settings drive)
|
||||
void coop_init(void); // starts the co-op thread; it idles while the COOP setting is off
|
||||
void coop_shutdown(void); // leaves the room and signs out of Steam, before the process ends
|
||||
|
||||
// Starts the coop thread. It re-reads the settings when cfg_version changes and does nothing while COOP is off.
|
||||
void coop_init(void);
|
||||
// Leaves the room and says BYE to the others, best effort, for the three ways the process ends (boot.c, svc.c,
|
||||
// gfx_present.c, before fs_save_flush): waits at most about 0.4 s for the coop thread, then returns whatever happened.
|
||||
// A session still connecting is left running (the process ends next; the relay drops a member it never hears from).
|
||||
void coop_shutdown(void);
|
||||
// Create, join or leave a room. secret (as typed: any case, '-' and spaces allowed) is required by JOIN; CREATE makes a
|
||||
// room of that secret, or of a new random one when it is NULL or empty (the view shows it: the player passes it on to
|
||||
// the others out of band). 1 when queued, 0 when the secret is not one or co-op is off. The outcome shows in coop_view_get.
|
||||
int coop_command(CoopCmd cmd, const char *secret);
|
||||
// The room's maker removes a member (its id): every game drops its identity (progress sync signs the removal with the
|
||||
// maker's key, coop_state.h), and when the relay names this player the maker, the relay drops the member and refuses
|
||||
// it again under that identity. 1 when either was done.
|
||||
int coop_remove_member(int member);
|
||||
// fn(member, user) when coop_remove_member is called, on the caller's thread, before the relay is asked: the layer that
|
||||
// signs removals (progress sync) registers here; 1 when it removed the member. One hook.
|
||||
typedef int (*CoopRemoveFn)(int member, void *user);
|
||||
int coop_on_remove(CoopRemoveFn fn, void *user);
|
||||
void coop_view_get(CoopView *out);
|
||||
// This player's id towards the relay: random for each start of the game, never sent to the other players.
|
||||
uint64_t coop_client_id(void);
|
||||
void coop_view(CoopView *out);
|
||||
uint32_t coop_serial(void); // changes whenever the view does: a reader that keeps a copy compares this first
|
||||
|
||||
// Peer messages. kind is COOP_K_*; bytes follow it in the datagram. coop_send goes to every other member, coop_send_to to
|
||||
// one (a member id). 1 when queued, 0 when not in a room, the message is too long (COOP_MAX_MESSAGE bytes) or the
|
||||
// outbox is full: a message is a datagram and may be lost anyway. Every message is sealed with the room's message key.
|
||||
int coop_send(uint8_t kind, const void *bytes, size_t n);
|
||||
int coop_send_to(int member, uint8_t kind, const void *bytes, size_t n);
|
||||
// fn(from member id, the message bytes after the kind, their count, user) for every message of that kind that opened
|
||||
// with the room's key and came from the session the roster names for its sender. One handler per kind; register before
|
||||
// the message can arrive (at start-up). Not once only: the window refuses a repeat within the last 64 it took, but
|
||||
// four older messages in a row start it again, after which a recorded message of that session can arrive again (a
|
||||
// relay without the secret can do that), and anyone with the secret can seal one again under a new counter. A handler
|
||||
// for which a repeat or an old message matters keeps a counter of its own per sender and session inside its messages
|
||||
// and takes only one above the last it took (a position message, say, so that an old pose does not move a player
|
||||
// back); progress sync signs its counter, which only the sender can then move.
|
||||
typedef void (*CoopMsgFn)(int from, const uint8_t *bytes, size_t n, void *user);
|
||||
int coop_on_message(uint8_t kind, CoopMsgFn fn, void *user);
|
||||
// fn(view, user) after the state, the room, the roster or the status changed; up to 8 hooks. A layer that sends a HELLO to
|
||||
// every new member listens here.
|
||||
typedef void (*CoopViewFn)(const CoopView *view, void *user);
|
||||
int coop_on_view(CoopViewFn fn, void *user);
|
||||
// fn(now in ms, user) at every step of the coop thread (every 8 ms or less in a room, 250 ms idle); up to 4 hooks. A layer
|
||||
// with timers of its own (digests, repeated sends) runs them here.
|
||||
typedef void (*CoopTickFn)(uint64_t now_ms, void *user);
|
||||
int coop_on_tick(CoopTickFn fn, void *user);
|
||||
// Commands, from any thread; each is carried out at the co-op thread's next step and none waits.
|
||||
void coop_create(void);
|
||||
int coop_join(const char *code); // 0: the text is no room id (nothing is asked of Steam)
|
||||
void coop_join_invite(void); // the room of the invite the view shows
|
||||
void coop_decline_invite(void);
|
||||
void coop_leave(void);
|
||||
void coop_retry(void); // look for Steam again now
|
||||
void coop_invite(uint64_t friend_id);
|
||||
void coop_invite_window(void);
|
||||
void coop_remove(uint64_t player_id); // the host's: that player is out of the room and stays out
|
||||
void coop_chat(const char *text);
|
||||
void coop_friends_refresh(void);
|
||||
int coop_friends(SteamFriend *out, int max); // the list of the last refresh
|
||||
|
||||
// "host", "host:port", "[v6]:port" or a bare IPv6 address into host (cap bytes) and port (default 24680). 0 when text is
|
||||
// empty or does not fit.
|
||||
int coop_server_parse(const char *text, char *host, size_t cap, uint16_t *port);
|
||||
// ---- for the game layer (coop_game.c)
|
||||
void coop_pose_set(const CoopPose *pose); // this game's own Link, each frame he is in the world; NULL when he is not
|
||||
// A message of the game layer to everyone in the room (to 0) or to one player; kind from COOP_GAME_KIND on, n at most
|
||||
// COOP_MESSAGE_MAX. From any thread; it leaves at the co-op thread's next step. 0 outside a room.
|
||||
int coop_post(uint64_t to, uint8_t kind, const void *data, size_t n, int reliable);
|
||||
// coop_game.c's part, called on the co-op thread: a message of its kinds from a player of the room, and a player who
|
||||
// came (the game layer sends that player what it shares) or went.
|
||||
void coop_game_message(uint64_t from, uint8_t kind, const uint8_t *data, size_t n);
|
||||
void coop_game_joined(uint64_t id);
|
||||
void coop_game_room(int in_room);
|
||||
|
||||
// ---- a session of its own (--probe-coop runs two in one process; the process's session is one of these driven by the settings)
|
||||
typedef struct CoopSess CoopSess;
|
||||
typedef struct {
|
||||
const char *tag; // names the session in log lines ("coop[A]: ..."); NULL for none
|
||||
const char *server; // "host[:port]"
|
||||
const char *name; // the player's name
|
||||
uint64_t client_id; // the same one on every reconnect keeps the member id for a minute (with the rejoin token)
|
||||
int on; // 0: off (COOP_OFF), the COOP setting; 1: on, in no room until a command says
|
||||
uint16_t local_port; // 0: any
|
||||
unsigned drop_pct; // percent of received datagrams thrown away, for tests
|
||||
int retry; // a room the relay lost (a restart) is made or waited for again instead of ending the session
|
||||
// timings in ms, 0 for the defaults (2000, 8000, 250, 1000, 15000); tests shorten them
|
||||
uint32_t ping_ms, silence_ms, burst_gap_ms, backoff_first_ms, backoff_max_ms;
|
||||
} CoopParams;
|
||||
CoopSess *coop_sess_new(const CoopParams *p); // p's strings are copied
|
||||
void coop_sess_free(CoopSess *s); // the stepping thread must be gone
|
||||
// The stepping thread calls this in a loop: handles commands, the outbox, one batch of datagrams and the timers, waiting at
|
||||
// most 8 ms (in a room), 50 ms (reaching the relay) or 250 ms (idle) for the next datagram.
|
||||
void coop_sess_step(CoopSess *s);
|
||||
int coop_sess_command(CoopSess *s, CoopCmd cmd, const char *secret); // as coop_command, for this session
|
||||
int coop_sess_remove(CoopSess *s, int member); // as coop_remove_member
|
||||
int coop_sess_send(CoopSess *s, int member, uint8_t kind, const void *bytes, size_t n); // member 0 or COOP_DST_ALL: all
|
||||
int coop_sess_on_message(CoopSess *s, uint8_t kind, CoopMsgFn fn, void *user);
|
||||
int coop_sess_on_view(CoopSess *s, CoopViewFn fn, void *user);
|
||||
int coop_sess_on_tick(CoopSess *s, CoopTickFn fn, void *user);
|
||||
void coop_sess_view(CoopSess *s, CoopView *out);
|
||||
// Replaces the settings the session reads with those of p (the timings stay as they were made); the stepping thread
|
||||
// applies them, on or off included. A new server ends the room; a new name, once the room is joined, joins it again under the new name a
|
||||
// second after the last change, so typing a name does not rejoin at every letter.
|
||||
void coop_sess_configure(CoopSess *s, const CoopParams *p);
|
||||
// Ends the session as coop_sess_configure with on = 0 would: LEAVE and BYE, socket closed, state COOP_OFF.
|
||||
void coop_sess_stop(CoopSess *s);
|
||||
// Waits at most ms for the stepping thread to have carried out a stop (or a configure with on = 0); 1 when it did.
|
||||
int coop_sess_wait_off(CoopSess *s, uint32_t ms);
|
||||
|
||||
int probe_coop(void); // coop_probe.c: --probe-coop
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
// The relay NX2navi's co-op (coop.c) joins when coop_server is not set: the one place that default lives, like
|
||||
// discord_app.h for the Rich Presence. Empty until the project hosts a relay: with no server the session stays idle and
|
||||
// logs why, rather than sending a player's room code to a server nobody chose. Anyone can run tools/coop_relay.py and set
|
||||
// coop_server in nx2navi.ini (docs/coop.md).
|
||||
#pragma once
|
||||
|
||||
#define NX2NAVI_COOP_SERVER_DEFAULT "" // "host" or "host:port"; the default port is 24680
|
||||
1300
runtime/coop_game.c
1300
runtime/coop_game.c
File diff suppressed because it is too large
Load Diff
@@ -1,22 +1,12 @@
|
||||
// Co-op progress sync, the game side (Ocarina 1.1.1): reads the game's flag database between frames, hands what changed
|
||||
// to the merge engine (coop_state.c), and gives the game what the room has through the game's own set routines, so the
|
||||
// game takes it as if the player had done it. Nothing is read or written while the game is on its title screen, loading
|
||||
// or changing scene; what arrives meanwhile waits. docs/coop.md says what is shared.
|
||||
// Co-op, the game side (coop_game.c): where this game's Link is and the progress a room shares. coop.h declares the
|
||||
// part the co-op thread calls (coop_game_message, coop_game_joined, coop_game_room).
|
||||
#pragma once
|
||||
#include "coop_offer.h"
|
||||
#include "coop_proto.h"
|
||||
#include "coop_state.h"
|
||||
#include "host.h"
|
||||
|
||||
// Registers the message handlers and the coop thread's hooks (main.c, after coop_init). Allocates nothing until the COOP
|
||||
// setting is on.
|
||||
#include "cpu.h"
|
||||
|
||||
void coop_game_init(void);
|
||||
// nvnQueuePresentTexture, between frames on the game's thread with its core held (as res_present). With COOP off it reads
|
||||
// one counter and returns.
|
||||
// At each present, on the game's thread, between two frames: reads Link and the game's flags and sets the flags the
|
||||
// room has and this game lacks, through the game's own routines. Does nothing while the COOP setting is off.
|
||||
void coop_present(Cpu *c);
|
||||
|
||||
// The offer the player accepts before anything of a room is applied, the maker's remedies and the pools' contributors:
|
||||
// coop_offer.h (coop_game_offer, coop_game_accept, coop_game_reset_pools, coop_game_remove_key, coop_game_contributors).
|
||||
// fs_host.c, at every RomFS file open on any thread: notes the start of the title screen, after which sync waits for a
|
||||
// save to be loaded. With COOP off it reads one value and returns.
|
||||
// Each RomFS file the game opens (fs_host.c): the title screen's start is told by its event flow being opened.
|
||||
void coop_game_rom_open(const char *path);
|
||||
|
||||
192
runtime/coop_local.c
Normal file
192
runtime/coop_local.c
Normal file
@@ -0,0 +1,192 @@
|
||||
// The stand-in for Steam in tests of two or more games on one PC (coop_net.h): datagrams between UDP ports on
|
||||
// 127.0.0.1. A player's id is its port, a room's number its maker's port. The maker keeps the member list: a member
|
||||
// says JOIN once a second, the maker answers everyone with MEMBERS and drops a member it has not heard for five
|
||||
// seconds. Loopback loses and reorders nothing in practice, so "reliable" is a plain datagram here.
|
||||
//
|
||||
// Only the environment turns it on: a settings file cannot.
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "coop_net.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
enum { L_JOIN = 1, L_MEMBERS, L_DATA, L_LEAVE, L_MAX = 8, L_SILENT_MS = 5000, L_JOIN_EVERY_MS = 1000, L_JOIN_WAIT_MS = 4000 };
|
||||
|
||||
static struct {
|
||||
PlatUdp *udp;
|
||||
uint64_t self, room;
|
||||
uint64_t joining; // the room asked for, until its maker answers
|
||||
uint64_t join_since, join_sent, members_sent;
|
||||
int n;
|
||||
uint64_t ids[L_MAX];
|
||||
uint64_t heard[L_MAX]; // the maker's: when each member last said JOIN
|
||||
int pending_entered; // the maker's own room: entered at the next pump
|
||||
} L;
|
||||
|
||||
static uint64_t env_number(const char *name) {
|
||||
char v[32];
|
||||
return plat_getenv(name, v, sizeof v) ? strtoull(v, NULL, 10) : 0;
|
||||
}
|
||||
|
||||
int coop_local_wanted(void) { return env_number("NX2NAVI_COOP_LOCAL") != 0; }
|
||||
uint64_t coop_local_join(void) { return env_number("NX2NAVI_COOP_LOCAL_JOIN"); }
|
||||
int coop_local_makes(void) { return env_number("NX2NAVI_COOP_LOCAL_MAKE") == 1; }
|
||||
|
||||
static void to_port(uint64_t port, const void *p, size_t n) {
|
||||
static const uint8_t loopback[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 127, 0, 0, 1};
|
||||
PlatAddr a;
|
||||
plat_addr_set(&a, loopback, (uint16_t)port, 0);
|
||||
plat_udp_send(L.udp, &a, p, n);
|
||||
}
|
||||
|
||||
static int l_start(char *why, size_t cap, int *which) {
|
||||
if (L.udp) return 1;
|
||||
uint64_t port = env_number("NX2NAVI_COOP_LOCAL");
|
||||
L.udp = port && port < 65536 ? plat_udp_open((uint16_t)port, 0) : NULL;
|
||||
if (!L.udp) {
|
||||
snprintf(why, cap, "the test port %llu cannot be opened", (unsigned long long)port);
|
||||
if (which) *which = STEAM_WHY_NO_CLIENT;
|
||||
return 0;
|
||||
}
|
||||
L.self = port;
|
||||
if (which) *which = STEAM_WHY_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void l_room_leave(void) {
|
||||
if (L.room && L.room != L.self) to_port(L.room, (uint8_t[]){L_LEAVE}, 1);
|
||||
L.room = L.joining = 0, L.n = 0;
|
||||
}
|
||||
|
||||
static void l_stop(void) {
|
||||
l_room_leave();
|
||||
if (L.udp) plat_udp_close(L.udp);
|
||||
L.udp = NULL;
|
||||
}
|
||||
|
||||
static uint64_t l_self(void) { return L.self; }
|
||||
static void l_name_of(uint64_t id, char *out, size_t cap) { snprintf(out, cap, "Player %llu", (unsigned long long)id); }
|
||||
|
||||
static int l_room_create(int max_players) {
|
||||
(void)max_players;
|
||||
if (!L.udp || L.room) return 0;
|
||||
L.room = L.self, L.n = 1, L.ids[0] = L.self, L.pending_entered = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_room_join(uint64_t room) {
|
||||
if (!L.udp || L.room || !room || room == L.self) return 0;
|
||||
L.joining = room, L.join_since = plat_now_ms(), L.join_sent = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint64_t l_room(void) { return L.room; }
|
||||
static uint64_t l_room_owner(void) { return L.room; }
|
||||
static int l_room_members(uint64_t *out, int max) {
|
||||
int n = L.room ? L.n : 0;
|
||||
if (n > max) n = max;
|
||||
memcpy(out, L.ids, (size_t)n * sizeof *out);
|
||||
return n;
|
||||
}
|
||||
static int l_room_set(const char *key, const char *value) { (void)key, (void)value; return 1; }
|
||||
static void l_room_get(const char *key, char *out, size_t cap) {
|
||||
snprintf(out, cap, "%s", !strcmp(key, "nx2navi") ? "1" : ""); // every room of the stand-in is one of ours
|
||||
}
|
||||
|
||||
static int member(uint64_t id) {
|
||||
for (int i = 0; i < L.n; i++)
|
||||
if (L.ids[i] == id) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int l_send(uint64_t to, const void *data, size_t n, int reliable) {
|
||||
(void)reliable;
|
||||
if (!L.room || n > STEAM_MESSAGE_MAX || member(to) < 0) return 0;
|
||||
uint8_t d[1 + STEAM_MESSAGE_MAX];
|
||||
d[0] = L_DATA;
|
||||
memcpy(d + 1, data, n);
|
||||
to_port(to, d, n + 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void send_members(void) {
|
||||
uint8_t d[1 + 8 * L_MAX];
|
||||
d[0] = L_MEMBERS;
|
||||
memcpy(d + 1, L.ids, (size_t)L.n * 8);
|
||||
for (int i = 1; i < L.n; i++) to_port(L.ids[i], d, 1 + (size_t)L.n * 8);
|
||||
L.members_sent = plat_now_ms();
|
||||
}
|
||||
|
||||
static void drop(int i, void (*on)(const SteamEvent *, void *), void *user) {
|
||||
uint64_t id = L.ids[i];
|
||||
for (int k = i; k + 1 < L.n; k++) L.ids[k] = L.ids[k + 1], L.heard[k] = L.heard[k + 1];
|
||||
L.n--;
|
||||
on(&(SteamEvent){.kind = STEAM_EV_MEMBER_LEFT, .a = id}, user);
|
||||
}
|
||||
|
||||
static void l_pump(void (*on)(const SteamEvent *e, void *user), void *user) {
|
||||
if (!L.udp) return;
|
||||
uint64_t now = plat_now_ms();
|
||||
if (L.pending_entered) {
|
||||
L.pending_entered = 0;
|
||||
on(&(SteamEvent){.kind = STEAM_EV_ROOM_ENTERED, .a = L.room}, user);
|
||||
}
|
||||
uint64_t maker = L.joining ? L.joining : L.room != L.self ? L.room : 0;
|
||||
if (maker && now - L.join_sent >= L_JOIN_EVERY_MS) to_port(maker, (uint8_t[]){L_JOIN}, 1), L.join_sent = now;
|
||||
if (L.joining && now - L.join_since > L_JOIN_WAIT_MS) {
|
||||
L.joining = 0;
|
||||
on(&(SteamEvent){.kind = STEAM_EV_ROOM_FAILED, .code = STEAM_FAIL_NO_ROOM}, user);
|
||||
}
|
||||
for (;;) {
|
||||
uint8_t d[1 + STEAM_MESSAGE_MAX + 8];
|
||||
PlatAddr from;
|
||||
int n = plat_udp_recv(L.udp, d, sizeof d, &from, 0);
|
||||
if (n <= 0) break;
|
||||
uint64_t who = plat_addr_port(&from);
|
||||
if (d[0] == L_JOIN && L.room == L.self) {
|
||||
int i = member(who);
|
||||
if (i < 0 && L.n < L_MAX) {
|
||||
i = L.n++;
|
||||
L.ids[i] = who, L.heard[i] = now;
|
||||
send_members();
|
||||
on(&(SteamEvent){.kind = STEAM_EV_MEMBER_JOINED, .a = who}, user);
|
||||
} else if (i >= 0) {
|
||||
L.heard[i] = now;
|
||||
}
|
||||
} else if (d[0] == L_LEAVE && L.room == L.self) {
|
||||
int i = member(who);
|
||||
if (i > 0) drop(i, on, user), send_members();
|
||||
} else if (d[0] == L_MEMBERS && (who == L.joining || (L.room && who == L.room && L.room != L.self))) {
|
||||
uint64_t ids[L_MAX];
|
||||
int count = (n - 1) / 8;
|
||||
if (count > L_MAX) count = L_MAX;
|
||||
memcpy(ids, d + 1, (size_t)count * 8);
|
||||
int entering = L.joining != 0;
|
||||
if (entering) L.room = L.joining, L.joining = 0, L.n = 0;
|
||||
// who left, then who came, against the list held
|
||||
for (int i = L.n - 1; i >= 0; i--) {
|
||||
int still = 0;
|
||||
for (int k = 0; k < count; k++) still |= ids[k] == L.ids[i];
|
||||
if (!still) drop(i, on, user);
|
||||
}
|
||||
for (int k = 0; k < count; k++) {
|
||||
if (member(ids[k]) >= 0 || L.n >= L_MAX) continue;
|
||||
L.ids[L.n++] = ids[k];
|
||||
if (!entering && ids[k] != L.self) on(&(SteamEvent){.kind = STEAM_EV_MEMBER_JOINED, .a = ids[k]}, user);
|
||||
}
|
||||
if (entering) on(&(SteamEvent){.kind = STEAM_EV_ROOM_ENTERED, .a = L.room}, user);
|
||||
} else if (d[0] == L_DATA && L.room && member(who) >= 0 && n > 1) {
|
||||
on(&(SteamEvent){.kind = STEAM_EV_MESSAGE, .a = who, .data = d + 1, .n = (size_t)n - 1}, user);
|
||||
}
|
||||
if (!L.udp) return; // a handler stopped the stand-in
|
||||
}
|
||||
if (L.room == L.self) {
|
||||
for (int i = L.n - 1; i > 0; i--)
|
||||
if (now - L.heard[i] > L_SILENT_MS) drop(i, on, user), send_members();
|
||||
if (now - L.members_sent >= L_JOIN_EVERY_MS) send_members();
|
||||
}
|
||||
}
|
||||
|
||||
const CoopNet coop_net_local = {l_start, l_stop, l_self, l_name_of, l_room_create, l_room_join, l_room_leave, l_room,
|
||||
l_room_owner, l_room_members, l_room_set, l_room_get, l_send, l_pump};
|
||||
30
runtime/coop_net.h
Normal file
30
runtime/coop_net.h
Normal file
@@ -0,0 +1,30 @@
|
||||
// What co-op (coop.c) needs from the network under it: Steam (steam.c), or the stand-in for tests of two games on one
|
||||
// PC (coop_local.c), which one Steam account cannot do. The functions are steam.h's, with its events.
|
||||
#pragma once
|
||||
|
||||
#include "steam.h"
|
||||
|
||||
typedef struct {
|
||||
int (*start)(char *why, size_t cap, int *which);
|
||||
void (*stop)(void);
|
||||
uint64_t (*self)(void);
|
||||
void (*name_of)(uint64_t id, char *out, size_t cap);
|
||||
int (*room_create)(int max_players);
|
||||
int (*room_join)(uint64_t room);
|
||||
void (*room_leave)(void);
|
||||
uint64_t (*room)(void);
|
||||
uint64_t (*room_owner)(void);
|
||||
int (*room_members)(uint64_t *out, int max);
|
||||
int (*room_set)(const char *key, const char *value);
|
||||
void (*room_get)(const char *key, char *out, size_t cap);
|
||||
int (*send)(uint64_t to, const void *data, size_t n, int reliable);
|
||||
void (*pump)(void (*on)(const SteamEvent *e, void *user), void *user);
|
||||
} CoopNet;
|
||||
|
||||
// The stand-in: NX2NAVI_COOP_LOCAL=<port> in the environment (never from nx2navi.ini) makes this game the player
|
||||
// whose id is that UDP port on 127.0.0.1; the room it makes has that number, and another game joins it with
|
||||
// NX2NAVI_COOP_LOCAL_JOIN=<that port>. No Steam, no room ids, no invites.
|
||||
extern const CoopNet coop_net_local;
|
||||
int coop_local_wanted(void); // the variable is set
|
||||
uint64_t coop_local_join(void); // the room NX2NAVI_COOP_LOCAL_JOIN names, 0 none
|
||||
int coop_local_makes(void); // NX2NAVI_COOP_LOCAL_MAKE=1: this game makes its room at once
|
||||
@@ -1,45 +0,0 @@
|
||||
// What the menu's Co-op tab reads of a room and asks of it (coop_game.c), in a header of its own without host.h so that
|
||||
// the menu's C++ can include it. Every call may be made from any thread and never waits for the sync engine: what is
|
||||
// read is a copy the coop thread publishes at each of its steps, and what is asked is carried out by the coop thread at
|
||||
// its next step (a few ms in a room), which logs the outcome.
|
||||
#pragma once
|
||||
#include "coop_proto.h"
|
||||
#include "coop_state.h"
|
||||
|
||||
// What joining the room means, for the player to accept: the engine's offer (coop_state.h: CoopOffer), with the
|
||||
// relay's names for members not identified yet. Nothing from a room is applied to the game before the player accepted
|
||||
// its offer and a copy of the save was made (<profile>/coop-backup/<time>/, docs/coop.md; the first copy for a room is
|
||||
// "first-<time>" and is never pruned). An accepted offer stays accepted while every member is an identity accepted,
|
||||
// the rules and the key that signs them stay the same and the same save is played; anything else is a new offer, and
|
||||
// nothing more is applied until that one is accepted. A member in the room that never identified itself keeps the room
|
||||
// unaccepted. The offer's number is random for each start of the game. The COOP_ACCEPT setting accepts one offer by its
|
||||
// number (the log shows it) or, from the environment only, every offer with "always"; the menu calls coop_game_accept.
|
||||
// 1 when there is an offer; without one (token 0) the members and disagree are still filled in while in a room.
|
||||
int coop_game_offer(CoopOffer *out);
|
||||
// Accepts the offer of that number, the one the player was shown: 1 when it is the offer published last (or that offer
|
||||
// is accepted already) and no member in the room is unidentified; 0 otherwise, and nothing changes (ask again once
|
||||
// unidentified is 0). The coop thread accepts it at its next step only while it is still the room's offer.
|
||||
int coop_game_accept(uint32_t token);
|
||||
// The room's maker (its game holds the key that signs the rules, kept in the profile across restarts) resets the pools:
|
||||
// every game joins them again with what they held for the players in the room. 1 when asked (this game is the maker).
|
||||
// The setting COOP_RESET_POOLS does it too (when it changes to a value other than 0).
|
||||
int coop_game_reset_pools(void);
|
||||
// The room's maker removes a key by its fingerprint (xxxx-xxxx-xxxx-xxxx, as the offer, the contributors and the log
|
||||
// show it), also of a member that left: every game drops it and its pool records, and a member in the room that holds
|
||||
// it is removed at the relay too. 1 when asked (a fingerprint, and this game is the maker). The setting COOP_REMOVE
|
||||
// takes a fingerprint too. A member is never removed by its id from here: ids pass to other players as members come
|
||||
// and go.
|
||||
int coop_game_remove_key(const char *fingerprint);
|
||||
// The identities the pools admit and what each took beyond what it brought, per pool (coop_state.h: CoopContributor):
|
||||
// whom the maker would remove after a drain. Their count (at most max), as published at most half a second ago.
|
||||
int coop_game_contributors(CoopContributor *out, int max);
|
||||
// This game holds the key that signs the room's rules (it made the room, in this start of the game or an earlier one):
|
||||
// its removals and pool resets act.
|
||||
int coop_game_is_maker(void);
|
||||
// The members this game would show in its world (nothing draws them in this build), one bit per member id: identified (heard, so not disputed
|
||||
// between two keys), not removed, and with a key this player accepted under the name it signs now (no accepted_as).
|
||||
// A member the player has not accepted, or who is not identified, shows no puppet. accepted(key fingerprint, user): 1
|
||||
// when this player accepted that key. Kept apart from the game so that --probe-coop checks it (coop_proto.c).
|
||||
uint32_t coop_offer_shown(const CoopOffer *o, int (*accepted)(const char *key, void *user), void *user);
|
||||
// The same, as the coop thread last published it (0 outside a room).
|
||||
uint32_t coop_game_shown(void);
|
||||
1592
runtime/coop_probe.c
1592
runtime/coop_probe.c
File diff suppressed because it is too large
Load Diff
@@ -1,513 +0,0 @@
|
||||
// The co-op wire format (coop_proto.h): room secrets and their keys, HMAC tags, the datagram header, the client and
|
||||
// relay messages and the sealed player messages. Pure functions on bytes.
|
||||
#include "coop_proto.h"
|
||||
#include "coop_offer.h" // coop_offer_shown: who the puppets show
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "sha256.h"
|
||||
#include "third_party/monocypher/monocypher.h"
|
||||
|
||||
static const char secret_alphabet[] = "23456789BCDFGHJKMNPRSTVWXYZ";
|
||||
|
||||
static int secret_char(char c) { return c && strchr(secret_alphabet, c) != NULL; }
|
||||
|
||||
// The length of the string at s, at most max.
|
||||
static size_t bounded_len(const char *s, size_t max) {
|
||||
size_t n = 0;
|
||||
while (n < max && s[n]) n++;
|
||||
return n;
|
||||
}
|
||||
|
||||
int coop_secret_normalize(const char *text, char out[COOP_SECRET_LEN + 1]) {
|
||||
size_t n = 0;
|
||||
for (const char *p = text; *p; p++) {
|
||||
char c = *p;
|
||||
if (c == '-' || c == ' ') continue;
|
||||
if (c >= 'a' && c <= 'z') c = (char)(c - 'a' + 'A');
|
||||
if (n == COOP_SECRET_LEN || !secret_char(c)) return 0;
|
||||
out[n++] = c;
|
||||
}
|
||||
if (n != COOP_SECRET_LEN) return 0;
|
||||
out[n] = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void coop_secret_format(const char secret[COOP_SECRET_LEN], char out[COOP_SECRET_TEXT + 1]) {
|
||||
for (int g = 0, at = 0; g < 3; g++) {
|
||||
if (g) out[at++] = '-';
|
||||
memcpy(out + at, secret + 6 * g, 6);
|
||||
at += 6;
|
||||
}
|
||||
out[COOP_SECRET_TEXT] = 0;
|
||||
}
|
||||
|
||||
int coop_secret_from_random(const uint8_t random[32], char out[COOP_SECRET_LEN + 1]) {
|
||||
int n = 0;
|
||||
for (int i = 0; i < 32 && n < COOP_SECRET_LEN; i++)
|
||||
if (random[i] < 243) out[n++] = secret_alphabet[random[i] % 27]; // 243 = 9 x 27: every symbol as likely
|
||||
out[n] = 0;
|
||||
return n == COOP_SECRET_LEN;
|
||||
}
|
||||
|
||||
// Three characters of the secret's alphabet taken from a hash of the secret, not from the secret itself: every game
|
||||
// in the room gets the same label, and a log that is passed on gives away none of the secret's characters.
|
||||
void coop_secret_short(const char secret[COOP_SECRET_LEN], char out[8]) {
|
||||
static const char label_key[] = "nx2navi co-op room label";
|
||||
uint8_t h[4];
|
||||
coop_blake2b(h, sizeof h, label_key, sizeof label_key - 1, secret, COOP_SECRET_LEN);
|
||||
uint32_t v = (uint32_t)h[0] | (uint32_t)h[1] << 8 | (uint32_t)h[2] << 16;
|
||||
for (int i = 0; i < 3; i++, v /= 27) out[i] = secret_alphabet[v % 27];
|
||||
memcpy(out + 3, "\xe2\x80\xa6", 4); // U+2026 and the NUL
|
||||
}
|
||||
|
||||
// ---- keys and tags
|
||||
|
||||
static void sha_two(Sha256 *s, const void *a, size_t an, const void *b, size_t bn) {
|
||||
if (an) sha256_update(s, a, an);
|
||||
if (bn) sha256_update(s, b, bn);
|
||||
}
|
||||
|
||||
void coop_hmac_sha256(const void *key, size_t klen, const void *a, size_t an, const void *b, size_t bn, uint8_t out[32]) {
|
||||
uint8_t k[64] = {0}, pad[64], inner[32];
|
||||
Sha256 s;
|
||||
if (klen > sizeof k) sha256(key, klen, k);
|
||||
else if (klen) memcpy(k, key, klen);
|
||||
for (int i = 0; i < 64; i++) pad[i] = k[i] ^ 0x36;
|
||||
sha256_init(&s);
|
||||
sha256_update(&s, pad, sizeof pad);
|
||||
sha_two(&s, a, an, b, bn);
|
||||
sha256_final(&s, inner);
|
||||
for (int i = 0; i < 64; i++) pad[i] = k[i] ^ 0x5c;
|
||||
sha256_init(&s);
|
||||
sha256_update(&s, pad, sizeof pad);
|
||||
sha256_update(&s, inner, sizeof inner);
|
||||
sha256_final(&s, out);
|
||||
}
|
||||
|
||||
void coop_room_keys(const char secret[COOP_SECRET_LEN], uint8_t locator[COOP_KEY_LEN], uint8_t msg_key[COOP_MSG_KEY_LEN]) {
|
||||
static const char room[] = "nx2navi-coop/2 room", messages[] = "nx2navi-coop/2 messages";
|
||||
if (locator) crypto_blake2b_keyed(locator, COOP_KEY_LEN, (const uint8_t *)secret, COOP_SECRET_LEN, (const uint8_t *)room, sizeof room - 1);
|
||||
if (msg_key)
|
||||
crypto_blake2b_keyed(msg_key, COOP_MSG_KEY_LEN, (const uint8_t *)secret, COOP_SECRET_LEN, (const uint8_t *)messages,
|
||||
sizeof messages - 1);
|
||||
}
|
||||
|
||||
static void make_tag(const uint8_t key[COOP_KEY_LEN], const uint8_t *hdr16, const uint8_t *payload, size_t n,
|
||||
uint8_t tag[COOP_TAG_LEN]) {
|
||||
uint8_t full[32];
|
||||
coop_hmac_sha256(key, COOP_KEY_LEN, hdr16, 16, payload, n, full);
|
||||
memcpy(tag, full, COOP_TAG_LEN);
|
||||
}
|
||||
|
||||
// ---- little-endian fields
|
||||
|
||||
static void put16(uint8_t *p, uint32_t v) { p[0] = (uint8_t)v, p[1] = (uint8_t)(v >> 8); }
|
||||
static void put32(uint8_t *p, uint32_t v) { put16(p, v), put16(p + 2, v >> 16); }
|
||||
static void put64(uint8_t *p, uint64_t v) { put32(p, (uint32_t)v), put32(p + 4, (uint32_t)(v >> 32)); }
|
||||
static uint32_t get16(const uint8_t *p) { return (uint32_t)p[0] | (uint32_t)p[1] << 8; }
|
||||
static uint32_t get32(const uint8_t *p) { return get16(p) | get16(p + 2) << 16; }
|
||||
static uint64_t get64(const uint8_t *p) { return get32(p) | (uint64_t)get32(p + 4) << 32; }
|
||||
|
||||
// ---- datagrams
|
||||
|
||||
size_t coop_dgram_pack(uint8_t *out, size_t cap, const CoopHdr *h, const void *payload, size_t n,
|
||||
const uint8_t key[COOP_KEY_LEN]) {
|
||||
if (n > COOP_MAX_PAYLOAD || cap < COOP_HDR_LEN + n) return 0;
|
||||
put16(out, COOP_MAGIC);
|
||||
out[2] = h->ver, out[3] = h->type;
|
||||
put32(out + 4, h->room);
|
||||
out[8] = h->src, out[9] = h->dst;
|
||||
put16(out + 10, (uint32_t)n);
|
||||
put32(out + 12, h->seq);
|
||||
if (n) memmove(out + COOP_HDR_LEN, payload, n); // the payload may already sit where it goes
|
||||
if (key) make_tag(key, out, out + COOP_HDR_LEN, n, out + 16);
|
||||
else memset(out + 16, 0, COOP_TAG_LEN);
|
||||
return COOP_HDR_LEN + n;
|
||||
}
|
||||
|
||||
int coop_dgram_parse(const uint8_t *d, size_t n, CoopHdr *h, const uint8_t **payload) {
|
||||
if (n < COOP_HDR_LEN || n > COOP_MAX_DGRAM || get16(d) != COOP_MAGIC) return 0;
|
||||
uint32_t len = get16(d + 10);
|
||||
if (len != n - COOP_HDR_LEN) return 0;
|
||||
h->ver = d[2], h->type = d[3];
|
||||
h->room = get32(d + 4);
|
||||
h->src = d[8], h->dst = d[9];
|
||||
h->len = (uint16_t)len;
|
||||
h->seq = get32(d + 12);
|
||||
*payload = d + COOP_HDR_LEN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int coop_dgram_verify(const uint8_t *d, size_t n, const uint8_t key[COOP_KEY_LEN]) {
|
||||
uint8_t tag[COOP_TAG_LEN], diff = 0;
|
||||
if (n < COOP_HDR_LEN) return 0;
|
||||
make_tag(key, d, d + COOP_HDR_LEN, n - COOP_HDR_LEN, tag);
|
||||
for (int i = 0; i < COOP_TAG_LEN; i++) diff |= (uint8_t)(tag[i] ^ d[16 + i]);
|
||||
return diff == 0;
|
||||
}
|
||||
|
||||
int coop_dgram_tag_zero(const uint8_t *d) {
|
||||
uint8_t any = 0;
|
||||
for (int i = 0; i < COOP_TAG_LEN; i++) any |= d[16 + i];
|
||||
return any == 0;
|
||||
}
|
||||
|
||||
// ---- names
|
||||
|
||||
// The length of the valid UTF-8 character at p (n bytes left), 0 when the bytes there are not one: no overlong forms,
|
||||
// no surrogates, nothing above U+10FFFF.
|
||||
static size_t utf8_len(const uint8_t *p, size_t n) {
|
||||
uint8_t c = p[0];
|
||||
if (c < 0x80) return 1;
|
||||
size_t len = c >= 0xC2 && c <= 0xDF ? 2 : c >= 0xE0 && c <= 0xEF ? 3 : c >= 0xF0 && c <= 0xF4 ? 4 : 0;
|
||||
if (!len || len > n) return 0;
|
||||
for (size_t i = 1; i < len; i++)
|
||||
if ((p[i] & 0xC0) != 0x80) return 0;
|
||||
if (c == 0xE0 && p[1] < 0xA0) return 0; // overlong
|
||||
if (c == 0xED && p[1] > 0x9F) return 0; // a surrogate
|
||||
if (c == 0xF0 && p[1] < 0x90) return 0; // overlong
|
||||
if (c == 0xF4 && p[1] > 0x8F) return 0; // above U+10FFFF
|
||||
return len;
|
||||
}
|
||||
|
||||
// A character a log or a console may act on: C0, DEL, C1 (U+0080-U+009F), and the bidi controls U+061C, U+200E,
|
||||
// U+200F, U+202A-U+202E and U+2066-U+2069.
|
||||
static int control_char(const uint8_t *p, size_t len) {
|
||||
if (len == 1) return p[0] < 0x20 || p[0] == 0x7F;
|
||||
if (len == 2) return (p[0] == 0xC2 && p[1] < 0xA0) || (p[0] == 0xD8 && p[1] == 0x9C);
|
||||
if (len == 3 && p[0] == 0xE2 && p[1] == 0x80) return p[2] == 0x8E || p[2] == 0x8F || (p[2] >= 0xAA && p[2] <= 0xAE);
|
||||
if (len == 3 && p[0] == 0xE2 && p[1] == 0x81) return p[2] >= 0xA6 && p[2] <= 0xA9;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// At most max bytes of raw as valid UTF-8 into out (cap bytes, NUL-terminated): a control character and each byte that is
|
||||
// not valid UTF-8 become '?', and the text is cut before the character that would not fit.
|
||||
static size_t text_clean(char *out, size_t cap, const uint8_t *raw, size_t n, size_t max) {
|
||||
size_t at = 0, i = 0;
|
||||
if (!cap) return 0;
|
||||
while (i < n) {
|
||||
size_t len = utf8_len(raw + i, n - i), take = len ? len : 1;
|
||||
int bad = !len || control_char(raw + i, len);
|
||||
if (at + (bad ? 1 : take) > max || at + (bad ? 1 : take) + 1 > cap) break;
|
||||
if (bad) out[at++] = '?';
|
||||
else memcpy(out + at, raw + i, len), at += len;
|
||||
i += take;
|
||||
}
|
||||
out[at] = 0;
|
||||
return at;
|
||||
}
|
||||
|
||||
size_t coop_name_clean(char *out, size_t cap, const uint8_t *raw, size_t n) {
|
||||
return text_clean(out, cap, raw, n, COOP_NAME_MAX);
|
||||
}
|
||||
|
||||
// ---- client and relay messages
|
||||
|
||||
enum { CONNECT_FIXED = 43 }; // the fields before the name
|
||||
|
||||
size_t coop_connect_pack(uint8_t *out, size_t cap, const CoopConnect *c) {
|
||||
size_t nlen = bounded_len(c->name, COOP_NAME_MAX);
|
||||
size_t len = CONNECT_FIXED + nlen + 2 * COOP_COOKIE_LEN;
|
||||
size_t padded = len < COOP_CONNECT_MIN - COOP_HDR_LEN ? COOP_CONNECT_MIN - COOP_HDR_LEN : len;
|
||||
if (cap < padded) return 0;
|
||||
memset(out, 0, padded);
|
||||
out[0] = c->intent, out[1] = c->flags;
|
||||
memcpy(out + 2, c->locator, COOP_KEY_LEN);
|
||||
put64(out + 18, c->client_id);
|
||||
put64(out + 26, c->session);
|
||||
put64(out + 34, c->nonce);
|
||||
out[42] = (uint8_t)nlen;
|
||||
memcpy(out + CONNECT_FIXED, c->name, nlen);
|
||||
memcpy(out + CONNECT_FIXED + nlen, c->cookie, COOP_COOKIE_LEN);
|
||||
memcpy(out + CONNECT_FIXED + nlen + COOP_COOKIE_LEN, c->token, COOP_COOKIE_LEN);
|
||||
return padded;
|
||||
}
|
||||
|
||||
int coop_connect_parse(const uint8_t *p, size_t n, CoopConnect *c) {
|
||||
if (n < CONNECT_FIXED) return 0;
|
||||
size_t nlen = p[42];
|
||||
if (nlen > COOP_NAME_MAX || CONNECT_FIXED + nlen + 2 * COOP_COOKIE_LEN > n) return 0;
|
||||
memset(c, 0, sizeof *c);
|
||||
c->intent = p[0], c->flags = p[1];
|
||||
memcpy(c->locator, p + 2, COOP_KEY_LEN);
|
||||
c->client_id = get64(p + 18);
|
||||
c->session = get64(p + 26);
|
||||
c->nonce = get64(p + 34);
|
||||
coop_name_clean(c->name, sizeof c->name, p + CONNECT_FIXED, nlen);
|
||||
memcpy(c->cookie, p + CONNECT_FIXED + nlen, COOP_COOKIE_LEN);
|
||||
memcpy(c->token, p + CONNECT_FIXED + nlen + COOP_COOKIE_LEN, COOP_COOKIE_LEN);
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t coop_challenge_pack(uint8_t *out, size_t cap, uint64_t nonce, const uint8_t cookie[COOP_COOKIE_LEN]) {
|
||||
if (cap < 8 + COOP_COOKIE_LEN) return 0;
|
||||
put64(out, nonce);
|
||||
memcpy(out + 8, cookie, COOP_COOKIE_LEN);
|
||||
return 8 + COOP_COOKIE_LEN;
|
||||
}
|
||||
|
||||
int coop_challenge_parse(const uint8_t *p, size_t n, uint64_t *nonce, uint8_t cookie[COOP_COOKIE_LEN]) {
|
||||
if (n != 8 + COOP_COOKIE_LEN) return 0;
|
||||
*nonce = get64(p);
|
||||
memcpy(cookie, p + 8, COOP_COOKIE_LEN);
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t coop_roster_pack(uint8_t *out, size_t cap, const CoopRoster *r) {
|
||||
size_t at = 1;
|
||||
if (!cap || r->n > COOP_MAX_MEMBERS) return 0;
|
||||
out[0] = r->n;
|
||||
for (int i = 0; i < r->n; i++) {
|
||||
size_t nlen = bounded_len(r->m[i].name, COOP_NAME_MAX);
|
||||
if (at + 11 + nlen > cap) return 0;
|
||||
out[at] = r->m[i].id, out[at + 1] = r->m[i].flags;
|
||||
put64(out + at + 2, r->m[i].session);
|
||||
out[at + 10] = (uint8_t)nlen;
|
||||
memcpy(out + at + 11, r->m[i].name, nlen);
|
||||
at += 11 + nlen;
|
||||
}
|
||||
return at;
|
||||
}
|
||||
|
||||
int coop_roster_parse(const uint8_t *p, size_t n, CoopRoster *r, size_t *used) {
|
||||
if (n < 1 || p[0] > COOP_MAX_MEMBERS) return 0;
|
||||
size_t at = 1;
|
||||
memset(r, 0, sizeof *r);
|
||||
r->n = p[0];
|
||||
for (int i = 0; i < r->n; i++) {
|
||||
if (at + 11 > n) return 0;
|
||||
size_t nlen = p[at + 10];
|
||||
if (nlen > COOP_NAME_MAX || at + 11 + nlen > n) return 0;
|
||||
r->m[i].id = p[at], r->m[i].flags = p[at + 1];
|
||||
r->m[i].session = get64(p + at + 2);
|
||||
coop_name_clean(r->m[i].name, sizeof r->m[i].name, p + at + 11, nlen);
|
||||
at += 11 + nlen;
|
||||
}
|
||||
if (used) *used = at;
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t coop_joined_pack(uint8_t *out, size_t cap, const CoopJoined *j) {
|
||||
if (cap < 9 + COOP_COOKIE_LEN) return 0;
|
||||
out[0] = j->member;
|
||||
put64(out + 1, j->nonce);
|
||||
memcpy(out + 9, j->token, COOP_COOKIE_LEN);
|
||||
size_t k = coop_roster_pack(out + 9 + COOP_COOKIE_LEN, cap - 9 - COOP_COOKIE_LEN, &j->roster);
|
||||
return k ? 9 + COOP_COOKIE_LEN + k : 0;
|
||||
}
|
||||
|
||||
int coop_joined_parse(const uint8_t *p, size_t n, CoopJoined *j) {
|
||||
if (n < 9 + COOP_COOKIE_LEN) return 0;
|
||||
memset(j, 0, sizeof *j);
|
||||
j->member = p[0];
|
||||
j->nonce = get64(p + 1);
|
||||
memcpy(j->token, p + 9, COOP_COOKIE_LEN);
|
||||
return coop_roster_parse(p + 9 + COOP_COOKIE_LEN, n - 9 - COOP_COOKIE_LEN, &j->roster, NULL);
|
||||
}
|
||||
|
||||
size_t coop_error_pack(uint8_t *out, size_t cap, const CoopError *e) {
|
||||
size_t tlen = bounded_len(e->text, sizeof e->text - 1);
|
||||
if (cap < 10 + tlen) return 0;
|
||||
out[0] = e->reason;
|
||||
put64(out + 1, e->nonce);
|
||||
out[9] = (uint8_t)tlen;
|
||||
memcpy(out + 10, e->text, tlen);
|
||||
return 10 + tlen;
|
||||
}
|
||||
|
||||
int coop_error_parse(const uint8_t *p, size_t n, CoopError *e) {
|
||||
if (n < 10 || 10u + p[9] > n) return 0;
|
||||
memset(e, 0, sizeof *e);
|
||||
e->reason = p[0];
|
||||
e->nonce = get64(p + 1);
|
||||
text_clean(e->text, sizeof e->text, p + 10, p[9], sizeof e->text - 1); // for the log: printable UTF-8 only
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t coop_kick_pack(uint8_t *out, size_t cap, uint8_t member, uint64_t session) {
|
||||
if (cap < 9) return 0;
|
||||
out[0] = member;
|
||||
put64(out + 1, session);
|
||||
return 9;
|
||||
}
|
||||
|
||||
int coop_kick_parse(const uint8_t *p, size_t n, uint8_t *member, uint64_t *session) {
|
||||
if (n != 9) return 0;
|
||||
*member = p[0];
|
||||
*session = get64(p + 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t coop_u32_pack(uint8_t *out, size_t cap, uint32_t v) {
|
||||
if (cap < 4) return 0;
|
||||
put32(out, v);
|
||||
return 4;
|
||||
}
|
||||
|
||||
int coop_u32_parse(const uint8_t *p, size_t n, uint32_t *v) {
|
||||
if (n < 4) return 0;
|
||||
*v = get32(p);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ---- sealed player messages
|
||||
|
||||
static void env_nonce(uint8_t nonce[24], uint64_t session, uint32_t counter, uint8_t src) {
|
||||
memset(nonce, 0, 24);
|
||||
put64(nonce, session);
|
||||
put32(nonce + 8, counter);
|
||||
nonce[12] = src;
|
||||
}
|
||||
|
||||
size_t coop_seal(uint8_t *out, size_t cap, const uint8_t key[COOP_MSG_KEY_LEN], uint8_t src, uint8_t dst, uint64_t session,
|
||||
uint32_t counter, uint8_t kind, const void *bytes, size_t n) {
|
||||
size_t total = COOP_ENV_OVERHEAD + 1 + n;
|
||||
if (n > COOP_MAX_MESSAGE || cap < total) return 0;
|
||||
uint8_t nonce[24], ad[2] = {dst, COOP_ENV_V1};
|
||||
out[0] = COOP_ENV_V1;
|
||||
put64(out + 1, session);
|
||||
put32(out + 9, counter);
|
||||
uint8_t *plain = out + COOP_ENV_HDR;
|
||||
if (n) memmove(plain + 1, bytes, n);
|
||||
plain[0] = kind;
|
||||
env_nonce(nonce, session, counter, src);
|
||||
crypto_aead_lock(plain, out + COOP_ENV_HDR + 1 + n, key, nonce, ad, sizeof ad, plain, 1 + n);
|
||||
return total;
|
||||
}
|
||||
|
||||
int coop_envelope_peek(const uint8_t *p, size_t n, uint64_t *session, uint32_t *counter) {
|
||||
if (n < COOP_ENV_OVERHEAD + 1 || p[0] != COOP_ENV_V1) return 0;
|
||||
*session = get64(p + 1);
|
||||
*counter = get32(p + 9);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int coop_open(const uint8_t *p, size_t n, const uint8_t key[COOP_MSG_KEY_LEN], uint8_t src, uint8_t dst, uint8_t *kind,
|
||||
uint8_t *out, size_t cap, size_t *nout) {
|
||||
uint64_t session;
|
||||
uint32_t counter;
|
||||
if (!coop_envelope_peek(p, n, &session, &counter)) return 0;
|
||||
size_t len = n - COOP_ENV_OVERHEAD; // kind and bytes
|
||||
uint8_t plain[COOP_MAX_PAYLOAD], nonce[24], ad[2] = {dst, COOP_ENV_V1};
|
||||
if (len > sizeof plain || cap < len - 1) return 0;
|
||||
env_nonce(nonce, session, counter, src);
|
||||
if (crypto_aead_unlock(plain, p + n - COOP_ENV_MAC, key, nonce, ad, sizeof ad, p + COOP_ENV_HDR, len)) return 0;
|
||||
*kind = plain[0];
|
||||
if (len > 1) memcpy(out, plain + 1, len - 1);
|
||||
*nout = len - 1;
|
||||
crypto_wipe(plain, len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ---- signatures
|
||||
|
||||
void coop_sign_keypair(const uint8_t seed[32], uint8_t sk[COOP_SK_LEN], uint8_t pk[COOP_PK_LEN]) {
|
||||
uint8_t s[32];
|
||||
memcpy(s, seed, sizeof s); // the library wipes the seed it is given
|
||||
crypto_eddsa_key_pair(sk, pk, s);
|
||||
}
|
||||
|
||||
void coop_sign(uint8_t sig[COOP_SIG_LEN], const uint8_t sk[COOP_SK_LEN], const void *msg, size_t n) {
|
||||
crypto_eddsa_sign(sig, sk, msg, n);
|
||||
}
|
||||
|
||||
int coop_sign_check(const uint8_t sig[COOP_SIG_LEN], const uint8_t pk[COOP_PK_LEN], const void *msg, size_t n) {
|
||||
return crypto_eddsa_check(sig, pk, msg, n) == 0;
|
||||
}
|
||||
|
||||
void coop_blake2b(uint8_t *out, size_t outlen, const void *key, size_t klen, const void *msg, size_t n) {
|
||||
crypto_blake2b_keyed(out, outlen, key, klen, msg, n);
|
||||
}
|
||||
|
||||
// ---- POS
|
||||
|
||||
static void putf(uint8_t *p, float f) {
|
||||
uint32_t v;
|
||||
memcpy(&v, &f, 4);
|
||||
put32(p, v);
|
||||
}
|
||||
|
||||
// The f32 at p into *f; 0 when it is an infinity or a NaN (all exponent bits set), which a pose never holds.
|
||||
static int getf(const uint8_t *p, float *f) {
|
||||
uint32_t v = get32(p);
|
||||
memcpy(f, &v, 4);
|
||||
return (v & 0x7f800000u) != 0x7f800000u;
|
||||
}
|
||||
|
||||
// 1 when p[0..n) is printable ASCII: a POS's names reach the log and the game's animation lookup.
|
||||
static int printable(const uint8_t *p, size_t n) {
|
||||
for (size_t i = 0; i < n; i++)
|
||||
if (p[i] < 0x20 || p[i] > 0x7e) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
enum { POS_HEAD = 11 }; // version, pseq, t_ms, flags, area length
|
||||
|
||||
size_t coop_pos_pack(uint8_t *out, size_t cap, const CoopPos *p) {
|
||||
size_t alen = bounded_len(p->area, COOP_POS_TEXT), n = POS_HEAD + alen + 17;
|
||||
int slots = p->nslots < COOP_POS_SLOTS ? p->nslots : COOP_POS_SLOTS;
|
||||
for (int i = 0; i < slots; i++) n += 1 + bounded_len(p->slot[i].node, COOP_POS_TEXT) + 4;
|
||||
if (cap < n) return 0;
|
||||
out[0] = COOP_POS_VERSION;
|
||||
put32(out + 1, p->pseq);
|
||||
put32(out + 5, p->t_ms);
|
||||
out[9] = p->flags, out[10] = (uint8_t)alen;
|
||||
memcpy(out + POS_HEAD, p->area, alen);
|
||||
uint8_t *q = out + POS_HEAD + alen;
|
||||
for (int k = 0; k < 3; k++) putf(q + 4 * k, p->pos[k]);
|
||||
putf(q + 12, p->yaw);
|
||||
q[16] = (uint8_t)slots, q += 17;
|
||||
for (int i = 0; i < slots; i++) {
|
||||
size_t len = bounded_len(p->slot[i].node, COOP_POS_TEXT);
|
||||
q[0] = (uint8_t)len;
|
||||
memcpy(q + 1, p->slot[i].node, len);
|
||||
putf(q + 1 + len, p->slot[i].frame);
|
||||
q += 1 + len + 4;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int coop_pos_parse(const uint8_t *p, size_t n, CoopPos *out) {
|
||||
if (n < POS_HEAD || p[0] != COOP_POS_VERSION || p[10] > COOP_POS_TEXT || n < POS_HEAD + p[10] + 17u ||
|
||||
!printable(p + POS_HEAD, p[10]))
|
||||
return 0;
|
||||
CoopPos r;
|
||||
memset(&r, 0, sizeof r);
|
||||
r.pseq = get32(p + 1), r.t_ms = get32(p + 5), r.flags = p[9];
|
||||
memcpy(r.area, p + POS_HEAD, p[10]);
|
||||
size_t at = POS_HEAD + (size_t)p[10];
|
||||
int finite = 1;
|
||||
for (int k = 0; k < 3; k++) finite &= getf(p + at + 4 * k, &r.pos[k]);
|
||||
finite &= getf(p + at + 12, &r.yaw);
|
||||
r.nslots = p[at + 16], at += 17;
|
||||
if (!finite || r.nslots > COOP_POS_SLOTS) return 0;
|
||||
for (int i = 0; i < r.nslots; i++) {
|
||||
if (at >= n || p[at] > COOP_POS_TEXT || at + 1 + p[at] + 4 > n || !printable(p + at + 1, p[at]) ||
|
||||
!getf(p + at + 1 + p[at], &r.slot[i].frame))
|
||||
return 0;
|
||||
memcpy(r.slot[i].node, p + at + 1, p[at]);
|
||||
at += 1u + p[at] + 4;
|
||||
}
|
||||
if (at != n) return 0;
|
||||
*out = r;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int coop_pos_fresh(CoopPosSeen *s, uint64_t session, uint32_t pseq, uint64_t now_ms) {
|
||||
int again = !s->any || s->session != session || now_ms - s->at_ms >= COOP_POS_QUIET_MS;
|
||||
if (!again && pseq <= s->last) return 0;
|
||||
s->any = 1, s->session = session, s->last = pseq, s->at_ms = now_ms;
|
||||
return again ? 2 : 1;
|
||||
}
|
||||
|
||||
uint32_t coop_offer_shown(const CoopOffer *o, int (*accepted)(const char *key, void *user), void *user) {
|
||||
uint32_t shown = 0;
|
||||
for (int i = 0; i < o->n && i < COOP_MAX_MEMBERS; i++) {
|
||||
const CoopOfferMember *m = &o->member[i];
|
||||
if (m->id >= 1 && m->id <= COOP_MAX_MEMBERS && m->heard && !m->removed && !m->accepted_as[0] && m->key[0] &&
|
||||
accepted(m->key, user))
|
||||
shown |= 1u << m->id;
|
||||
}
|
||||
return shown;
|
||||
}
|
||||
@@ -1,209 +0,0 @@
|
||||
// The co-op wire format, as pure functions on bytes: no sockets, no threads, no game state. docs/coop.md ("The room's
|
||||
// secret and the wire") is the description a reviewer checks this file against.
|
||||
//
|
||||
// A room is named by a secret the players share out of band: 18 characters of a 27-symbol alphabet (85 bits), shown
|
||||
// XXXXXX-XXXXXX-XXXXXX. The relay never sees it. Two values are derived from it with keyed BLAKE2b (the key is the
|
||||
// secret's 18 canonical characters): the room's locator (16 bytes), which the relay knows the room by and which keys
|
||||
// the tag of every datagram between a client and the relay, and the message key (32 bytes), which seals every message
|
||||
// between the players (XChaCha20-Poly1305), so that the relay and anyone on the path can neither read nor change nor
|
||||
// make one.
|
||||
//
|
||||
// A datagram is a 24-byte header (little-endian) and a payload; the header carries an 8-byte tag, the start of an
|
||||
// HMAC-SHA256 over the first 16 header bytes and the payload, keyed with the locator. The client and relay messages
|
||||
// are CONNECT .. LEAVE and KICK (tools/coop_relay.py, the same format in Python); DATA carries a sealed player message:
|
||||
// the envelope (sender's session, counter) and, sealed, one kind byte and the message bytes the layers above coop.c
|
||||
// define. tests/coop_vectors.txt holds byte vectors that this file and the relay's Python are checked against
|
||||
// (--probe-coop, tests/coop_relay_test.py). Every parser checks every length against the bytes it was given and fails
|
||||
// closed.
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum {
|
||||
COOP_MAGIC = 0x434E, // bytes 4E 43
|
||||
COOP_PROTO = 2, // protocol major: a relay and a client talk only when it is equal
|
||||
COOP_HDR_LEN = 24,
|
||||
COOP_MAX_DGRAM = 1200, // a datagram's size at most: it crosses any path without fragmenting
|
||||
COOP_MAX_PAYLOAD = COOP_MAX_DGRAM - COOP_HDR_LEN,
|
||||
COOP_TAG_LEN = 8,
|
||||
COOP_KEY_LEN = 16, // the locator, which keys the tags
|
||||
COOP_MSG_KEY_LEN = 32,
|
||||
COOP_DST_ALL = 0xFF, // dst: every other member of the room
|
||||
COOP_SECRET_LEN = 18, // characters of a room secret
|
||||
COOP_SECRET_TEXT = COOP_SECRET_LEN + 2, // shown with two '-'
|
||||
COOP_MAX_MEMBERS = 8,
|
||||
COOP_NAME_MAX = 24, // a player's name in bytes of UTF-8
|
||||
COOP_COOKIE_LEN = 16,
|
||||
COOP_CONNECT_MIN = 64, // a CONNECT datagram's smallest size, so that no answer to it is larger
|
||||
COOP_ENV_V1 = 1, // the envelope of a player message
|
||||
COOP_ENV_HDR = 13, // u8 envelope version, u64 session, u32 counter
|
||||
COOP_ENV_MAC = 16,
|
||||
COOP_ENV_OVERHEAD = COOP_ENV_HDR + COOP_ENV_MAC,
|
||||
COOP_MAX_MESSAGE = COOP_MAX_PAYLOAD - COOP_ENV_OVERHEAD - 1, // a player message's bytes after its kind, at most
|
||||
};
|
||||
|
||||
// Datagram types. CONNECT .. LEAVE and KICK are between a client and the relay, DATA carries the players' messages.
|
||||
enum { COOP_T_CONNECT = 1, COOP_T_CHALLENGE = 2, COOP_T_JOINED = 3, COOP_T_ERROR = 5, COOP_T_ROSTER = 6, COOP_T_PING = 7,
|
||||
COOP_T_PONG = 8, COOP_T_LEAVE = 9, COOP_T_KICK = 11, COOP_T_DATA = 0x10 };
|
||||
enum { COOP_INTENT_CREATE = 1, COOP_INTENT_JOIN = 2 }; // CONNECT: make the room of a locator or join it
|
||||
enum { COOP_E_NO_ROOM = 1, COOP_E_ROOM_FULL = 2, COOP_E_PROTO = 3, COOP_E_RATE = 4, COOP_E_BAD_TAG = 5, COOP_E_SERVER_FULL = 6,
|
||||
COOP_E_ROOM_EXISTS = 7, COOP_E_REMOVED = 8, COOP_E_SESSION_USED = 9 }; // 9: a session used in the room before
|
||||
enum { COOP_FLAG_AWAY = 1, COOP_FLAG_MAKER = 2 }; // roster flags: not heard from for a while; made the room
|
||||
|
||||
// The kinds of player messages (the first byte of a sealed message). coop.c only carries them; HELLO, POS, DIGEST,
|
||||
// SECTION, SYNC_NEED and NOTICE belong to the layers that send them. A kind of 0xF0 and above is free for tests.
|
||||
enum { COOP_K_HELLO = 1, COOP_K_POS = 2, COOP_K_DIGEST = 3, COOP_K_SECTION = 4, COOP_K_SYNC_NEED = 5, COOP_K_NOTICE = 6,
|
||||
COOP_K_BYE = 7, COOP_K_TEST = 0xF0 };
|
||||
|
||||
typedef struct {
|
||||
uint8_t ver, type;
|
||||
uint8_t src, dst; // member ids 1..8; src 0 is the relay; dst COOP_DST_ALL: every other member
|
||||
uint16_t len; // payload bytes
|
||||
uint32_t room, seq; // room 0 until joined; seq counts the sender's datagrams
|
||||
} CoopHdr;
|
||||
|
||||
// ---- room secrets: 18 characters of "23456789BCDFGHJKMNPRSTVWXYZ" (27 symbols, 85.6 bits; no vowels, 0/1/O/I/L, Q or
|
||||
// E, so a secret spoken or typed does not read as a word), shown as XXXXXX-XXXXXX-XXXXXX. Any ASCII case, '-' and spaces
|
||||
// ignored. 1 and the canonical 18 characters plus a NUL in out when text is a secret.
|
||||
int coop_secret_normalize(const char *text, char out[COOP_SECRET_LEN + 1]);
|
||||
void coop_secret_format(const char secret[COOP_SECRET_LEN], char out[COOP_SECRET_TEXT + 1]);
|
||||
// A new secret from 32 random bytes (each symbol from one byte below 243, the rest skipped); 0 when they ran out.
|
||||
int coop_secret_from_random(const uint8_t random[32], char out[COOP_SECRET_LEN + 1]);
|
||||
// The secret's first characters and an ellipsis, for logs: "XXX…".
|
||||
void coop_secret_short(const char secret[COOP_SECRET_LEN], char out[8]);
|
||||
|
||||
// ---- keys. BLAKE2b keyed with the secret's canonical characters: locator = BLAKE2b-128("nx2navi-coop/2 room"),
|
||||
// message key = BLAKE2b-256("nx2navi-coop/2 messages"). The tag of a datagram: HMAC-SHA256(locator, header[0:16] +
|
||||
// payload)[0:8].
|
||||
void coop_hmac_sha256(const void *key, size_t klen, const void *a, size_t an, const void *b, size_t bn, uint8_t out[32]);
|
||||
void coop_room_keys(const char secret[COOP_SECRET_LEN], uint8_t locator[COOP_KEY_LEN], uint8_t msg_key[COOP_MSG_KEY_LEN]);
|
||||
|
||||
// ---- datagrams
|
||||
// The datagram of hdr (its len is ignored: n is the payload length) and payload into out. key NULL: a zero tag (what a
|
||||
// relay of another protocol version answers). Bytes written, 0 when it does not fit cap or n is too long.
|
||||
size_t coop_dgram_pack(uint8_t *out, size_t cap, const CoopHdr *hdr, const void *payload, size_t n,
|
||||
const uint8_t key[COOP_KEY_LEN]);
|
||||
// 1 when d is exactly one datagram of this format (magic, a length that matches); *payload points into d. The version
|
||||
// and the tag are not checked here.
|
||||
int coop_dgram_parse(const uint8_t *d, size_t n, CoopHdr *hdr, const uint8_t **payload);
|
||||
// 1 when the tag of the parsed datagram d (n bytes) is the one key makes; time independent of where they differ.
|
||||
int coop_dgram_verify(const uint8_t *d, size_t n, const uint8_t key[COOP_KEY_LEN]);
|
||||
int coop_dgram_tag_zero(const uint8_t *d);
|
||||
|
||||
// ---- names: a player's name from untrusted bytes. At most COOP_NAME_MAX bytes of valid UTF-8; a control character
|
||||
// (C0, DEL, C1) and each byte that is not valid UTF-8 become '?', and so do the characters that reorder text (bidi
|
||||
// controls). out is NUL-terminated (cap at least COOP_NAME_MAX + 1); the length.
|
||||
size_t coop_name_clean(char *out, size_t cap, const uint8_t *raw, size_t n);
|
||||
|
||||
// ---- client and relay messages
|
||||
// CONNECT: u8 intent, u8 flags, u8[16] locator, u64 client id, u64 session, u64 nonce, u8 name length, name,
|
||||
// u8[16] cookie (zero, or the CHALLENGE's), u8[16] rejoin token (zero, or the JOINED's of this room).
|
||||
typedef struct {
|
||||
uint8_t intent, flags;
|
||||
uint8_t locator[COOP_KEY_LEN];
|
||||
uint64_t client_id; // random for each start of the game; the relay knows a rejoin of the same member by it
|
||||
uint64_t session; // random for each join: the others take messages only of the session the roster names
|
||||
uint64_t nonce; // random for each attempt: every answer carries it
|
||||
char name[COOP_NAME_MAX + 1];
|
||||
uint8_t cookie[COOP_COOKIE_LEN], token[COOP_COOKIE_LEN];
|
||||
} CoopConnect;
|
||||
size_t coop_connect_pack(uint8_t *out, size_t cap, const CoopConnect *c); // zero-padded to COOP_CONNECT_MIN as a datagram
|
||||
int coop_connect_parse(const uint8_t *p, size_t n, CoopConnect *c);
|
||||
|
||||
// CHALLENGE: u64 nonce, u8[16] cookie.
|
||||
size_t coop_challenge_pack(uint8_t *out, size_t cap, uint64_t nonce, const uint8_t cookie[COOP_COOKIE_LEN]);
|
||||
int coop_challenge_parse(const uint8_t *p, size_t n, uint64_t *nonce, uint8_t cookie[COOP_COOKIE_LEN]);
|
||||
|
||||
// ROSTER: u8 n, n x (u8 id, u8 flags, u64 session, u8 name length, name).
|
||||
typedef struct { uint8_t id, flags; uint64_t session; char name[COOP_NAME_MAX + 1]; } CoopMemberInfo;
|
||||
typedef struct { uint8_t n; CoopMemberInfo m[COOP_MAX_MEMBERS]; } CoopRoster;
|
||||
size_t coop_roster_pack(uint8_t *out, size_t cap, const CoopRoster *r);
|
||||
// used (may be NULL): the bytes the roster took.
|
||||
int coop_roster_parse(const uint8_t *p, size_t n, CoopRoster *r, size_t *used);
|
||||
|
||||
// JOINED: u8 member, u64 nonce, u8[16] rejoin token, roster.
|
||||
typedef struct { uint8_t member; uint64_t nonce; uint8_t token[COOP_COOKIE_LEN]; CoopRoster roster; } CoopJoined;
|
||||
size_t coop_joined_pack(uint8_t *out, size_t cap, const CoopJoined *j);
|
||||
int coop_joined_parse(const uint8_t *p, size_t n, CoopJoined *j);
|
||||
|
||||
// ERROR: u8 reason, u64 nonce (of the CONNECT it answers, 0 else), u8 text length, text.
|
||||
typedef struct { uint8_t reason; uint64_t nonce; char text[61]; } CoopError; // text for the log, at most 60 bytes
|
||||
size_t coop_error_pack(uint8_t *out, size_t cap, const CoopError *e);
|
||||
int coop_error_parse(const uint8_t *p, size_t n, CoopError *e);
|
||||
|
||||
// KICK (the room's maker to the relay): u8 member, u64 its session.
|
||||
size_t coop_kick_pack(uint8_t *out, size_t cap, uint8_t member, uint64_t session);
|
||||
int coop_kick_parse(const uint8_t *p, size_t n, uint8_t *member, uint64_t *session);
|
||||
|
||||
size_t coop_u32_pack(uint8_t *out, size_t cap, uint32_t v); // PING and PONG: the token
|
||||
int coop_u32_parse(const uint8_t *p, size_t n, uint32_t *v);
|
||||
|
||||
// ---- player messages: the payload of a DATA datagram, sealed with the message key.
|
||||
// u8 envelope version (COOP_ENV_V1), u64 sender's session, u32 counter, ciphertext of (u8 kind, bytes), u8[16] tag
|
||||
// XChaCha20-Poly1305: nonce = session (8 bytes LE), counter (4 LE), src (1), 11 zero bytes; associated data = dst and
|
||||
// the envelope version. A session and counter are used once (a new session for every join, the counter from 1), so a
|
||||
// nonce never repeats under the room's key. A later envelope version can carry other fields; the kind byte and the
|
||||
// message inside stay as they are, so a new kind (a pose, say) only needs a number.
|
||||
// Seal: the payload into out (cap); its length, 0 when n is above COOP_MAX_MESSAGE or it does not fit.
|
||||
size_t coop_seal(uint8_t *out, size_t cap, const uint8_t key[COOP_MSG_KEY_LEN], uint8_t src, uint8_t dst, uint64_t session,
|
||||
uint32_t counter, uint8_t kind, const void *bytes, size_t n);
|
||||
// The envelope's clear fields; 0 when p is not an envelope of a version this build reads.
|
||||
int coop_envelope_peek(const uint8_t *p, size_t n, uint64_t *session, uint32_t *counter);
|
||||
// Open: 1 and the kind and bytes (into out, cap at least n) when the tag is right for this key, src and dst.
|
||||
int coop_open(const uint8_t *p, size_t n, const uint8_t key[COOP_MSG_KEY_LEN], uint8_t src, uint8_t dst, uint8_t *kind,
|
||||
uint8_t *out, size_t cap, size_t *nout);
|
||||
|
||||
// ---- signatures: EdDSA over Curve25519 with BLAKE2b (the library's crypto_eddsa). The room's message key cannot tell
|
||||
// one member from another, and the sync layer's state travels through every member, so what only one member may make
|
||||
// is signed with that member's key: its identity in the room, the maker's rules, and each pool contributor's counts
|
||||
// (coop_state.c). Every member can then pass them on, and nobody but the key's holder can make or change them.
|
||||
enum { COOP_PK_LEN = 32, COOP_SK_LEN = 64, COOP_SIG_LEN = 64 };
|
||||
void coop_sign_keypair(const uint8_t seed[32], uint8_t sk[COOP_SK_LEN], uint8_t pk[COOP_PK_LEN]);
|
||||
void coop_sign(uint8_t sig[COOP_SIG_LEN], const uint8_t sk[COOP_SK_LEN], const void *msg, size_t n);
|
||||
int coop_sign_check(const uint8_t sig[COOP_SIG_LEN], const uint8_t pk[COOP_PK_LEN], const void *msg, size_t n); // 1: valid
|
||||
// BLAKE2b of msg keyed with key (klen at most 64, 0 for none), outlen bytes (1 to 64): the sync layer's derivations.
|
||||
void coop_blake2b(uint8_t *out, size_t outlen, const void *key, size_t klen, const void *msg, size_t n);
|
||||
|
||||
// ---- POS (COOP_K_POS): where a player is and what Link plays, for showing the other players (nothing sends it in this build), meant to be sent about 15
|
||||
// times a second as a sealed player message (above). The bytes after the kind, little endian: u8 version
|
||||
// (COOP_POS_VERSION), u32 pseq (the sender's counter: one more for each POS it sends), u32 t_ms (the sender's clock), u8
|
||||
// flags, u8 area length (<= COOP_POS_TEXT) and the area's name (the game's current-area text), f32 x y z, f32 yaw
|
||||
// (radians, 0 facing +z), u8 slot count (<= COOP_POS_SLOTS), per AS slot u8 node name length (<= COOP_POS_TEXT), the
|
||||
// node's name, f32 frame. A parser takes exactly one message of its version: another version is another format this
|
||||
// build cannot read (version 1 had a u16 pseq). The names come from another player's game and reach this one's log and
|
||||
// its animation lookup, so a name with a byte outside printable ASCII (0x20..0x7e) is refused, and so is a number that
|
||||
// is not finite.
|
||||
#define COOP_POS_VERSION 2
|
||||
#define COOP_POS_TEXT 47
|
||||
#define COOP_POS_SLOTS 4
|
||||
enum { COOP_POS_ADULT = 1, COOP_POS_IN_WORLD = 2 };
|
||||
typedef struct {
|
||||
uint32_t pseq;
|
||||
uint32_t t_ms;
|
||||
uint8_t flags, nslots;
|
||||
char area[COOP_POS_TEXT + 1];
|
||||
float pos[3], yaw;
|
||||
struct { char node[COOP_POS_TEXT + 1]; float frame; } slot[COOP_POS_SLOTS];
|
||||
} CoopPos;
|
||||
size_t coop_pos_pack(uint8_t *out, size_t cap, const CoopPos *p); // 0 when it does not fit cap
|
||||
int coop_pos_parse(const uint8_t *p, size_t n, CoopPos *out);
|
||||
|
||||
// The receiver's counter of one POS sender (coop.h: a handler is not called once only). A pose is taken only above the
|
||||
// last one taken from the same member id in the same session, so neither a pose sent again nor one recorded earlier
|
||||
// in the session moves the puppet back while that sender's poses keep being taken; the first pose of another session
|
||||
// (another player given the id, the member back in a new session, or a roster that lists an earlier session) starts the
|
||||
// counter again. After COOP_POS_QUIET_MS with none taken (below), whoever holds the sender's datagrams back that long can
|
||||
// send its recorded poses of the session again (no secret needed), and they are taken: only the puppet moves. Someone
|
||||
// with the room's secret can seal a POS in a member's name with a counter far ahead: it becomes the newest pose, so the
|
||||
// puppet stands where it says (or is hidden, if it names another area) and the member's own poses are kept out until
|
||||
// nothing was taken from the sender for COOP_POS_QUIET_MS; then the next pose is taken whatever its counter and starts
|
||||
// the counter again. One forged pose every COOP_POS_QUIET_MS keeps the member's own out while the forger goes on.
|
||||
// session: the one the roster lists for the member (CoopView). Returns 0 to drop the pose, 1 to take it, 2 to take it
|
||||
// and drop what was kept of the sender's earlier poses.
|
||||
#define COOP_POS_QUIET_MS 3000
|
||||
typedef struct {
|
||||
uint64_t session, at_ms; // the session of the last pose taken, and when it was taken
|
||||
uint32_t last; // its counter
|
||||
int any; // a pose was taken
|
||||
} CoopPosSeen;
|
||||
int coop_pos_fresh(CoopPosSeen *s, uint64_t session, uint32_t pseq, uint64_t now_ms);
|
||||
2107
runtime/coop_state.c
2107
runtime/coop_state.c
File diff suppressed because it is too large
Load Diff
@@ -1,277 +0,0 @@
|
||||
// Co-op progress sync: the merge engine, without the game. Each player's game reports its flags here (coop_game.c reads
|
||||
// them from the game's flag database); the engine keeps the merged state of the room, gossips it between the players
|
||||
// (coop.c carries the messages) and hands back what the local game lacks. It knows flags only as (category, 32-bit hash,
|
||||
// value), so the probe drives it with a fake flag store.
|
||||
//
|
||||
// The state is a set of registers, each merged by keeping the highest value: a flag's register holds 1 for a flag that
|
||||
// changed from its default (it stays changed), or the count of an item (the highest wins). Merging is commutative,
|
||||
// associative and idempotent, so lost, repeated and reordered messages do no harm, and nothing a player has shrinks.
|
||||
// Spendable counters (rupees, ammunition, small keys) in a shared pool are records, one per contributor (a member's
|
||||
// identity) and pool: the base it brought when it joined the pool, and the units it gained and spent, signed with the
|
||||
// member's key, so every member passes them on and nobody but their owner can change them. The pool's value is the
|
||||
// highest base (at least 0) + all gains - all spends, where no contributor's spends count beyond its own gains plus the
|
||||
// counter's limit: a contributor can take at most what the pool can hold. Only identities the maker admitted
|
||||
// contribute, and a game counts only the records of the keys its own player accepted (and its own). A game remembers
|
||||
// what it joined a pool with and the records it saw then, and makes its claim again when the records it counts change
|
||||
// (a removal, or its player accepting more keys), so a removed player takes no keys another player brought.
|
||||
//
|
||||
// Gossip. Registers are split into COOP_SYNC_SECTIONS sections by hash; a DIGEST carries a sum per section (and the
|
||||
// room's rules), every 2 s and at once to a member who joins; a section whose sum differs from a peer's is sent to it in
|
||||
// SYNC messages, so two players converge within a few digests and a late joiner catches up with everything. A local
|
||||
// change goes out at once and again 80 and 250 ms later. Sending is paced (32 KB/s) under the relay's per-member limit.
|
||||
// Every SECTION (a push or an answer) carries its sender's signature over the room, its member id and session, a
|
||||
// counter and its bytes, checked before anything of it counts: the room's message key, which every holder of the
|
||||
// secret has (a relay run by one, a sender on a player's network), makes no values in a member's name.
|
||||
//
|
||||
// Identities. Each game has a signing key for each room and start of the game (from coop_sync_seed's random value and the
|
||||
// room's secret; the room's maker keeps one per room across starts, coop_sync_room_seed), and signs its identity in that
|
||||
// room: the key, the name, the session the relay lists for it and its session in the room before that one. A game takes
|
||||
// values only from a member whose identity it checked, an identity is bound to one session, and a session a member's
|
||||
// later identity names as the one before is never taken again, so an identity cannot be copied or reused by another
|
||||
// member; nothing else (a roster, a lost room) ends a session, since anyone on the path can send those. A signature
|
||||
// that fails its check counts against the member that sent it, as a refused value does (a section's against the
|
||||
// member's budget of checks only: someone else made it), and each member gets a bounded number of checks a second.
|
||||
//
|
||||
// Rules belong to the room: every game merges the same way. The maker's game signs a charter: the rules (the maker's
|
||||
// settings, coop_sync_settings), the identities admitted to the pools, the identities removed and the pools' epoch,
|
||||
// with an epoch it raises at each change; it rides in every DIGEST, so every member passes it on. A game takes a
|
||||
// charter only signed by the key it pinned when its player accepted the room (coop_sync_accept); before that, its own
|
||||
// for a room it made in this session; else the key of the member the relay names as the maker, but only while no
|
||||
// identified member carries a charter of another key; else, while no maker is there, the one key every member's
|
||||
// charter carries. A member the relay marks later (a restart, a hostile relay) changes nothing for a player who
|
||||
// accepted. A category switched to shared starts merging (its digest sums differ, the sections are exchanged); one
|
||||
// switched to per player stops; what was merged stays. A removed identity's messages are ignored and its records
|
||||
// dropped everywhere, and each game keeps every removal it saw in the room; a pool reset starts a new pools' epoch in
|
||||
// which the games join the pools again with what each held for the identities the reset admits.
|
||||
//
|
||||
// Acceptance. Flags are taken (stored, passed on, applied) only from a member whose key this player accepted in this
|
||||
// room: what a member brings that the player did not accept never enters this game's state. Acceptance is transitive:
|
||||
// a member the player accepted passes on what it took from members it accepted. Pool records are stored and passed on
|
||||
// as the maker admits them, so the games converge, but a pool counts only the records of keys this player accepted
|
||||
// (and its own), and joins the pools only once the player accepted the room: those are not transitive. Nothing is
|
||||
// handed to the game (coop_sync_take) until its player accepted the room as it is now (the identities in it, the
|
||||
// rules, the maker's key and the save being played: coop_sync_offer) and a copy of the save was made
|
||||
// (coop_sync_copied), and another save joins the pools only once it is accepted too; a member that is
|
||||
// present and has not identified itself after a few seconds keeps the room unaccepted. The offer's number is keyed
|
||||
// with this start's random value, so nobody can compute it in advance; it changes with any of those, and so does the
|
||||
// acceptance.
|
||||
//
|
||||
// Threads: none of its own and no lock. coop_game.c holds one lock around every call.
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// Categories of shared state (coop_game.c classifies the game's flags) and their modes.
|
||||
enum {
|
||||
COOP_CAT_PROGRESS, // story, world and dungeon flags: shared | own
|
||||
COOP_CAT_ITEMS, // equipment, key items, upgrades and capacities: shared | own
|
||||
COOP_CAT_SONGS, // shared | own
|
||||
COOP_CAT_QUEST, // medallions, stones and the other quest items: shared | own
|
||||
COOP_CAT_KEYS, // small keys, per dungeon: pool | own
|
||||
COOP_CAT_RUPEES, // own | pool
|
||||
COOP_CAT_AMMO, // own | pool
|
||||
COOP_CAT_N
|
||||
};
|
||||
enum { COOP_MODE_OWN = 0, COOP_MODE_SHARED = 1, COOP_MODE_POOL = 2 };
|
||||
|
||||
typedef struct {
|
||||
uint32_t epoch; // 0: no rules
|
||||
uint8_t maker; // the member whose rules they are (this game's view: who sent them)
|
||||
uint8_t mode[COOP_CAT_N];
|
||||
} CoopRules;
|
||||
|
||||
const char *coop_cat_name(int cat); // "progress", ... (the settings key without "coop_")
|
||||
const char *coop_mode_name(int mode); // "own", "shared", "pool"
|
||||
int coop_cat_is_pool(int cat); // keys, rupees, ammo: own | pool; the others own | shared
|
||||
// The defaults: everything shared, keys in a pool, rupees and ammunition per player.
|
||||
void coop_rules_default(CoopRules *r);
|
||||
// Makes r a set the engine can run: a mode a category does not have becomes its default; with progress per player, keys
|
||||
// are per player too (a pool would pay twice for a key each world still holds); with progress shared, items, songs and
|
||||
// quest items are shared (per player, the one who took one from the shared world would leave the others without it).
|
||||
// The categories it changed, as a bit mask.
|
||||
unsigned coop_rules_normalize(CoopRules *r);
|
||||
// "progress shared, items shared, ..." into out.
|
||||
void coop_rules_text(const CoopRules *r, char *out, size_t cap);
|
||||
|
||||
// Register kinds on the wire (2 to 4 were protocol 2's unsigned pool registers).
|
||||
enum { COOP_R_FLAG = 1, COOP_R_POOL = 5 };
|
||||
enum { COOP_SYNC_SECTIONS = 64, COOP_K_DIGEST_VER = 4 }; // 4: signed sections, identities that name the session before
|
||||
|
||||
typedef struct CoopSync CoopSync;
|
||||
// self_id: random for this start of the game (contributor ids derive from it). schema: games merge only with the same
|
||||
// (this layer's version, the game's, and the classified table); 0 until the table is known.
|
||||
CoopSync *coop_sync_new(uint64_t self_id, uint32_t schema);
|
||||
void coop_sync_free(CoopSync *s);
|
||||
// Trace lines (sent, received, by hash and value) go to fn when set.
|
||||
void coop_sync_trace(CoopSync *s, void (*fn)(void *user, const char *line), void *user);
|
||||
// What the local game takes from the room: the highest value of flag or counter (cat, hash), 0 when this game does not
|
||||
// share that hash in that category (a flag: 1 for a Bool; a pool counter: what the game can show). Every value a
|
||||
// member sends is checked against it before it is stored or passed on; one that fails is dropped and counted, and a
|
||||
// member that sends many is ignored while it stays in the room. Called with the engine's lock held; no limits, nothing
|
||||
// is taken.
|
||||
typedef uint32_t (*CoopSyncLimitFn)(int cat, uint32_t hash, void *user);
|
||||
void coop_sync_limits(CoopSync *s, CoopSyncLimitFn fn, void *user);
|
||||
// A random key of this process for the register index (SipHash-2-4), so a peer cannot choose where its registers go.
|
||||
void coop_sync_index_key(CoopSync *s, const uint8_t key[16]);
|
||||
uint64_t coop_siphash24(uint64_t k0, uint64_t k1, const uint8_t *m, size_t n);
|
||||
// The schema, once the local game's table is known: a new one forgets everything merged.
|
||||
void coop_sync_schema(CoopSync *s, uint32_t schema);
|
||||
// Members (a bit per id) whose messages are ignored for sending values this game refuses.
|
||||
unsigned coop_sync_ignored(const CoopSync *s);
|
||||
|
||||
// ---- the room (the coop thread)
|
||||
// The room and who is in it: code "" when in none. A new code (or none) forgets the peers and everything merged:
|
||||
// nothing of one room reaches the next. The acceptance, the pinned maker, the charter, the removals, the sessions that
|
||||
// ended and this game's own pool records stay while the code comes back the same (the session reached the room again);
|
||||
// another room starts them anew.
|
||||
// self: this player's member id; ids and sessions: every member's (self included: this game's own session, the one it
|
||||
// joined with, which its identity and sections are signed for; sessions NULL: each id's own number); maker: the member
|
||||
// the relay names as the room's maker, 0 when none is in the room.
|
||||
void coop_sync_room(CoopSync *s, const char *code, int self, const int *ids, const uint64_t *sessions, int n, int maker,
|
||||
uint64_t now_ms);
|
||||
// The room's own seed for this player's key in the room of that code (the maker's, kept in its profile so that its key
|
||||
// outlives a restart of the game); without it the key comes from coop_sync_seed's value of this start.
|
||||
void coop_sync_room_seed(CoopSync *s, const char *code, const uint8_t seed[32]);
|
||||
// This player's own rule settings, and whether it made the room in this session (its settings are the room's).
|
||||
void coop_sync_settings(CoopSync *s, const CoopRules *mine, int made_room);
|
||||
// A peer message (kind COOP_K_DIGEST or COOP_K_SECTION, the bytes after the kind) from member from.
|
||||
void coop_sync_receive(CoopSync *s, int from, uint8_t kind, const uint8_t *bytes, size_t n, uint64_t now_ms);
|
||||
// Timers: digests, repeated pushes, answers to digests. send(member or 0 for all, kind, bytes, n, user) queues one
|
||||
// message (1 when queued); call it every few ms.
|
||||
typedef int (*CoopSyncSendFn)(int member, uint8_t kind, const uint8_t *bytes, size_t n, void *user);
|
||||
void coop_sync_tick(CoopSync *s, uint64_t now_ms, CoopSyncSendFn send, void *user);
|
||||
// The rules in force (epoch 0: none yet; maker: the member holding the key that signed them, 0 none) and a counter
|
||||
// that changes when they do.
|
||||
unsigned coop_sync_rules(const CoopSync *s, CoopRules *out);
|
||||
|
||||
// ---- identity, the offer and acceptance
|
||||
// A random value of this start of the game: the identity keys (one per room) and the offer's number derive from it.
|
||||
void coop_sync_seed(CoopSync *s, const uint8_t seed[32]);
|
||||
void coop_sync_name(CoopSync *s, const char *name); // this player's name, signed into its identity
|
||||
// What joining the room means, for the player to accept: the other members (by the names their identities carry), the
|
||||
// rules and the key that signed them. heard: its identity was checked (a member not identified a few seconds after
|
||||
// it appeared shows with heard 0, counts in unidentified and keeps the room unaccepted); removed: the maker removed
|
||||
// it. A key the player accepted counts as accepted only under the name it signed then: under another name it is a new
|
||||
// offer (accepted_as says the name it was accepted as). No offer (token 0) outside a room, before the rules are known
|
||||
// (the members and disagree are filled in), and while a member that just appeared is not identified yet.
|
||||
typedef struct {
|
||||
int id, heard, maker, removed;
|
||||
char name[COOP_NAME_MAX + 1]; // the name it signed; "" until heard (coop_game.c shows the relay's)
|
||||
char key[20]; // its key's fingerprint, xxxx-xxxx-xxxx-xxxx; "" until heard
|
||||
char accepted_as[COOP_NAME_MAX + 1]; // its key was accepted under this other name ("" when not, or under this one)
|
||||
} CoopOfferMember;
|
||||
typedef struct {
|
||||
uint32_t token; // the offer's number, random for each start of the game; 0: none
|
||||
int accepted; // the player accepted this offer (values are applied once the copy is made: copy)
|
||||
int n; // the other members
|
||||
CoopOfferMember member[COOP_MAX_MEMBERS];
|
||||
CoopRules rules;
|
||||
char maker_key[20]; // the fingerprint of the key that signed the rules
|
||||
int maker_moved; // the relay names another member as the maker than the one whose key signs the rules
|
||||
int new_save; // another save was loaded since the last acceptance: it gets the room's progress, which holds
|
||||
// what every save played in the room brought (the last one's too)
|
||||
int copy; // the copy of the save for this acceptance: 0 not yet, 1 made, -1 failed (accept again to retry)
|
||||
int unidentified; // members in the room that never identified themselves: the room cannot be accepted meanwhile
|
||||
int disagree; // members carry rules signed by different keys (or by another than the one in force)
|
||||
} CoopOffer;
|
||||
int coop_sync_offer(CoopSync *s, CoopOffer *out, uint64_t now_ms); // 1 when there is an offer
|
||||
// Accepts the offer of that number: its identities, rules and maker's key (pinned from now on in this room). 1 when
|
||||
// token is the current offer's and no member in the room is unidentified. A copy of the save is wanted when none was
|
||||
// made for the save being played.
|
||||
int coop_sync_accept(CoopSync *s, uint32_t token);
|
||||
int coop_sync_copy_wanted(const CoopSync *s);
|
||||
void coop_sync_copied(CoopSync *s, int ok);
|
||||
// Values are handed out: the current offer is accepted and its copy made (coop_sync_take checks it itself).
|
||||
int coop_sync_open(CoopSync *s);
|
||||
// The maker's game (it holds the key the charter is signed with): removes a member in the room (by member id) or any
|
||||
// key the room knew (admitted to the pools, accepted by this player, or a member's; by key id, also once it left): its
|
||||
// identity is dropped by every game, its messages ignored, its pool records gone. Or resets the pools: a new pools'
|
||||
// epoch that admits this player and the members it accepted that are in the room, and in which every game joins the
|
||||
// pools again with what they held for those. 1 when done.
|
||||
int coop_sync_remove(CoopSync *s, int member);
|
||||
int coop_sync_remove_key(CoopSync *s, uint64_t kid);
|
||||
int coop_sync_reset_pools(CoopSync *s);
|
||||
int coop_sync_is_maker(const CoopSync *s);
|
||||
// A key's fingerprint as the offer shows it (xxxx-xxxx-xxxx-xxxx, or the 16 hex digits) into its id; 1 when it is one.
|
||||
int coop_sync_key_parse(const char *text, uint64_t *kid);
|
||||
// The identities the pools admit, with what each took beyond what it brought (per pool, what its spends took up to its
|
||||
// gains plus the counter's limit and what entered the pool, beyond its gains; summed over the pools of keys, rupees and
|
||||
// ammunition): whom a maker would remove after a drain. Their count (at most max).
|
||||
typedef struct {
|
||||
char key[20]; // its fingerprint
|
||||
int member; // its member id in the room, 0 when it is not in it
|
||||
int self; // this player's
|
||||
int removed; // the maker removed it
|
||||
char name[COOP_NAME_MAX + 1]; // the name its identity signed, while it is in the room
|
||||
int64_t spent[3]; // keys, rupees, ammunition taken beyond what it brought, in pools it took from (>= 0)
|
||||
} CoopContributor;
|
||||
int coop_sync_contributors(const CoopSync *s, CoopContributor *out, int max);
|
||||
// 1 once every peer's digest matched this player's after it joined (or it is alone): the room's pools are known.
|
||||
int coop_sync_caught_up(const CoopSync *s);
|
||||
|
||||
// ---- the local game (the game thread)
|
||||
// A save is being played (the game calls it at every bind). After the first one: another save was loaded, so
|
||||
// everything merged is forgotten, the pools bind again (this game's own pool records stay: they are the room's), and
|
||||
// the acceptance is asked again with a new copy, since the room's progress holds what the last save brought.
|
||||
void coop_sync_rebind(CoopSync *s);
|
||||
// A flag's local value: 1 for a flag that differs from its default, a count for an item. Values only grow the merged state.
|
||||
void coop_sync_local(CoopSync *s, int cat, uint32_t hash, uint32_t value, uint64_t now_ms);
|
||||
// A pool counter's local value and its cap (-1: none). Before the room is known and accepted it is only remembered;
|
||||
// then it joins the pool (the pool rises to it if lower: nothing is taken away) and each later change counts as a gain
|
||||
// or a spend.
|
||||
void coop_sync_pool_local(CoopSync *s, int cat, uint32_t hash, int32_t value, int32_t cap, uint64_t now_ms);
|
||||
|
||||
typedef struct {
|
||||
uint8_t pool; // 0: a flag (value: the merged value), 1: a pool counter (value: what to show, within its cap)
|
||||
uint8_t cat;
|
||||
uint32_t hash;
|
||||
int32_t value;
|
||||
} CoopApply;
|
||||
// Up to max values the local game should take. A flag is handed out once per merged value, so the game may lower it
|
||||
// afterwards (spend, lose) without getting it back; a pool counter until the game shows it (coop_sync_pool_wrote).
|
||||
int coop_sync_take(CoopSync *s, CoopApply *out, int max);
|
||||
// The game was given the value of a pool counter (coop_sync_take): it is the expected local value from now on.
|
||||
void coop_sync_pool_wrote(CoopSync *s, uint32_t hash, int32_t value);
|
||||
// Put a taken apply back (the game could not take it this frame).
|
||||
void coop_sync_untake(CoopSync *s, const CoopApply *a);
|
||||
|
||||
// ---- inspection (tests, logs)
|
||||
typedef struct {
|
||||
unsigned regs, synced; // registers, and those under the room's rules
|
||||
unsigned sent_msgs, recv_msgs, sent_bytes;
|
||||
unsigned merged; // registers a message raised
|
||||
unsigned pools_bound;
|
||||
unsigned rejected; // values refused (not shared here, out of range, the state full, failed record signatures)
|
||||
unsigned unaccepted; // flags dropped because their sender's key is not one this player accepted
|
||||
unsigned sig_checks; // signatures checked
|
||||
unsigned sig_skipped; // messages dropped because their sender's budget of checks was spent
|
||||
unsigned forged; // sections, and identities or charters in digests, whose signature did not check out (made
|
||||
// in a member's name by someone else); never held against that member
|
||||
unsigned replayed; // sections whose counter was taken before (sealed again by someone with the secret)
|
||||
unsigned rate_dropped; // messages over a member's rate
|
||||
unsigned probe_max; // the longest run of index slots an insert walked
|
||||
unsigned own_key; // identities of another member signed with this game's own key (a copy of its key file)
|
||||
int own_key_member; // the member that sent the last of them
|
||||
unsigned key_changes; // another key's identity for an identified member's session checked out: a dispute
|
||||
int key_change_member; // began, or the other key took the place; the member of the last of them
|
||||
unsigned key_moves; // a key this player accepted identified as another member number or under another
|
||||
int key_move_member, key_move_from; // name than before: the member it is now, the number it had (0 none)
|
||||
} CoopSyncStats;
|
||||
void coop_sync_stats(const CoopSync *s, CoopSyncStats *out);
|
||||
// The merged value of a flag (0 when absent), and a pool's value (as this game counts it) and whether it is bound.
|
||||
uint32_t coop_sync_flag(const CoopSync *s, int cat, uint32_t hash);
|
||||
int coop_sync_pool(const CoopSync *s, uint32_t hash, int64_t *value);
|
||||
// The record this game signed for a pool in the pools' epoch in force (tests): 1 when it has one.
|
||||
int coop_sync_own_record(const CoopSync *s, uint32_t hash, int32_t *base, uint32_t *gain, uint32_t *spend);
|
||||
// The record of key kid this game holds for a pool in the pools' epoch in force, and that epoch (tests).
|
||||
int coop_sync_record(const CoopSync *s, uint32_t hash, uint64_t kid, int32_t *base, uint32_t *gain, uint32_t *spend);
|
||||
uint32_t coop_sync_pool_epoch(const CoopSync *s);
|
||||
// 1 when this player accepted key kid in the room (its own key counts as accepted).
|
||||
int coop_sync_accepted_key(const CoopSync *s, uint64_t kid);
|
||||
// A SECTION message of n bytes in msg (cap at most) as this game sends one: its next counter and its signature for its
|
||||
// member id and session appended (tests that hand an engine what a member sends). The new length, 0 when it does not fit.
|
||||
size_t coop_sync_sign_section(CoopSync *s, uint8_t *msg, size_t n, size_t cap);
|
||||
// The digest sums, for tests: two engines with equal sums hold the same synced state.
|
||||
void coop_sync_sums(const CoopSync *s, uint32_t out[COOP_SYNC_SECTIONS]);
|
||||
|
||||
int probe_coop_sync(void); // coop_sync_probe.c: the engine's part of --probe-coop; failures
|
||||
File diff suppressed because it is too large
Load Diff
@@ -495,6 +495,8 @@ static int text_get(const char *name, char out[64]) {
|
||||
}
|
||||
|
||||
// A text written into the entry's own buffers (game thread). 0: the game has no such text.
|
||||
int dbg_area(char out[64]) { return dbg_supported() && text_get("Sequence_CurrentBanc", out) && out[0]; }
|
||||
|
||||
static int text_set(const char *name, const char *value) {
|
||||
uint64_t e = gmd_entry(GD_TEXT64, 0x108, hash_of(name)), text = e ? rd_ptr(e + 0x68) : 0, other = e ? rd_ptr(e + 0x18) : 0;
|
||||
int32_t room = 0;
|
||||
|
||||
@@ -16,6 +16,7 @@ extern "C" {
|
||||
int dbg_supported(void); // this game build's structures are known (Ocarina of Time 1.1.1)
|
||||
|
||||
int dbg_player_pos(float xyz[3]); // Link's position in metres; 0 while there is no player
|
||||
int dbg_area(char out[64]); // the area the game is in, by its name in the game's files; 0 unknown
|
||||
float dbg_speed_factor(void); // the game's speed: 1 normal, 0.05 to 8 (frame_rate.c multiplies the game's step)
|
||||
void dbg_speed_set(float factor);
|
||||
|
||||
|
||||
@@ -81,10 +81,7 @@ const char *fs_save_import_done(void); // the backup of the
|
||||
// "-" when there was none, "" when no import ran
|
||||
// A copy of the newest committed save (every slot) in <profile>/<folder>/<UTC time>/, flushed, taken while no Commit
|
||||
// runs; the newest keep copies stay. prefix (NULL: none) goes before the time, and a copy whose name it begins is
|
||||
// never pruned: the copy from before a co-op room, say, outlasts the ones made later. 1 and the copy's path in out
|
||||
// never pruned, so a first copy outlasts the ones made later. 1 and the copy's path in out
|
||||
// (empty when nothing is saved yet: nothing to copy), 0 when it could not be made (logged). Slow (the whole save): not
|
||||
// on the game's thread.
|
||||
int fs_save_snapshot(const char *folder, const char *prefix, int keep, char *out, size_t cap);
|
||||
// <profile>/rel into out: a file of the profile folder beside the saves (the co-op maker's room keys). 0 when there is
|
||||
// no profile folder or the path does not fit.
|
||||
int fs_profile_path(const char *rel, char *out, size_t cap);
|
||||
|
||||
@@ -600,11 +600,6 @@ void fs_save_crash_wait(void) {
|
||||
(unsigned long long)(plat_now_ms() - t0));
|
||||
}
|
||||
|
||||
int fs_profile_path(const char *rel, char *out, size_t cap) {
|
||||
if (cap) out[0] = 0;
|
||||
return *profile && snprintf(out, cap, "%s/%s", profile, rel) < (int)cap;
|
||||
}
|
||||
|
||||
int fs_save_snapshot(const char *folder, const char *prefix, int keep, char *out, size_t cap) {
|
||||
char root[1100];
|
||||
if (cap) out[0] = 0;
|
||||
@@ -2076,10 +2071,10 @@ static void probe_storage(void) {
|
||||
|
||||
// copies of the save: the first one, prefixed, outlasts the rotation of the later ones
|
||||
char first[PLAT_PATH_MAX], later[PLAT_PATH_MAX];
|
||||
int copies = fs_save_snapshot("coop-backup", "first-", 3, first, sizeof first);
|
||||
for (int i = 0; i < 6; i++) copies += fs_save_snapshot("coop-backup", NULL, 3, later, sizeof later);
|
||||
int copies = fs_save_snapshot("save-copies", "first-", 3, first, sizeof first);
|
||||
for (int i = 0; i < 6; i++) copies += fs_save_snapshot("save-copies", NULL, 3, later, sizeof later);
|
||||
char backup[PLAT_PATH_MAX * 3 + 96];
|
||||
snprintf(backup, sizeof backup, "%s/coop-backup", dir);
|
||||
snprintf(backup, sizeof backup, "%s/save-copies", dir);
|
||||
Listing bl;
|
||||
int dated = 0, prefixed = 0;
|
||||
if (!list_dir(backup, &bl)) {
|
||||
|
||||
@@ -92,7 +92,7 @@ void gfx_window_closed(void) {
|
||||
vk_pipeline_save_exit();
|
||||
prof_write(); // plat_exit runs no atexit handlers
|
||||
rtss_limit_restore(); // RivaTuner Statistics Server's profile as it was
|
||||
coop_shutdown(); // LEAVE and BYE to the room, before the process ends
|
||||
coop_shutdown(); // leaves the room, before the process ends
|
||||
input_rumble_hd_stop(); // a controller on HD rumble gets the neutral value: nothing renews or stops it after the exit
|
||||
fs_save_flush(); // last: the game's threads still run until plat_exit, and a Commit after this one is refused
|
||||
if (restart) {
|
||||
|
||||
@@ -25,8 +25,8 @@ void rt_log_raw(const char *p, size_t n);
|
||||
const char *rt_log_path(void); // the log file, NULL when this run writes none
|
||||
void rt_log_sync(void); // writes the queued log lines now; later lines are written as they are made
|
||||
enum { RT_TRACE_SVC = 1, RT_TRACE_HOSTCALL = 2, RT_TRACE_IPC = 4, RT_TRACE_FS = 8, RT_TRACE_GFX = 16, RT_TRACE_PERF = 32,
|
||||
RT_TRACE_SCHED = 64, RT_TRACE_AUDIO = 128, RT_TRACE_PRESENT = 256, RT_TRACE_COOP = 512 };
|
||||
extern unsigned rt_trace; // from NX2NAVI_TRACE=svc,host,ipc,fs,gfx,perf,sched,audio,present,coop (or all)
|
||||
RT_TRACE_SCHED = 64, RT_TRACE_AUDIO = 128, RT_TRACE_PRESENT = 256 };
|
||||
extern unsigned rt_trace; // from NX2NAVI_TRACE=svc,host,ipc,fs,gfx,perf,sched,audio,present (or all)
|
||||
// prof_win.c: NX2NAVI_PROFILE=<path> sampling profiler; NX2NAVI_TRACE=perf frame timing (waits of the render thread)
|
||||
// PERF_TEX: texture uploads on the render thread (deswizzle, decode, staging), PERF_ASTC included
|
||||
enum { PERF_PACE, PERF_FENCE, PERF_DRAIN, PERF_PIPE, PERF_XLATE, PERF_TEX, PERF_ASTC, PERF_N };
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
// --probe-loader load and relocate the modules, check them against the measured 1.2.1 values
|
||||
// --probe-kernel, --probe-ipc, --probe-services, --probe-fs host probes
|
||||
// --probe-discord the Rich Presence IPC exchange; skips without a Discord client; no game files
|
||||
// --probe-coop the co-op codec, two sessions through a relay on 127.0.0.1 (NX2NAVI_COOP_RELAY, else its own); no game files
|
||||
// --probe-dpi the process DPI awareness (per-monitor v2) and the primary monitor's size; no game files
|
||||
// --probe-gfx-abi NVN object layouts against nvn.h's reserved sizes; needs no game files
|
||||
// --probe-nvn, --probe-nvn-tex, --probe-window, --probe-shader, --probe-vkmem, --probe-vkexec graphics probes
|
||||
@@ -176,13 +175,13 @@ static void parse_trace(void) {
|
||||
static const struct { const char *name; unsigned bit; } names[] = {
|
||||
{"svc", RT_TRACE_SVC}, {"host", RT_TRACE_HOSTCALL}, {"ipc", RT_TRACE_IPC}, {"fs", RT_TRACE_FS},
|
||||
{"gfx", RT_TRACE_GFX}, {"perf", RT_TRACE_PERF}, {"sched", RT_TRACE_SCHED}, {"audio", RT_TRACE_AUDIO},
|
||||
{"present", RT_TRACE_PRESENT}, {"coop", RT_TRACE_COOP}, {"all", ~0u}};
|
||||
{"present", RT_TRACE_PRESENT}, {"all", ~0u}};
|
||||
for (const char *p = e; *p;) {
|
||||
size_t n = strcspn(p, ",");
|
||||
int known = 0;
|
||||
for (unsigned i = 0; i < sizeof names / sizeof *names; i++)
|
||||
if (strlen(names[i].name) == n && !strncmp(p, names[i].name, n)) rt_trace |= names[i].bit, known = 1;
|
||||
if (!known && n) rt_log("NX2NAVI_TRACE: unknown item '%.*s' (svc, host, ipc, fs, gfx, perf, sched, audio, present, coop, all)", (int)n, p);
|
||||
if (!known && n) rt_log("NX2NAVI_TRACE: unknown item '%.*s' (svc, host, ipc, fs, gfx, perf, sched, audio, present, all)", (int)n, p);
|
||||
p += n + (p[n] == ',');
|
||||
}
|
||||
}
|
||||
@@ -572,7 +571,7 @@ static int usage(const char *argv0) {
|
||||
fprintf(stderr, "usage: %s [--exefs DIR] [--romfs DIR] [--profile DIR] [--audio-device VALUE] [--monitor VALUE] [--list-audio-devices | --list-monitors | --selftest | --probe-loader | "
|
||||
"--probe-cfg | --probe-dpi | --probe-mods | --probe-kernel | --probe-ipc | --probe-services | --probe-fs | --probe-gfx-abi | "
|
||||
"--probe-nvn | --probe-nvn-tex | --probe-window | --probe-shader | --probe-vkmem | "
|
||||
"--probe-vkexec | --probe-meshfb | --probe-astc | --probe-zstd | --probe-input | --probe-movie | --probe-crash-call | --probe-crash-null | --probe-crash-exit | --probe-discord | --probe-coop | "
|
||||
"--probe-vkexec | --probe-meshfb | --probe-astc | --probe-zstd | --probe-input | --probe-movie | --probe-crash-call | --probe-crash-null | --probe-crash-exit | --probe-discord | "
|
||||
"--prepare-shaders | --warm-shaders | --prepare-pipelines | --probe-prewarm | --probe-buildgate | --probe-ffx-cache | --probe-memneed | --probe-devlost | --boot |--seconds S [--shot PNG]]\n", argv0);
|
||||
return 2;
|
||||
}
|
||||
@@ -701,8 +700,8 @@ static int main_run(int argc, char **argv) {
|
||||
cfg.boot = cfg.seconds > 0; // --seconds starts the game like --boot, with its checkpoints
|
||||
vk_driver_cache_env(); // before the threads below and rt_boot's, any of which may load the Vulkan driver
|
||||
discord_init(); // the Rich Presence thread (discord_rpc.c); it reads nx2navi.ini itself and idles while off
|
||||
coop_game_init(); // co-op's game side (coop_game.c), before the thread that hands it messages
|
||||
coop_init(); // the co-op thread (coop.c); the same, idle while the COOP setting is off
|
||||
coop_game_init(); // progress sync's hooks on that thread and the game's frames (coop_game.c)
|
||||
rt_boot();
|
||||
return 0;
|
||||
}
|
||||
@@ -719,7 +718,6 @@ static int main_run(int argc, char **argv) {
|
||||
#endif
|
||||
if (!strcmp(mode, "--probe-mods")) return probe_mods();
|
||||
if (!strcmp(mode, "--probe-discord")) return probe_discord();
|
||||
if (!strcmp(mode, "--probe-coop")) return probe_coop();
|
||||
if (!strcmp(mode, "--probe-kernel")) return probe_kernel();
|
||||
if (!strcmp(mode, "--probe-ipc")) return probe_ipc();
|
||||
if (!strcmp(mode, "--probe-services")) return probe_services();
|
||||
|
||||
@@ -874,8 +874,8 @@ NVN_API(nvnQueuePresentTexture) {
|
||||
int idx = (int)arg_x(c, 2);
|
||||
movie_tick(c); // ov_movie.c: hand over decoded movie frames that are due; needs the core, so before the wait
|
||||
res_present(c); // resolution.c: a DLSS mode change sets the game's render size again, between frames
|
||||
coop_present(c); // coop_game.c: co-op reads Link and the game's flags and sets the flags the room has, between frames
|
||||
wide_present(); // widescreen.c: Ocarina's DLSS render scale
|
||||
coop_present(c); // coop_game.c: co-op progress sync reads and sets the game's flags, between frames
|
||||
NVN_BLOCKING();
|
||||
if (o->magic != NVN_WIN_MAGIC || idx < 0 || idx >= o->ntex || idx >= 4 || !o->tex[idx])
|
||||
rt_fatal("nvn: QueuePresentTexture of image %d on window %p", idx, (void *)o);
|
||||
|
||||
@@ -2579,7 +2579,7 @@ void plat_ipc_close(PlatIpc *p) {
|
||||
free(p);
|
||||
}
|
||||
|
||||
// ---- UDP sockets (platform.h): the co-op layer's transport
|
||||
// ---- UDP sockets (platform.h)
|
||||
struct PlatUdp { int fd, v6; };
|
||||
|
||||
static void addr_from_sockaddr(PlatAddr *out, const struct sockaddr_storage *ss) {
|
||||
|
||||
@@ -463,7 +463,7 @@ int plat_is_wine(void); // 1 when the Windows
|
||||
// The file the process's stderr (the log) goes to, as a UTF-8 path; 0 when stderr is not a file (a console, a pipe).
|
||||
int plat_stderr_path(char *out, size_t cap);
|
||||
|
||||
// ---- desktop: the in-game menu's "Copy system info", "Open log folder" and the Co-op tab's secret
|
||||
// ---- desktop: the in-game menu's "Copy system info" and "Open log folder"
|
||||
int plat_clipboard_set(const char *utf8); // replaces the clipboard's text; 1 on success
|
||||
// The clipboard's text as UTF-8 in out (cap bytes with the NUL; a longer text: "" on Windows, cut at a character
|
||||
// elsewhere); 1 when it had text. With SDL only on the window thread, as SDL asks: the menu goes through
|
||||
@@ -539,7 +539,7 @@ int plat_ipc_read(PlatIpc *p, void *buf, size_t n, uint32_t ms);
|
||||
int plat_ipc_write(PlatIpc *p, const void *buf, size_t n); // 1 when all n bytes were written, 0 the connection broke
|
||||
void plat_ipc_close(PlatIpc *p);
|
||||
|
||||
// ---- UDP sockets: the co-op layer's transport (coop.c). One unconnected datagram socket per PlatUdp; who a datagram
|
||||
// ---- UDP sockets. One unconnected datagram socket per PlatUdp; who a datagram
|
||||
// came from is checked by the protocol, not by the OS. On Windows the first call of any of these starts Winsock.
|
||||
// A PlatAddr is an IPv6 address (an IPv4 one as ::ffff:a.b.c.d), the port and the scope id in the same layout on every
|
||||
// OS, so two equal addresses compare equal bytewise (plat_addr_eq) whichever way the OS reported them.
|
||||
|
||||
@@ -2168,7 +2168,7 @@ void plat_ipc_close(PlatIpc *p) {
|
||||
free(p);
|
||||
}
|
||||
|
||||
// ---- UDP sockets (platform.h): the co-op layer's transport. Winsock starts at the first call that needs it.
|
||||
// ---- UDP sockets (platform.h). Winsock starts at the first call that needs it.
|
||||
#ifndef SIO_UDP_CONNRESET
|
||||
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR, 12)
|
||||
#endif
|
||||
|
||||
@@ -119,9 +119,8 @@ static void add_file(Export *e, const char *name, const char *path) {
|
||||
free(data);
|
||||
}
|
||||
|
||||
// nx2navi.ini for a bug report: as it is, except that the values of the private settings (cfg_private.h: a co-op
|
||||
// room's secret, the relay, the player's name) read "(set, not shown)". A report goes to people the player does not
|
||||
// know, and the secret lets anyone into the room.
|
||||
// nx2navi.ini for a bug report: as it is, except that the values of the private settings (cfg_private.h) read
|
||||
// "(set, not shown)". A report goes to people the player does not know.
|
||||
static void add_settings_file(Export *e, const char *name, const char *path) {
|
||||
uint64_t n = 0;
|
||||
uint8_t *data = plat_file_read(path, &n);
|
||||
|
||||
474
runtime/steam.c
Normal file
474
runtime/steam.c
Normal file
@@ -0,0 +1,474 @@
|
||||
// Steam for co-op (steam.h): the Steamworks library loaded at run time and used through its C entry points.
|
||||
//
|
||||
// The library. steam_api64.dll exports one plain C function per method of each interface ("the flat API"):
|
||||
// SteamAPI_ISteamMatchmaking_CreateLobby(self, ...), with self from an accessor whose name carries the interface's
|
||||
// version (SteamAPI_SteamMatchmaking_v009). A library of another age exports other accessor versions, so each accessor
|
||||
// is looked for under the versions known to have the calls below with these parameters, newest first; a library that
|
||||
// lacks one of them, the manual dispatch calls or the networking messages interface (before 2020) is refused as too
|
||||
// old. Nothing of the library's headers is used: the declarations here are the documented parameters of each call, a
|
||||
// CSteamID passed and returned as the 64-bit number it is, a bool as one byte.
|
||||
//
|
||||
// The app id. The library signs in as the app SteamAppId names in the environment, set here to 480 before it loads:
|
||||
// Steam's test app, which every account owns. A game started from Steam as a non-Steam shortcut has SteamGameId set
|
||||
// to the shortcut's own number; both are set, so the library does not take the shortcut for the app.
|
||||
//
|
||||
// Callbacks. With manual dispatch the library queues what happened and steam_pump takes it out: a callback is a
|
||||
// number and a block of bytes whose layout is fixed per number (8-byte packing on Windows). The numbers and offsets
|
||||
// used are in the enum below; an asynchronous call (CreateLobby, JoinLobby) ends in callback 703, which names the
|
||||
// call and the callback that holds its result.
|
||||
//
|
||||
// Messages. ISteamNetworkingMessages sends datagrams to a Steam id; Steam opens the session, finds a direct path or
|
||||
// relays through its own network, encrypts, and vouches for the sender's id. A session a stranger opens is accepted
|
||||
// only when that id is in the room, and a message is handed out only when its sender is.
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "host.h"
|
||||
#include "platform/platform.h"
|
||||
#include "steam.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define STEAM_LIB "steam_api64.dll"
|
||||
#else
|
||||
#define STEAM_LIB "libsteam_api.so"
|
||||
#endif
|
||||
|
||||
enum {
|
||||
CB_SERVERS_DISCONNECTED = 103,
|
||||
CB_LOBBY_JOIN_REQUESTED = 333, // u64 lobby, u64 friend
|
||||
CB_SHUTDOWN = 704, // Steam is closing
|
||||
CB_CALL_COMPLETED = 703, // u64 call, i32 callback, u32 size
|
||||
CB_LOBBY_INVITE = 503, // u64 user, u64 lobby, u64 game
|
||||
CB_LOBBY_ENTER = 504, // u64 lobby, u32 permissions, u8 locked, u32 response at 16
|
||||
CB_LOBBY_CHAT_UPDATE = 506, // u64 lobby, u64 user changed, u64 user making the change, u32 change at 24
|
||||
CB_LOBBY_CREATED = 513, // i32 result, u64 lobby at 8
|
||||
CB_SESSION_REQUEST = 1251, // the identity of who asks
|
||||
RESULT_OK = 1,
|
||||
ENTER_OK = 1, ENTER_NO_ROOM = 2, ENTER_NOT_ALLOWED = 3, ENTER_FULL = 4,
|
||||
CHANGE_ENTERED = 1, // the other bits: left, disconnected, kicked, banned
|
||||
LOBBY_FRIENDS_ONLY = 1, // friends see and may join it; anyone else needs an invite or its number
|
||||
FRIENDS_IMMEDIATE = 4, // the flag for "the player's friends"
|
||||
SEND_UNRELIABLE_NO_DELAY = 5, SEND_RELIABLE = 8, SEND_AUTO_RESTART = 32,
|
||||
IDENTITY_SIZE = 136, // SteamNetworkingIdentity
|
||||
MSG_DATA = 0, MSG_SIZE = 8, MSG_PEER = 16, // SteamNetworkingMessage_t: void *data, i32 size, u32 conn, identity
|
||||
CHANNEL = 0,
|
||||
RECEIVE_BATCH = 32,
|
||||
CALL_RESULT_CAP = 64,
|
||||
};
|
||||
|
||||
typedef struct { int32_t user, id; uint8_t *param; int32_t size; } CallbackMsg;
|
||||
|
||||
static struct {
|
||||
void *lib;
|
||||
int up;
|
||||
int32_t pipe;
|
||||
void *user, *friends, *mm, *utils, *msgs;
|
||||
uint64_t self, room, call; // call: the CreateLobby or JoinLobby that has not answered yet
|
||||
int creating;
|
||||
// the library
|
||||
void (*shutdown)(void);
|
||||
int32_t (*get_pipe)(void);
|
||||
void (*md_frame)(int32_t);
|
||||
uint8_t (*md_next)(int32_t, CallbackMsg *);
|
||||
void (*md_free)(int32_t);
|
||||
uint8_t (*md_result)(int32_t, uint64_t, void *, int, int, uint8_t *);
|
||||
uint64_t (*get_id)(void *);
|
||||
uint8_t (*overlay)(void *);
|
||||
const char *(*persona_of)(void *, uint64_t);
|
||||
const char *(*persona)(void *);
|
||||
int (*friend_count)(void *, int);
|
||||
uint64_t (*friend_at)(void *, int, int);
|
||||
int (*friend_state)(void *, uint64_t);
|
||||
uint8_t (*friend_game)(void *, uint64_t, void *);
|
||||
uint8_t (*has_friend)(void *, uint64_t, int);
|
||||
void (*invite_dialog)(void *, uint64_t);
|
||||
uint64_t (*create)(void *, int, int);
|
||||
uint64_t (*join)(void *, uint64_t);
|
||||
void (*leave)(void *, uint64_t);
|
||||
uint8_t (*invite)(void *, uint64_t, uint64_t);
|
||||
uint8_t (*set_data)(void *, uint64_t, const char *, const char *);
|
||||
const char *(*get_data)(void *, uint64_t, const char *);
|
||||
int (*member_count)(void *, uint64_t);
|
||||
uint64_t (*member_at)(void *, uint64_t, int);
|
||||
uint64_t (*owner)(void *, uint64_t);
|
||||
int (*send)(void *, const void *, const void *, uint32_t, int, int);
|
||||
int (*receive)(void *, int, void **, int);
|
||||
uint8_t (*accept)(void *, const void *);
|
||||
uint8_t (*close_session)(void *, const void *);
|
||||
void (*msg_release)(void *);
|
||||
void (*ident_clear)(void *);
|
||||
void (*ident_set)(void *, uint64_t);
|
||||
uint64_t (*ident_get)(void *);
|
||||
} S;
|
||||
|
||||
static void *sym(const char *name) { return plat_lib_sym(S.lib, name); }
|
||||
|
||||
// The accessor of an interface under the first of the version names the library has; NULL: none.
|
||||
static void *interface_of(const char *const *names) {
|
||||
for (; *names; names++) {
|
||||
void *(*get)(void) = sym(*names);
|
||||
if (get) return get();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int fail(char *why, size_t cap, int *which, int code, const char *text) {
|
||||
snprintf(why, cap, "%s", text);
|
||||
if (which) *which = code;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int steam_up(void) { return S.up; }
|
||||
uint64_t steam_self(void) { return S.self; }
|
||||
uint64_t steam_room(void) { return S.room; }
|
||||
|
||||
int steam_start(char *why, size_t cap, int *which) {
|
||||
if (S.up) return 1;
|
||||
if (which) *which = STEAM_WHY_OK;
|
||||
if (!S.lib) {
|
||||
// beside the game's exe, nowhere else: a path from a settings file would load whatever file a stranger's
|
||||
// nx2navi.ini names
|
||||
char path[PLAT_PATH_MAX], exe[PLAT_PATH_MAX];
|
||||
if (!plat_exe_path(exe, sizeof exe)) return fail(why, cap, which, STEAM_WHY_NO_LIBRARY, "the game's folder is not known");
|
||||
char *sep = plat_last_sep(exe);
|
||||
if (sep) *sep = 0;
|
||||
snprintf(path, sizeof path, "%s/%s", exe, STEAM_LIB);
|
||||
if (!plat_file_exists(path))
|
||||
return fail(why, cap, which, STEAM_WHY_NO_LIBRARY, STEAM_LIB " is not beside the game");
|
||||
plat_setenv("SteamAppId", "480");
|
||||
plat_setenv("SteamGameId", "480");
|
||||
S.lib = plat_lib_open(path);
|
||||
if (!S.lib) return fail(why, cap, which, STEAM_WHY_NO_LIBRARY, STEAM_LIB " beside the game does not load");
|
||||
}
|
||||
#define NEED(field, name) \
|
||||
if (!(S.field = sym(name))) return fail(why, cap, which, STEAM_WHY_OLD_LIBRARY, STEAM_LIB " is too old: it lacks " name);
|
||||
void (*md_init)(void) = sym("SteamAPI_ManualDispatch_Init");
|
||||
if (!md_init) return fail(why, cap, which, STEAM_WHY_OLD_LIBRARY, STEAM_LIB " is too old: it lacks SteamAPI_ManualDispatch_Init");
|
||||
NEED(shutdown, "SteamAPI_Shutdown") NEED(get_pipe, "SteamAPI_GetHSteamPipe")
|
||||
NEED(md_frame, "SteamAPI_ManualDispatch_RunFrame") NEED(md_next, "SteamAPI_ManualDispatch_GetNextCallback")
|
||||
NEED(md_free, "SteamAPI_ManualDispatch_FreeLastCallback") NEED(md_result, "SteamAPI_ManualDispatch_GetAPICallResult")
|
||||
NEED(get_id, "SteamAPI_ISteamUser_GetSteamID") NEED(overlay, "SteamAPI_ISteamUtils_IsOverlayEnabled")
|
||||
NEED(persona_of, "SteamAPI_ISteamFriends_GetFriendPersonaName") NEED(persona, "SteamAPI_ISteamFriends_GetPersonaName")
|
||||
NEED(friend_count, "SteamAPI_ISteamFriends_GetFriendCount") NEED(friend_at, "SteamAPI_ISteamFriends_GetFriendByIndex")
|
||||
NEED(friend_state, "SteamAPI_ISteamFriends_GetFriendPersonaState") NEED(friend_game, "SteamAPI_ISteamFriends_GetFriendGamePlayed")
|
||||
NEED(has_friend, "SteamAPI_ISteamFriends_HasFriend") NEED(invite_dialog, "SteamAPI_ISteamFriends_ActivateGameOverlayInviteDialog")
|
||||
NEED(create, "SteamAPI_ISteamMatchmaking_CreateLobby") NEED(join, "SteamAPI_ISteamMatchmaking_JoinLobby")
|
||||
NEED(leave, "SteamAPI_ISteamMatchmaking_LeaveLobby") NEED(invite, "SteamAPI_ISteamMatchmaking_InviteUserToLobby")
|
||||
NEED(set_data, "SteamAPI_ISteamMatchmaking_SetLobbyData") NEED(get_data, "SteamAPI_ISteamMatchmaking_GetLobbyData")
|
||||
NEED(member_count, "SteamAPI_ISteamMatchmaking_GetNumLobbyMembers") NEED(member_at, "SteamAPI_ISteamMatchmaking_GetLobbyMemberByIndex")
|
||||
NEED(owner, "SteamAPI_ISteamMatchmaking_GetLobbyOwner")
|
||||
NEED(send, "SteamAPI_ISteamNetworkingMessages_SendMessageToUser") NEED(receive, "SteamAPI_ISteamNetworkingMessages_ReceiveMessagesOnChannel")
|
||||
NEED(accept, "SteamAPI_ISteamNetworkingMessages_AcceptSessionWithUser") NEED(close_session, "SteamAPI_ISteamNetworkingMessages_CloseSessionWithUser")
|
||||
NEED(msg_release, "SteamAPI_SteamNetworkingMessage_t_Release") NEED(ident_clear, "SteamAPI_SteamNetworkingIdentity_Clear")
|
||||
NEED(ident_set, "SteamAPI_SteamNetworkingIdentity_SetSteamID64") NEED(ident_get, "SteamAPI_SteamNetworkingIdentity_GetSteamID64")
|
||||
#undef NEED
|
||||
// signing in: the newest entry point says why it failed, the older ones only that they did
|
||||
int (*init_flat)(char *) = sym("SteamAPI_InitFlat");
|
||||
uint8_t (*init_safe)(void) = sym("SteamAPI_InitSafe");
|
||||
uint8_t (*init_old)(void) = sym("SteamAPI_Init");
|
||||
char err[1024] = "";
|
||||
int ok = init_flat ? init_flat(err) == 0 : init_safe ? init_safe() : init_old ? init_old() : 0;
|
||||
if (!ok) {
|
||||
char text[200];
|
||||
snprintf(text, sizeof text, "Steam did not answer: is it running and signed in?%s%.100s", *err ? " Steam says: " : "", err);
|
||||
return fail(why, cap, which, STEAM_WHY_NO_CLIENT, text);
|
||||
}
|
||||
md_init();
|
||||
S.user = interface_of((const char *const[]){"SteamAPI_SteamUser_v023", "SteamAPI_SteamUser_v022", "SteamAPI_SteamUser_v021",
|
||||
"SteamAPI_SteamUser_v020", NULL});
|
||||
S.friends = interface_of((const char *const[]){"SteamAPI_SteamFriends_v018", "SteamAPI_SteamFriends_v017", NULL});
|
||||
S.mm = interface_of((const char *const[]){"SteamAPI_SteamMatchmaking_v009", NULL});
|
||||
S.utils = interface_of((const char *const[]){"SteamAPI_SteamUtils_v010", "SteamAPI_SteamUtils_v009", NULL});
|
||||
S.msgs = interface_of((const char *const[]){"SteamAPI_SteamNetworkingMessages_SteamAPI_v002", NULL});
|
||||
if (!S.user || !S.friends || !S.mm || !S.utils || !S.msgs) {
|
||||
S.shutdown();
|
||||
return fail(why, cap, which, STEAM_WHY_OLD_LIBRARY, STEAM_LIB " is too old or too new: an interface this version knows is missing");
|
||||
}
|
||||
// Steam's relay network takes a few seconds to measure its routes: started now, the first message does not wait
|
||||
void *nu = interface_of((const char *const[]){"SteamAPI_SteamNetworkingUtils_SteamAPI_v004",
|
||||
"SteamAPI_SteamNetworkingUtils_SteamAPI_v003", NULL});
|
||||
void (*relay_init)(void *) = sym("SteamAPI_ISteamNetworkingUtils_InitRelayNetworkAccess");
|
||||
if (nu && relay_init) relay_init(nu);
|
||||
S.pipe = S.get_pipe();
|
||||
S.self = S.get_id(S.user);
|
||||
S.room = S.call = 0;
|
||||
S.up = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void steam_stop(void) {
|
||||
if (!S.up) return;
|
||||
steam_room_leave();
|
||||
S.shutdown();
|
||||
S.up = 0;
|
||||
}
|
||||
|
||||
void steam_name_of(uint64_t id, char *out, size_t cap) {
|
||||
const char *name = !S.up ? "" : id == S.self ? S.persona(S.friends) : S.persona_of(S.friends, id);
|
||||
// Steam answers "[unknown]" for a player whose name it has not fetched yet
|
||||
snprintf(out, cap, "%s", name && strcmp(name, "[unknown]") ? name : "");
|
||||
}
|
||||
|
||||
int steam_is_friend(uint64_t id) { return S.up && S.has_friend(S.friends, id, FRIENDS_IMMEDIATE); }
|
||||
int steam_overlay(void) { return S.up && S.overlay(S.utils); }
|
||||
|
||||
int steam_room_create(int max_players) {
|
||||
if (!S.up || S.room || S.call) return 0;
|
||||
S.call = S.create(S.mm, LOBBY_FRIENDS_ONLY, max_players);
|
||||
S.creating = 1;
|
||||
return S.call != 0;
|
||||
}
|
||||
|
||||
int steam_room_join(uint64_t room) {
|
||||
if (!S.up || S.room || S.call || !room) return 0;
|
||||
S.call = S.join(S.mm, room);
|
||||
S.creating = 0;
|
||||
return S.call != 0;
|
||||
}
|
||||
|
||||
static void identity_of(uint8_t ident[IDENTITY_SIZE], uint64_t id) {
|
||||
S.ident_clear(ident);
|
||||
S.ident_set(ident, id);
|
||||
}
|
||||
|
||||
void steam_room_leave(void) {
|
||||
if (!S.up || !S.room) return;
|
||||
uint64_t ids[STEAM_ROOM_MAX];
|
||||
int n = steam_room_members(ids, STEAM_ROOM_MAX);
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (ids[i] == S.self) continue;
|
||||
uint8_t ident[IDENTITY_SIZE];
|
||||
identity_of(ident, ids[i]);
|
||||
S.close_session(S.msgs, ident);
|
||||
}
|
||||
S.leave(S.mm, S.room);
|
||||
S.room = 0;
|
||||
}
|
||||
|
||||
uint64_t steam_room_owner(void) { return S.up && S.room ? S.owner(S.mm, S.room) : 0; }
|
||||
|
||||
int steam_room_members(uint64_t *out, int max) {
|
||||
if (!S.up || !S.room) return 0;
|
||||
int n = S.member_count(S.mm, S.room);
|
||||
if (n > max) n = max;
|
||||
for (int i = 0; i < n; i++) out[i] = S.member_at(S.mm, S.room, i);
|
||||
return n;
|
||||
}
|
||||
|
||||
static int in_room(uint64_t id) {
|
||||
uint64_t ids[STEAM_ROOM_MAX];
|
||||
int n = steam_room_members(ids, STEAM_ROOM_MAX);
|
||||
for (int i = 0; i < n; i++)
|
||||
if (ids[i] == id) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int steam_room_set(const char *key, const char *value) { return S.up && S.room && S.set_data(S.mm, S.room, key, value); }
|
||||
|
||||
void steam_room_get(const char *key, char *out, size_t cap) {
|
||||
const char *v = S.up && S.room ? S.get_data(S.mm, S.room, key) : NULL;
|
||||
snprintf(out, cap, "%s", v ? v : "");
|
||||
}
|
||||
|
||||
static int friend_rank(const SteamFriend *f) { return f->in_app ? 0 : f->online ? 1 : 2; }
|
||||
static int friend_cmp(const void *a, const void *b) {
|
||||
const SteamFriend *x = a, *y = b;
|
||||
int d = friend_rank(x) - friend_rank(y);
|
||||
return d ? d : strcmp(x->name, y->name);
|
||||
}
|
||||
|
||||
int steam_friends(SteamFriend *out, int max) {
|
||||
if (!S.up) return 0;
|
||||
int total = S.friend_count(S.friends, FRIENDS_IMMEDIATE), n = 0;
|
||||
for (int i = 0; i < total && n < max; i++) {
|
||||
SteamFriend *f = &out[n];
|
||||
f->id = S.friend_at(S.friends, i, FRIENDS_IMMEDIATE);
|
||||
steam_name_of(f->id, f->name, sizeof f->name);
|
||||
if (!f->name[0]) continue;
|
||||
f->online = S.friend_state(S.friends, f->id) != 0;
|
||||
// FriendGameInfo_t: u64 game id (the app in its low 24 bits), u32 address, u16 and u16 ports, u64 lobby
|
||||
uint8_t game[24] = {0};
|
||||
uint64_t game_id = 0;
|
||||
if (S.friend_game(S.friends, f->id, game)) memcpy(&game_id, game, 8);
|
||||
f->in_app = (game_id & 0xffffff) == STEAM_APP_ID;
|
||||
n++;
|
||||
}
|
||||
qsort(out, (size_t)n, sizeof *out, friend_cmp);
|
||||
return n;
|
||||
}
|
||||
|
||||
int steam_invite(uint64_t friend_id) { return S.up && S.room && S.invite(S.mm, S.room, friend_id); }
|
||||
void steam_invite_window(void) {
|
||||
if (S.up && S.room) S.invite_dialog(S.friends, S.room);
|
||||
}
|
||||
|
||||
int steam_send(uint64_t to, const void *data, size_t n, int reliable) {
|
||||
if (!S.up || !S.room || n > STEAM_MESSAGE_MAX) return 0;
|
||||
uint8_t ident[IDENTITY_SIZE];
|
||||
identity_of(ident, to);
|
||||
// a session that broke (the other player's connection dropped for a moment) is opened again by the next message
|
||||
int flags = (reliable ? SEND_RELIABLE : SEND_UNRELIABLE_NO_DELAY) | SEND_AUTO_RESTART;
|
||||
return S.send(S.msgs, ident, data, (uint32_t)n, flags, CHANNEL) == RESULT_OK;
|
||||
}
|
||||
|
||||
static uint64_t u64_at(const uint8_t *p, size_t off) {
|
||||
uint64_t v;
|
||||
memcpy(&v, p + off, 8);
|
||||
return v;
|
||||
}
|
||||
static uint32_t u32_at(const uint8_t *p, size_t off) {
|
||||
uint32_t v;
|
||||
memcpy(&v, p + off, 4);
|
||||
return v;
|
||||
}
|
||||
|
||||
static void entered(uint64_t room, uint32_t response, void (*on)(const SteamEvent *, void *), void *user) {
|
||||
S.call = 0;
|
||||
if (response == ENTER_OK) {
|
||||
S.room = room;
|
||||
on(&(SteamEvent){.kind = STEAM_EV_ROOM_ENTERED, .a = room}, user);
|
||||
} else {
|
||||
int code = response == ENTER_NO_ROOM ? STEAM_FAIL_NO_ROOM : response == ENTER_FULL ? STEAM_FAIL_FULL
|
||||
: response == ENTER_NOT_ALLOWED ? STEAM_FAIL_REFUSED : STEAM_FAIL_OTHER;
|
||||
on(&(SteamEvent){.kind = STEAM_EV_ROOM_FAILED, .code = code}, user);
|
||||
}
|
||||
}
|
||||
|
||||
static void callback(int id, const uint8_t *p, int size, void (*on)(const SteamEvent *, void *), void *user) {
|
||||
switch (id) {
|
||||
case CB_CALL_COMPLETED: {
|
||||
if (size < 16) break;
|
||||
uint64_t call = u64_at(p, 0);
|
||||
int32_t result_id = (int32_t)u32_at(p, 8);
|
||||
uint32_t n = u32_at(p, 12);
|
||||
if (call != S.call || n > CALL_RESULT_CAP) break; // a call of the library's own
|
||||
uint8_t r[CALL_RESULT_CAP] = {0}, failed = 0;
|
||||
if (!S.md_result(S.pipe, call, r, (int)n, result_id, &failed) || failed) {
|
||||
S.call = 0;
|
||||
on(&(SteamEvent){.kind = STEAM_EV_ROOM_FAILED, .code = S.creating ? STEAM_FAIL_CREATE : STEAM_FAIL_OTHER}, user);
|
||||
} else if (result_id == CB_LOBBY_CREATED && n >= 16) {
|
||||
if (u32_at(r, 0) == RESULT_OK) {
|
||||
entered(u64_at(r, 8), ENTER_OK, on, user);
|
||||
} else {
|
||||
S.call = 0;
|
||||
on(&(SteamEvent){.kind = STEAM_EV_ROOM_FAILED, .code = STEAM_FAIL_CREATE}, user);
|
||||
}
|
||||
} else if (result_id == CB_LOBBY_ENTER && n >= 20) {
|
||||
entered(u64_at(r, 0), u32_at(r, 16), on, user);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CB_LOBBY_CHAT_UPDATE:
|
||||
if (size >= 28 && u64_at(p, 0) == S.room && u64_at(p, 8) != S.self) {
|
||||
uint64_t who = u64_at(p, 8);
|
||||
int came = u32_at(p, 24) == CHANGE_ENTERED;
|
||||
if (!came) {
|
||||
uint8_t ident[IDENTITY_SIZE];
|
||||
identity_of(ident, who);
|
||||
S.close_session(S.msgs, ident);
|
||||
}
|
||||
on(&(SteamEvent){.kind = came ? STEAM_EV_MEMBER_JOINED : STEAM_EV_MEMBER_LEFT, .a = who}, user);
|
||||
}
|
||||
break;
|
||||
case CB_LOBBY_INVITE:
|
||||
if (size >= 24 && (u64_at(p, 16) & 0xffffff) == STEAM_APP_ID)
|
||||
on(&(SteamEvent){.kind = STEAM_EV_INVITED, .a = u64_at(p, 8), .b = u64_at(p, 0)}, user);
|
||||
break;
|
||||
case CB_LOBBY_JOIN_REQUESTED:
|
||||
if (size >= 16) on(&(SteamEvent){.kind = STEAM_EV_JOIN_ASKED, .a = u64_at(p, 0), .b = u64_at(p, 8)}, user);
|
||||
break;
|
||||
case CB_SESSION_REQUEST:
|
||||
// only a player in the room may open a session: anyone on Steam can ask
|
||||
if (size >= IDENTITY_SIZE) {
|
||||
uint8_t ident[IDENTITY_SIZE];
|
||||
memcpy(ident, p, IDENTITY_SIZE);
|
||||
if (in_room(S.ident_get(ident))) S.accept(S.msgs, ident);
|
||||
}
|
||||
break;
|
||||
case CB_SERVERS_DISCONNECTED:
|
||||
case CB_SHUTDOWN:
|
||||
if (S.room) {
|
||||
S.room = S.call = 0;
|
||||
on(&(SteamEvent){.kind = STEAM_EV_LOST}, user);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void steam_pump(void (*on)(const SteamEvent *e, void *user), void *user) {
|
||||
if (!S.up) return;
|
||||
S.md_frame(S.pipe);
|
||||
CallbackMsg m;
|
||||
while (S.md_next(S.pipe, &m)) {
|
||||
// the block is the library's until it is freed, and a handler may call the library: copy first
|
||||
uint8_t copy[512];
|
||||
int size = m.size < 0 ? 0 : m.size > (int)sizeof copy ? (int)sizeof copy : m.size;
|
||||
if (size) memcpy(copy, m.param, (size_t)size);
|
||||
int id = m.id;
|
||||
S.md_free(S.pipe);
|
||||
callback(id, copy, size, on, user);
|
||||
if (!S.up) return;
|
||||
}
|
||||
for (;;) {
|
||||
void *batch[RECEIVE_BATCH];
|
||||
int n = S.receive(S.msgs, CHANNEL, batch, RECEIVE_BATCH);
|
||||
for (int i = 0; i < n; i++) {
|
||||
const uint8_t *msg = batch[i];
|
||||
const uint8_t *data;
|
||||
int32_t size;
|
||||
uint8_t ident[IDENTITY_SIZE];
|
||||
memcpy(&data, msg + MSG_DATA, sizeof data);
|
||||
memcpy(&size, msg + MSG_SIZE, 4);
|
||||
memcpy(ident, msg + MSG_PEER, IDENTITY_SIZE);
|
||||
uint64_t from = S.ident_get(ident);
|
||||
if (size > 0 && size <= STEAM_MESSAGE_MAX && from && from != S.self && in_room(from))
|
||||
on(&(SteamEvent){.kind = STEAM_EV_MESSAGE, .a = from, .data = data, .n = (size_t)size}, user);
|
||||
S.msg_release(batch[i]);
|
||||
}
|
||||
if (n < RECEIVE_BATCH) break;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- room ids
|
||||
//
|
||||
// Every lobby's 64-bit number starts with the same 32 bits (universe 1, the chat type, the lobby flag: 0x01860000); the
|
||||
// other 32 name the lobby. A room id is those 32 bits and an 8-bit check of them, 40 bits as 8 symbols of 5 bits.
|
||||
|
||||
#define LOBBY_HIGH 0x01860000ull
|
||||
static const char code_symbols[] = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ"; // no 0, 1, I or O
|
||||
|
||||
static uint32_t code_check(uint32_t low) {
|
||||
uint32_t h = low * 2654435761u;
|
||||
return (h >> 24) & 0xff;
|
||||
}
|
||||
|
||||
void steam_code_make(uint64_t room, char out[STEAM_CODE_CAP]) {
|
||||
out[0] = 0;
|
||||
if (room >> 32 != LOBBY_HIGH) return; // a lobby of a kind this version does not know: it has no room id
|
||||
uint32_t low = (uint32_t)room;
|
||||
uint64_t v = (uint64_t)low << 8 | code_check(low);
|
||||
int o = 0;
|
||||
for (int i = 7; i >= 0; i--) {
|
||||
out[o++] = code_symbols[(v >> (5 * i)) & 31];
|
||||
if (i == 4) out[o++] = '-';
|
||||
}
|
||||
out[o] = 0;
|
||||
}
|
||||
|
||||
uint64_t steam_code_parse(const char *text) {
|
||||
uint64_t v = 0;
|
||||
int n = 0;
|
||||
for (; *text; text++) {
|
||||
char c = *text;
|
||||
if (c == '-' || c == ' ' || c == '\t') continue;
|
||||
if (c >= 'a' && c <= 'z') c = (char)(c - 'a' + 'A');
|
||||
const char *at = strchr(code_symbols, c);
|
||||
if (!at || !c || ++n > 8) return 0;
|
||||
v = v << 5 | (uint64_t)(at - code_symbols);
|
||||
}
|
||||
if (n != 8) return 0;
|
||||
uint32_t low = (uint32_t)(v >> 8);
|
||||
if ((v & 0xff) != code_check(low)) return 0;
|
||||
return LOBBY_HIGH << 32 | low;
|
||||
}
|
||||
84
runtime/steam.h
Normal file
84
runtime/steam.h
Normal file
@@ -0,0 +1,84 @@
|
||||
// Steam for co-op (steam.c): rooms are Steam lobbies, players are invited through Steam, and the games talk through
|
||||
// Steam's networking, so nobody forwards a port and nobody runs a server. NX2navi is no Steam app of its own: it signs
|
||||
// in as Steam's public test app (id 480, "Spacewar"), which every account may use; Steam then shows the player as
|
||||
// playing that app.
|
||||
//
|
||||
// The Steamworks library is not part of NX2navi and is never in its repository. steam.c declares the functions it
|
||||
// calls itself and loads steam_api64.dll from beside the game at run time (the launcher copies one there from a
|
||||
// Steam game the player has, launcher/steamlib.py); without the file, or without a running Steam client that is
|
||||
// signed in, steam_start fails and says why.
|
||||
//
|
||||
// Every function here is called from one thread (the co-op thread, coop.c): the library is used single-threaded.
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum { STEAM_APP_ID = 480, STEAM_NAME_CAP = 64, STEAM_ROOM_MAX = 8, STEAM_MESSAGE_MAX = 1200 };
|
||||
|
||||
typedef enum {
|
||||
STEAM_EV_ROOM_ENTERED, // a: the room. This game made or joined it
|
||||
STEAM_EV_ROOM_FAILED, // code: why (STEAM_FAIL_*)
|
||||
STEAM_EV_MEMBER_JOINED, // a: the player's id
|
||||
STEAM_EV_MEMBER_LEFT, // a: the player's id
|
||||
STEAM_EV_INVITED, // a: the room, b: the friend who invites. Shown to the player, who may join
|
||||
STEAM_EV_JOIN_ASKED, // a: the room. The player accepted an invite, or chose Join Game, in Steam itself
|
||||
STEAM_EV_MESSAGE, // a: the sender, data and n: the message. Only from players in the room
|
||||
STEAM_EV_LOST, // Steam lost its connection or closed: the room is gone
|
||||
} SteamEventKind;
|
||||
|
||||
enum { STEAM_FAIL_CREATE = 1, STEAM_FAIL_NO_ROOM, STEAM_FAIL_FULL, STEAM_FAIL_REFUSED, STEAM_FAIL_OTHER };
|
||||
|
||||
typedef struct {
|
||||
SteamEventKind kind;
|
||||
uint64_t a, b;
|
||||
int code;
|
||||
const uint8_t *data;
|
||||
size_t n;
|
||||
} SteamEvent;
|
||||
|
||||
typedef struct {
|
||||
uint64_t id;
|
||||
char name[STEAM_NAME_CAP];
|
||||
int online; // signed in to Steam now
|
||||
int in_app; // shown as playing app 480: probably in NX2navi with co-op on, so an invite can reach the game
|
||||
} SteamFriend;
|
||||
|
||||
// Loads the library, signs in as app 480 and takes the interfaces. 1 when Steam is up; 0 with the reason in why (a
|
||||
// sentence for the log and the menu's status line; STEAM_WHY_* says which, for the menu's own text).
|
||||
enum { STEAM_WHY_OK, STEAM_WHY_NO_LIBRARY, STEAM_WHY_OLD_LIBRARY, STEAM_WHY_NO_CLIENT, STEAM_WHY_OTHER_OS };
|
||||
int steam_start(char *why, size_t cap, int *which);
|
||||
void steam_stop(void); // leaves the room and signs out
|
||||
int steam_up(void);
|
||||
|
||||
uint64_t steam_self(void);
|
||||
void steam_name_of(uint64_t id, char *out, size_t cap); // the player's Steam name; "" while Steam has not got it
|
||||
int steam_is_friend(uint64_t id);
|
||||
int steam_overlay(void); // Steam's overlay is in this game (it was started from Steam): its invite window works
|
||||
|
||||
// Rooms. Create and join answer later with STEAM_EV_ROOM_ENTERED or STEAM_EV_ROOM_FAILED.
|
||||
int steam_room_create(int max_players);
|
||||
int steam_room_join(uint64_t room);
|
||||
void steam_room_leave(void);
|
||||
uint64_t steam_room(void); // 0: in none
|
||||
uint64_t steam_room_owner(void); // whose game made it; Steam hands it to another member when that player leaves
|
||||
int steam_room_members(uint64_t *out, int max);
|
||||
int steam_room_set(const char *key, const char *value); // the owner's notes on the room, read by everyone
|
||||
void steam_room_get(const char *key, char *out, size_t cap);
|
||||
|
||||
int steam_friends(SteamFriend *out, int max); // the player's friends, those in the app first, then online, then the rest
|
||||
int steam_invite(uint64_t friend_id); // Steam shows the friend an invite to this room
|
||||
void steam_invite_window(void); // Steam's own invite window (only with steam_overlay)
|
||||
|
||||
// A message to a player in the room. reliable: it arrives, in order; else it may be lost and is never late.
|
||||
int steam_send(uint64_t to, const void *data, size_t n, int reliable);
|
||||
|
||||
// Runs Steam's callbacks and hands out what happened. Call it many times a second.
|
||||
void steam_pump(void (*on)(const SteamEvent *e, void *user), void *user);
|
||||
|
||||
// A room's id as players pass it on, "XXXX-XXXX": the part of the lobby's number that differs between lobbies and a
|
||||
// check of it, in letters and digits that cannot be mixed up (no 0, 1, I or O). steam_code_parse takes it in any case, with or
|
||||
// without the dash and spaces; 0 when it is no room id.
|
||||
enum { STEAM_CODE_CAP = 16 };
|
||||
void steam_code_make(uint64_t room, char out[STEAM_CODE_CAP]);
|
||||
uint64_t steam_code_parse(const char *text);
|
||||
@@ -244,7 +244,7 @@ static void svc_body(Cpu *c, uint32_t imm, uint64_t pc) {
|
||||
// profile saved, logs flushed, exit code 0
|
||||
char at[160];
|
||||
rt_log("guest ExitProcess at %s; exiting", ldr_describe(pc, at, sizeof at));
|
||||
coop_shutdown(); // LEAVE and BYE to the room, before the process ends
|
||||
coop_shutdown(); // leaves the room, before the process ends
|
||||
fs_save_flush();
|
||||
vk_pipeline_prewarm_marker_clear(); // as the window's close (gfx_present.c gfx_window_closed)
|
||||
vk_pipeline_save_exit();
|
||||
|
||||
@@ -53,8 +53,7 @@ static void put(Out *o, const char *fmt, ...) {
|
||||
if (k > 0) o->at = o->at + (size_t)k < o->n ? o->at + (size_t)k : o->n - 1;
|
||||
}
|
||||
|
||||
// The co-op room's secret and the offer number made from it, the relay's address and the player's name stay out of a
|
||||
// text that ends up in bug reports: only whether they are set.
|
||||
// The private settings (cfg_private.h) stay out of a text that ends up in bug reports: only whether they are set.
|
||||
static int private_setting(const char *key) { return cfg_private_key(key); } // cfg_private.h: one list for all
|
||||
|
||||
static void put_setting(const char *key, const char *value, int from_env, void *ctx) {
|
||||
|
||||
167
runtime/third_party/monocypher/LICENCE.md
vendored
167
runtime/third_party/monocypher/LICENCE.md
vendored
@@ -1,167 +0,0 @@
|
||||
Monocypher as a whole is dual-licensed. Choose whichever licence you
|
||||
want from the two licences listed below.
|
||||
|
||||
The first licence is a regular 2-clause BSD licence. The second licence
|
||||
is the CC-0 from Creative Commons. It is intended to release Monocypher
|
||||
to the public domain. The BSD licence serves as a fallback option.
|
||||
|
||||
See the individual files for specific information about who contributed
|
||||
to what file during which years. See below for special notes.
|
||||
|
||||
Licence 1 (2-clause BSD)
|
||||
------------------------
|
||||
|
||||
Copyright (c) 2017-2023, Loup Vaillant
|
||||
Copyright (c) 2017-2019, Michael Savage
|
||||
Copyright (c) 2017-2023, Fabio Scotoni
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
Licence 2 (CC-0)
|
||||
----------------
|
||||
|
||||
> CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
> LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
> ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
> INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
> REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
> PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
> THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
> HEREUNDER.
|
||||
|
||||
### Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work
|
||||
of authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without
|
||||
fear of later claims of infringement build upon, modify, incorporate in
|
||||
other works, reuse and redistribute as freely as possible in any form
|
||||
whatsoever and for any purposes, including without limitation commercial
|
||||
purposes. These owners may contribute to the Commons to promote the
|
||||
ideal of a free culture and the further production of creative, cultural
|
||||
and scientific works, or to gain reputation or greater distribution for
|
||||
their Work in part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or
|
||||
she is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under
|
||||
its terms, with knowledge of his or her Copyright and Related Rights in
|
||||
the Work and the meaning and intended legal effect of CC0 on those
|
||||
rights.
|
||||
|
||||
1. **Copyright and Related Rights.** A Work made available under CC0 may
|
||||
be protected by copyright and related or neighboring rights
|
||||
("Copyright and Related Rights"). Copyright and Related Rights
|
||||
include, but are not limited to, the following:
|
||||
|
||||
- the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
- moral rights retained by the original author(s) and/or
|
||||
performer(s); publicity and privacy rights pertaining to a person's
|
||||
image or likeness depicted in a Work;
|
||||
- rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
- rights protecting the extraction, dissemination, use and reuse of
|
||||
data in a Work;
|
||||
- database rights (such as those arising under Directive 96/9/EC of
|
||||
the European Parliament and of the Council of 11 March 1996 on the
|
||||
legal protection of databases, and under any national
|
||||
implementation thereof, including any amended or successor version
|
||||
of such directive); and
|
||||
- other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. **Waiver.** To the greatest extent permitted by, but not in
|
||||
contravention of, applicable law, Affirmer hereby overtly, fully,
|
||||
permanently, irrevocably and unconditionally waives, abandons, and
|
||||
surrenders all of Affirmer's Copyright and Related Rights and
|
||||
associated claims and causes of action, whether now known or unknown
|
||||
(including existing as well as future claims and causes of action),
|
||||
in the Work (i) in all territories worldwide, (ii) for the maximum
|
||||
duration provided by applicable law or treaty (including future time
|
||||
extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"Waiver"). Affirmer makes the Waiver for the benefit of each member
|
||||
of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal
|
||||
or equitable action to disrupt the quiet enjoyment of the Work by the
|
||||
public as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. **Public License Fallback.** Should any part of the Waiver for any
|
||||
reason be judged legally invalid or ineffective under applicable law,
|
||||
then the Waiver shall be preserved to the maximum extent permitted
|
||||
taking into account Affirmer's express Statement of Purpose. In
|
||||
addition, to the extent the Waiver is so judged Affirmer hereby
|
||||
grants to each affected person a royalty-free, non transferable, non
|
||||
sublicensable, non exclusive, irrevocable and unconditional license
|
||||
to exercise Affirmer's Copyright and Related Rights in the Work (i)
|
||||
in all territories worldwide, (ii) for the maximum duration provided
|
||||
by applicable law or treaty (including future time extensions), (iii)
|
||||
in any current or future medium and for any number of copies, and
|
||||
(iv) for any purpose whatsoever, including without limitation
|
||||
commercial, advertising or promotional purposes (the "License"). The
|
||||
License shall be deemed effective as of the date CC0 was applied by
|
||||
Affirmer to the Work. Should any part of the License for any reason
|
||||
be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the
|
||||
remainder of the License, and in such case Affirmer hereby affirms
|
||||
that he or she will not (i) exercise any of his or her remaining
|
||||
Copyright and Related Rights in the Work or (ii) assert any
|
||||
associated claims and causes of action with respect to the Work, in
|
||||
either case contrary to Affirmer's express Statement of Purpose.
|
||||
|
||||
4. **Limitations and Disclaimers.**
|
||||
|
||||
- No trademark or patent rights held by Affirmer are waived,
|
||||
abandoned, surrendered, licensed or otherwise affected by this
|
||||
document.
|
||||
- Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy,
|
||||
or the present or absence of errors, whether or not discoverable,
|
||||
all to the greatest extent permissible under applicable law.
|
||||
- Affirmer disclaims responsibility for clearing rights of other
|
||||
persons that may apply to the Work or any use thereof, including
|
||||
without limitation any person's Copyright and Related Rights in the
|
||||
Work. Further, Affirmer disclaims responsibility for obtaining any
|
||||
necessary consents, permissions or other rights required for any
|
||||
use of the Work.
|
||||
- Affirmer understands and acknowledges that Creative Commons is not
|
||||
a party to this document and has no duty or obligation with respect
|
||||
to this CC0 or use of the Work.
|
||||
2956
runtime/third_party/monocypher/monocypher.c
vendored
2956
runtime/third_party/monocypher/monocypher.c
vendored
File diff suppressed because it is too large
Load Diff
321
runtime/third_party/monocypher/monocypher.h
vendored
321
runtime/third_party/monocypher/monocypher.h
vendored
@@ -1,321 +0,0 @@
|
||||
// Monocypher version 4.0.2
|
||||
//
|
||||
// This file is dual-licensed. Choose whichever licence you want from
|
||||
// the two licences listed below.
|
||||
//
|
||||
// The first licence is a regular 2-clause BSD licence. The second licence
|
||||
// is the CC-0 from Creative Commons. It is intended to release Monocypher
|
||||
// to the public domain. The BSD licence serves as a fallback option.
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-2-Clause OR CC0-1.0
|
||||
//
|
||||
// ------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2017-2019, Loup Vaillant
|
||||
// All rights reserved.
|
||||
//
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ------------------------------------------------------------------------
|
||||
//
|
||||
// Written in 2017-2019 by Loup Vaillant
|
||||
//
|
||||
// To the extent possible under law, the author(s) have dedicated all copyright
|
||||
// and related neighboring rights to this software to the public domain
|
||||
// worldwide. This software is distributed without any warranty.
|
||||
//
|
||||
// You should have received a copy of the CC0 Public Domain Dedication along
|
||||
// with this software. If not, see
|
||||
// <https://creativecommons.org/publicdomain/zero/1.0/>
|
||||
|
||||
#ifndef MONOCYPHER_H
|
||||
#define MONOCYPHER_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef MONOCYPHER_CPP_NAMESPACE
|
||||
namespace MONOCYPHER_CPP_NAMESPACE {
|
||||
#elif defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Constant time comparisons
|
||||
// -------------------------
|
||||
|
||||
// Return 0 if a and b are equal, -1 otherwise
|
||||
int crypto_verify16(const uint8_t a[16], const uint8_t b[16]);
|
||||
int crypto_verify32(const uint8_t a[32], const uint8_t b[32]);
|
||||
int crypto_verify64(const uint8_t a[64], const uint8_t b[64]);
|
||||
|
||||
|
||||
// Erase sensitive data
|
||||
// --------------------
|
||||
void crypto_wipe(void *secret, size_t size);
|
||||
|
||||
|
||||
// Authenticated encryption
|
||||
// ------------------------
|
||||
void crypto_aead_lock(uint8_t *cipher_text,
|
||||
uint8_t mac [16],
|
||||
const uint8_t key [32],
|
||||
const uint8_t nonce[24],
|
||||
const uint8_t *ad, size_t ad_size,
|
||||
const uint8_t *plain_text, size_t text_size);
|
||||
int crypto_aead_unlock(uint8_t *plain_text,
|
||||
const uint8_t mac [16],
|
||||
const uint8_t key [32],
|
||||
const uint8_t nonce[24],
|
||||
const uint8_t *ad, size_t ad_size,
|
||||
const uint8_t *cipher_text, size_t text_size);
|
||||
|
||||
// Authenticated stream
|
||||
// --------------------
|
||||
typedef struct {
|
||||
uint64_t counter;
|
||||
uint8_t key[32];
|
||||
uint8_t nonce[8];
|
||||
} crypto_aead_ctx;
|
||||
|
||||
void crypto_aead_init_x(crypto_aead_ctx *ctx,
|
||||
const uint8_t key[32], const uint8_t nonce[24]);
|
||||
void crypto_aead_init_djb(crypto_aead_ctx *ctx,
|
||||
const uint8_t key[32], const uint8_t nonce[8]);
|
||||
void crypto_aead_init_ietf(crypto_aead_ctx *ctx,
|
||||
const uint8_t key[32], const uint8_t nonce[12]);
|
||||
|
||||
void crypto_aead_write(crypto_aead_ctx *ctx,
|
||||
uint8_t *cipher_text,
|
||||
uint8_t mac[16],
|
||||
const uint8_t *ad , size_t ad_size,
|
||||
const uint8_t *plain_text, size_t text_size);
|
||||
int crypto_aead_read(crypto_aead_ctx *ctx,
|
||||
uint8_t *plain_text,
|
||||
const uint8_t mac[16],
|
||||
const uint8_t *ad , size_t ad_size,
|
||||
const uint8_t *cipher_text, size_t text_size);
|
||||
|
||||
|
||||
// General purpose hash (BLAKE2b)
|
||||
// ------------------------------
|
||||
|
||||
// Direct interface
|
||||
void crypto_blake2b(uint8_t *hash, size_t hash_size,
|
||||
const uint8_t *message, size_t message_size);
|
||||
|
||||
void crypto_blake2b_keyed(uint8_t *hash, size_t hash_size,
|
||||
const uint8_t *key, size_t key_size,
|
||||
const uint8_t *message, size_t message_size);
|
||||
|
||||
// Incremental interface
|
||||
typedef struct {
|
||||
// Do not rely on the size or contents of this type,
|
||||
// for they may change without notice.
|
||||
uint64_t hash[8];
|
||||
uint64_t input_offset[2];
|
||||
uint64_t input[16];
|
||||
size_t input_idx;
|
||||
size_t hash_size;
|
||||
} crypto_blake2b_ctx;
|
||||
|
||||
void crypto_blake2b_init(crypto_blake2b_ctx *ctx, size_t hash_size);
|
||||
void crypto_blake2b_keyed_init(crypto_blake2b_ctx *ctx, size_t hash_size,
|
||||
const uint8_t *key, size_t key_size);
|
||||
void crypto_blake2b_update(crypto_blake2b_ctx *ctx,
|
||||
const uint8_t *message, size_t message_size);
|
||||
void crypto_blake2b_final(crypto_blake2b_ctx *ctx, uint8_t *hash);
|
||||
|
||||
|
||||
// Password key derivation (Argon2)
|
||||
// --------------------------------
|
||||
#define CRYPTO_ARGON2_D 0
|
||||
#define CRYPTO_ARGON2_I 1
|
||||
#define CRYPTO_ARGON2_ID 2
|
||||
|
||||
typedef struct {
|
||||
uint32_t algorithm; // Argon2d, Argon2i, Argon2id
|
||||
uint32_t nb_blocks; // memory hardness, >= 8 * nb_lanes
|
||||
uint32_t nb_passes; // CPU hardness, >= 1 (>= 3 recommended for Argon2i)
|
||||
uint32_t nb_lanes; // parallelism level (single threaded anyway)
|
||||
} crypto_argon2_config;
|
||||
|
||||
typedef struct {
|
||||
const uint8_t *pass;
|
||||
const uint8_t *salt;
|
||||
uint32_t pass_size;
|
||||
uint32_t salt_size; // 16 bytes recommended
|
||||
} crypto_argon2_inputs;
|
||||
|
||||
typedef struct {
|
||||
const uint8_t *key; // may be NULL if no key
|
||||
const uint8_t *ad; // may be NULL if no additional data
|
||||
uint32_t key_size; // 0 if no key (32 bytes recommended otherwise)
|
||||
uint32_t ad_size; // 0 if no additional data
|
||||
} crypto_argon2_extras;
|
||||
|
||||
extern const crypto_argon2_extras crypto_argon2_no_extras;
|
||||
|
||||
void crypto_argon2(uint8_t *hash, uint32_t hash_size, void *work_area,
|
||||
crypto_argon2_config config,
|
||||
crypto_argon2_inputs inputs,
|
||||
crypto_argon2_extras extras);
|
||||
|
||||
|
||||
// Key exchange (X-25519)
|
||||
// ----------------------
|
||||
|
||||
// Shared secrets are not quite random.
|
||||
// Hash them to derive an actual shared key.
|
||||
void crypto_x25519_public_key(uint8_t public_key[32],
|
||||
const uint8_t secret_key[32]);
|
||||
void crypto_x25519(uint8_t raw_shared_secret[32],
|
||||
const uint8_t your_secret_key [32],
|
||||
const uint8_t their_public_key [32]);
|
||||
|
||||
// Conversion to EdDSA
|
||||
void crypto_x25519_to_eddsa(uint8_t eddsa[32], const uint8_t x25519[32]);
|
||||
|
||||
// scalar "division"
|
||||
// Used for OPRF. Be aware that exponential blinding is less secure
|
||||
// than Diffie-Hellman key exchange.
|
||||
void crypto_x25519_inverse(uint8_t blind_salt [32],
|
||||
const uint8_t private_key[32],
|
||||
const uint8_t curve_point[32]);
|
||||
|
||||
// "Dirty" versions of x25519_public_key().
|
||||
// Use with crypto_elligator_rev().
|
||||
// Leaks 3 bits of the private key.
|
||||
void crypto_x25519_dirty_small(uint8_t pk[32], const uint8_t sk[32]);
|
||||
void crypto_x25519_dirty_fast (uint8_t pk[32], const uint8_t sk[32]);
|
||||
|
||||
|
||||
// Signatures
|
||||
// ----------
|
||||
|
||||
// EdDSA with curve25519 + BLAKE2b
|
||||
void crypto_eddsa_key_pair(uint8_t secret_key[64],
|
||||
uint8_t public_key[32],
|
||||
uint8_t seed[32]);
|
||||
void crypto_eddsa_sign(uint8_t signature [64],
|
||||
const uint8_t secret_key[64],
|
||||
const uint8_t *message, size_t message_size);
|
||||
int crypto_eddsa_check(const uint8_t signature [64],
|
||||
const uint8_t public_key[32],
|
||||
const uint8_t *message, size_t message_size);
|
||||
|
||||
// Conversion to X25519
|
||||
void crypto_eddsa_to_x25519(uint8_t x25519[32], const uint8_t eddsa[32]);
|
||||
|
||||
// EdDSA building blocks
|
||||
void crypto_eddsa_trim_scalar(uint8_t out[32], const uint8_t in[32]);
|
||||
void crypto_eddsa_reduce(uint8_t reduced[32], const uint8_t expanded[64]);
|
||||
void crypto_eddsa_mul_add(uint8_t r[32],
|
||||
const uint8_t a[32],
|
||||
const uint8_t b[32],
|
||||
const uint8_t c[32]);
|
||||
void crypto_eddsa_scalarbase(uint8_t point[32], const uint8_t scalar[32]);
|
||||
int crypto_eddsa_check_equation(const uint8_t signature[64],
|
||||
const uint8_t public_key[32],
|
||||
const uint8_t h_ram[32]);
|
||||
|
||||
|
||||
// Chacha20
|
||||
// --------
|
||||
|
||||
// Specialised hash.
|
||||
// Used to hash X25519 shared secrets.
|
||||
void crypto_chacha20_h(uint8_t out[32],
|
||||
const uint8_t key[32],
|
||||
const uint8_t in [16]);
|
||||
|
||||
// Unauthenticated stream cipher.
|
||||
// Don't forget to add authentication.
|
||||
uint64_t crypto_chacha20_djb(uint8_t *cipher_text,
|
||||
const uint8_t *plain_text,
|
||||
size_t text_size,
|
||||
const uint8_t key[32],
|
||||
const uint8_t nonce[8],
|
||||
uint64_t ctr);
|
||||
uint32_t crypto_chacha20_ietf(uint8_t *cipher_text,
|
||||
const uint8_t *plain_text,
|
||||
size_t text_size,
|
||||
const uint8_t key[32],
|
||||
const uint8_t nonce[12],
|
||||
uint32_t ctr);
|
||||
uint64_t crypto_chacha20_x(uint8_t *cipher_text,
|
||||
const uint8_t *plain_text,
|
||||
size_t text_size,
|
||||
const uint8_t key[32],
|
||||
const uint8_t nonce[24],
|
||||
uint64_t ctr);
|
||||
|
||||
|
||||
// Poly 1305
|
||||
// ---------
|
||||
|
||||
// This is a *one time* authenticator.
|
||||
// Disclosing the mac reveals the key.
|
||||
// See crypto_lock() on how to use it properly.
|
||||
|
||||
// Direct interface
|
||||
void crypto_poly1305(uint8_t mac[16],
|
||||
const uint8_t *message, size_t message_size,
|
||||
const uint8_t key[32]);
|
||||
|
||||
// Incremental interface
|
||||
typedef struct {
|
||||
// Do not rely on the size or contents of this type,
|
||||
// for they may change without notice.
|
||||
uint8_t c[16]; // chunk of the message
|
||||
size_t c_idx; // How many bytes are there in the chunk.
|
||||
uint32_t r [4]; // constant multiplier (from the secret key)
|
||||
uint32_t pad[4]; // random number added at the end (from the secret key)
|
||||
uint32_t h [5]; // accumulated hash
|
||||
} crypto_poly1305_ctx;
|
||||
|
||||
void crypto_poly1305_init (crypto_poly1305_ctx *ctx, const uint8_t key[32]);
|
||||
void crypto_poly1305_update(crypto_poly1305_ctx *ctx,
|
||||
const uint8_t *message, size_t message_size);
|
||||
void crypto_poly1305_final (crypto_poly1305_ctx *ctx, uint8_t mac[16]);
|
||||
|
||||
|
||||
// Elligator 2
|
||||
// -----------
|
||||
|
||||
// Elligator mappings proper
|
||||
void crypto_elligator_map(uint8_t curve [32], const uint8_t hidden[32]);
|
||||
int crypto_elligator_rev(uint8_t hidden[32], const uint8_t curve [32],
|
||||
uint8_t tweak);
|
||||
|
||||
// Easy to use key pair generation
|
||||
void crypto_elligator_key_pair(uint8_t hidden[32], uint8_t secret_key[32],
|
||||
uint8_t seed[32]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // MONOCYPHER_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,25 +1,24 @@
|
||||
// The menu's Co-op tab (ui/coop_page.cpp, docs/coop.md): make, join, accept and leave a room. Present path only (ImGui).
|
||||
// The menu's Co-op tab and what co-op draws over the game (ui/coop_page.cpp, docs/coop.md). Present path only (ImGui).
|
||||
#pragma once
|
||||
|
||||
// Inside the page's opt_begin / opt_end. Not in a room: the player's name, the relay's address, Make a room, Join a
|
||||
// room, a status line, the rules of a room this player makes and the co-op switch. In a room: the room's offer while it
|
||||
// waits for an answer, the players (each one's Remove for the room's maker), the secret (hidden until asked) and its
|
||||
// copy, the room's rules (the maker changes them, the others read them) and Leave.
|
||||
// Inside the page's opt_begin / opt_end. Co-op off: its switch. Steam not there: why, and Look for Steam again. In no
|
||||
// room: an invite that waits, Create a room, Join a room, the settings. In a room: the room ID (a press copies it),
|
||||
// Invite a friend, the players (the host's press removes one), the chat and Leave.
|
||||
void coop_rows(float scale);
|
||||
// After opt_end: the window a row opens: a name, an address or a secret to type, and the confirmations of Accept,
|
||||
// Remove and Leave, each opening with the cursor on its safe button.
|
||||
// After opt_end: the window a row opens: a room ID or a chat line to type, the friends to invite, and the
|
||||
// confirmations of Remove and Leave, each opening with the cursor on its safe button.
|
||||
void coop_after_page(float scale);
|
||||
// The window is open: B, Esc, L / R and the tab keys stay with it.
|
||||
bool coop_modal(void);
|
||||
// The menu opened or closed (menu.cpp): the window closes and the secret is hidden again.
|
||||
// The menu opened or closed (menu.cpp): the window closes.
|
||||
void coop_cancel(void);
|
||||
// NX2NAVI_MENU_TEST_SET pseudo-keys (menu.cpp test_apply_sets): COOP_PAGE=name|server|join|accept|leave|remove:<id>
|
||||
// opens that window as its row does, COOP_JOIN=<secret> joins as the Join window's button does, COOP_ACCEPT_OFFER=1
|
||||
// accepts the room's offer as the Accept window's button does. 1 when key is one of them.
|
||||
// NX2NAVI_MENU_TEST_SET pseudo-keys (menu.cpp test_apply_sets), from the environment only: COOP_DO=create | leave |
|
||||
// join:<room id> | chat:<text> | page:join | page:invite | page:chat | page:leave does what the row or the window's
|
||||
// button does. 1 when key is one of them.
|
||||
int coop_test_set(const char *key, const char *value);
|
||||
|
||||
// Toasts over the game while the menu is closed: a player joined or left the room, a room waits for an answer.
|
||||
// coop_toast_tick on every overlay frame (menu open or not; it costs a copy of the co-op view while co-op is on): true
|
||||
// while a toast is to be drawn. coop_toast_draw draws them into the foreground of a w x h frame.
|
||||
bool coop_toast_tick(void);
|
||||
void coop_toast_draw(float w, float h, float scale);
|
||||
// Over the game, menu open or not: the other players' names where they stand, and while the menu is closed the chat's
|
||||
// new lines and an invite that waits. coop_overlay_tick on every overlay frame (it costs a copy of the co-op view while
|
||||
// co-op is on): true while there is something to draw. coop_overlay_draw draws into a w x h frame.
|
||||
bool coop_overlay_tick(void);
|
||||
void coop_overlay_draw(float w, float h, float scale, bool menu_open);
|
||||
|
||||
@@ -36,8 +36,8 @@ static int g_font_bad;
|
||||
#pragma clang diagnostic pop
|
||||
#include "ui/amiibo_page.h"
|
||||
#include "ui/binds_page.h"
|
||||
#include "ui/coop_page.h"
|
||||
#include "ui/debug_menu.h"
|
||||
#include "ui/coop_page.h"
|
||||
#include "ui/option_rows.h"
|
||||
#include "ui/perf_panel.h"
|
||||
|
||||
@@ -581,10 +581,10 @@ extern "C" void menu_vk_release(void) {
|
||||
// optional) at that presented frame; changes live settings with no input, menu open or not. nx2navi.ini is written only by
|
||||
// the pseudo-key SAVE=1 (cfg_save, as a row change does; a failed write shows the menu's save note). FOCUS=<key> (the
|
||||
// NX2NAVI_ prefix optional) puts the cursor on that setting's row and scrolls it into view when the row is next drawn
|
||||
// (opt_focus_key), so a page's shot shows a row below the first screenful; it does not switch tabs. COOP_PAGE, COOP_JOIN
|
||||
// and COOP_ACCEPT_OFFER drive the Co-op tab (ui/coop_page.h coop_test_set).
|
||||
// (opt_focus_key), so a page's shot shows a row below the first screenful; it does not switch tabs. COOP_DO drives the
|
||||
// Co-op tab (ui/coop_page.h coop_test_set).
|
||||
// Ocarina of Time: the options this port has, and co-op (ui/coop_page.cpp)
|
||||
enum { TAB_SCREEN, TAB_GAME, TAB_SOUND, TAB_CONTROLS, TAB_COOP, TAB_COUNT }; // co-op last: tabs_shown
|
||||
enum { TAB_SCREEN, TAB_GAME, TAB_SOUND, TAB_CONTROLS, TAB_COOP, TAB_COUNT };
|
||||
enum { TEST_PAGE_FRAMES = 30, TEST_SETS = 16, TEST_OPENS = 8 };
|
||||
struct TestSet { uint64_t frame; char key[64], value[64]; };
|
||||
static struct {
|
||||
@@ -643,19 +643,16 @@ static void test_parse(void) {
|
||||
static void test_apply_sets(uint64_t frame) {
|
||||
for (; g_test.next_set < g_test.n_sets && g_test.sets[g_test.next_set].frame <= frame; g_test.next_set++) {
|
||||
const TestSet &t = g_test.sets[g_test.next_set];
|
||||
// a room's secret stays out of the log here too
|
||||
const bool secret = !strcmp(t.key, "NX2NAVI_COOP_JOIN") || !strcmp(t.key, "NX2NAVI_COOP_ROOM");
|
||||
rt_log("menu: test hook: frame %llu: %s=%s", (unsigned long long)frame, t.key, secret ? "(set, not shown)" : t.value);
|
||||
rt_log("menu: test hook: frame %llu: %s=%s", (unsigned long long)frame, t.key, t.value);
|
||||
if (!strcmp(t.key, "NX2NAVI_SAVE")) {
|
||||
rt_log("menu: test hook: cfg_save %s", cfg_save() ? "wrote" : "failed");
|
||||
} else if (!strcmp(t.key, "NX2NAVI_FOCUS")) {
|
||||
char row[80];
|
||||
snprintf(row, sizeof row, "%s%s", strncmp(t.value, "NX2NAVI_", strlen("NX2NAVI_")) ? "NX2NAVI_" : "", t.value);
|
||||
opt_focus_key(row);
|
||||
} else if (!strncmp(t.key, "NX2NAVI_COOP_", 13) && !cfg_from_env("NX2NAVI_MENU_TEST_SET")) {
|
||||
// From nx2navi.ini the hook sets no co-op key and drives no part of the Co-op tab: a settings file
|
||||
// someone hands a player could otherwise turn co-op on, join a room and accept its offer for them
|
||||
// (COOP_JOIN, COOP_ACCEPT_OFFER). A test sets it in the environment.
|
||||
} else if (!strcmp(t.key, "NX2NAVI_COOP_DO") && !cfg_from_env("NX2NAVI_MENU_TEST_SET")) {
|
||||
// From nx2navi.ini the hook drives no part of the Co-op tab: a settings file someone hands a player could
|
||||
// otherwise put them into a room. A test sets it in the environment.
|
||||
rt_log("menu: test hook: %s is taken from the environment only, not from nx2navi.ini", t.key);
|
||||
} else if (!coop_test_set(t.key, t.value)) {
|
||||
cfg_set(t.key, t.value);
|
||||
@@ -1740,14 +1737,6 @@ static void tab_controls(float scale) {
|
||||
binds_after_page();
|
||||
}
|
||||
|
||||
// The Co-op tab (ui/coop_page.cpp): the rows, then the window a row opens.
|
||||
static void tab_coop(float scale) {
|
||||
opt_begin("##coop", scale);
|
||||
coop_rows(scale);
|
||||
opt_end();
|
||||
coop_after_page(scale);
|
||||
}
|
||||
|
||||
// ---- the settings of the low-end GPU mode, under its switch in the Game tab while that is on (tab_game): each is read
|
||||
// where the code it sets reads it
|
||||
static void rows_low_end(void) {
|
||||
@@ -1820,13 +1809,17 @@ static void rows_low_end(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// The Co-op tab (ui/coop_page.cpp): the rows, then the window a row opens.
|
||||
static void tab_coop(float scale) {
|
||||
opt_begin("##coop", scale);
|
||||
coop_rows(scale);
|
||||
opt_end();
|
||||
coop_after_page(scale);
|
||||
}
|
||||
|
||||
static const UiTextId kTabNames[TAB_COUNT] = {UI_MENU_TAB_SCREEN, UI_MENU_TAB_GAME, UI_MENU_TAB_SOUND,
|
||||
UI_MENU_TAB_CONTROLS, UI_MENU_TAB_COOP};
|
||||
static int g_tab; // the tab shown
|
||||
|
||||
// The tabs the menu shows: the Co-op tab is a beta, shown only with coop_beta = 1 in nx2navi.ini (NX2NAVI_COOP_BETA),
|
||||
// which no menu row sets. Co-op itself is untouched by it: coop = 1 still runs a session (docs/coop.md).
|
||||
static int tabs_shown(void) { return cfg_bool("NX2NAVI_COOP_BETA") ? TAB_COUNT : TAB_COOP; }
|
||||
static int g_tab_request = -1; // select this tab at the next layout; -1 none
|
||||
static int g_focus_page = -1; // this tab's first row takes the cursor once it is shown; -1 none
|
||||
|
||||
@@ -1917,8 +1910,7 @@ static void layout_menu(uint32_t w, uint32_t h, float scale) {
|
||||
: ImGui::IsKeyPressed(ImGuiKey_GamepadR1, false) || ImGui::IsKeyPressed(ImGuiKey_E, false) ? 1
|
||||
: ImGui::IsKeyPressed(ImGuiKey_GamepadL1, false) || ImGui::IsKeyPressed(ImGuiKey_Q, false) ? -1
|
||||
: 0;
|
||||
const int ntabs = tabs_shown();
|
||||
if (g_tab >= ntabs) g_tab_request = 0; // the Co-op tab was shown and coop_beta went off
|
||||
const int ntabs = TAB_COUNT;
|
||||
if (step) g_tab_request = g_tab_sounded = (g_tab + step + ntabs) % ntabs;
|
||||
if (step) menu_sound_play(step > 0 ? MENU_SOUND_TAB_RIGHT : MENU_SOUND_TAB_LEFT);
|
||||
if (g_tab_request >= 0) g_focus_page = g_tab_request; // the new page's first row takes the cursor
|
||||
@@ -2188,7 +2180,7 @@ static int overlay_frame(uint64_t frame, const MenuTarget *t, const char **shot)
|
||||
if (g_perf_save.exchange(0)) cfg_save();
|
||||
perf_tick(plat_now_ns(), t);
|
||||
amiibo_tick();
|
||||
const bool toast = coop_toast_tick(); // a co-op player came or went: a toast over the game, the menu closed
|
||||
const bool coop_draws = coop_overlay_tick(); // names of the other players, chat lines, an invite: over the game
|
||||
if (g_booting.load(std::memory_order_relaxed)) g_booting.store(0, std::memory_order_release); // the game runs
|
||||
bool open = g_open.load(std::memory_order_relaxed);
|
||||
// the frame the menu is first laid out after opening: also when its g_reset went to an earlier frame of the overlay
|
||||
@@ -2206,7 +2198,7 @@ static int overlay_frame(uint64_t frame, const MenuTarget *t, const char **shot)
|
||||
if (g_debug.load()) debug_menu_tab(0);
|
||||
set_open(1);
|
||||
open = true;
|
||||
} else if (!g_perf_mode && !toast) {
|
||||
} else if (!g_perf_mode && !coop_draws) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -2240,7 +2232,7 @@ static int overlay_frame(uint64_t frame, const MenuTarget *t, const char **shot)
|
||||
io.ClearInputKeys();
|
||||
io.ClearInputMouse();
|
||||
binds_cancel(); // a cell waiting for a press when the menu closed: no press binds on the next opening
|
||||
coop_cancel(); // the Co-op tab's window closes and its secret hides
|
||||
coop_cancel(); // the Co-op tab's window closes
|
||||
g_sound_fresh = true;
|
||||
g_last_ns = 0;
|
||||
g_focus_page = g_tab_request >= 0 ? g_tab_request : g_tab; // opening: the first row has the cursor
|
||||
@@ -2272,7 +2264,7 @@ static int overlay_frame(uint64_t frame, const MenuTarget *t, const char **shot)
|
||||
layout_menu(t->width, t->height, scale);
|
||||
}
|
||||
perf_draw(t, scale);
|
||||
if (!open && toast) coop_toast_draw((float)t->width, (float)t->height, scale);
|
||||
if (coop_draws) coop_overlay_draw((float)t->width, (float)t->height, scale, open);
|
||||
ImGui::Render();
|
||||
if (open) g_save_pending = opt_save_tick(0);
|
||||
g_cost_ns += plat_now_ns() - t0;
|
||||
@@ -2281,7 +2273,7 @@ static int overlay_frame(uint64_t frame, const MenuTarget *t, const char **shot)
|
||||
const char *dir = cfg_get("NX2NAVI_MENU_TEST_DIR");
|
||||
snprintf(path, sizeof path, "%s/menu-test-%llu-%d.png", dir ? dir : ".", (unsigned long long)frame, g_test.page);
|
||||
*shot = path;
|
||||
if (++g_test.page == (g_debug.load() ? DEBUG_MENU_TABS : tabs_shown())) {
|
||||
if (++g_test.page == (g_debug.load() ? DEBUG_MENU_TABS : TAB_COUNT)) {
|
||||
g_test.page = -1;
|
||||
g_test.opened = 0, g_test.next_at++; // the next NX2NAVI_MENU_TEST frame opens it again
|
||||
set_open(0); // the next frame lays out nothing
|
||||
|
||||
@@ -688,145 +688,95 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_SAVE_E_DAMAGED] = "%s is damaged: download it again.",
|
||||
[UI_MENU_SAVE_E_UNSAFE] = "%s was refused: it holds files outside a save, links, or far more than a save.",
|
||||
[UI_MENU_TAB_COOP] = "Co-op",
|
||||
[UI_MENU_COOP_ON] = "Co-op",
|
||||
[UI_MENU_COOP_ON_DESC] = "Play with friends, each in their own game and save: a room on a relay shares story progress "
|
||||
"between them by its rules (docs/coop.md). Off: the game uses no network at all. Make a room "
|
||||
"and Join a room turn it on.",
|
||||
[UI_MENU_COOP_NAME] = "Your name",
|
||||
[UI_MENU_COOP_NAME_DESC] = "The name the other players in a room see; the relay sees it too. At most 24 bytes. Empty: "
|
||||
"Player- and four random digits.",
|
||||
[UI_MENU_COOP_AUTO] = "automatic",
|
||||
[UI_MENU_COOP_SERVER] = "Relay address",
|
||||
[UI_MENU_COOP_SERVER_DESC] = "The relay that connects the players' games: host, host:port or [IPv6]:port (port 24680 "
|
||||
"when none is given). Whoever runs it (python tools/coop_relay.py) gives its address to "
|
||||
"the others. The log and the system info do not show it.",
|
||||
[UI_MENU_COOP_NONE] = "none",
|
||||
[UI_MENU_COOP_MAKE] = "Make a room",
|
||||
[UI_MENU_COOP_MAKE_DESC] = "Makes a room with a new secret of 18 characters, which you pass on to the players you "
|
||||
"invite (by voice or a private message). A room you make shares by the rules below, and you "
|
||||
"can change them while you play.",
|
||||
[UI_MENU_COOP_ON] = "Co-op (experimental)",
|
||||
[UI_MENU_COOP_ON_DESC] = "Play with friends over Steam, each in their own game and save. Nobody sets up a router: rooms "
|
||||
"and invites go through Steam, which shows you as playing Spacewar, its test app. Needs Steam "
|
||||
"running; the launcher takes Steam's library file from a Steam game you have installed. Off: the "
|
||||
"game uses no network.",
|
||||
[UI_MENU_COOP_NO_LIBRARY] = "Steam's library file, steam_api64.dll, is not beside the game. The launcher puts it there when "
|
||||
"it starts the game, from a Steam game you have installed: start the game from the launcher, with "
|
||||
"Steam and at least one game from 2021 or later installed. You can also copy the file yourself "
|
||||
"from a Steam game's folder into the folder of ocarina.exe.",
|
||||
[UI_MENU_COOP_OLD_LIBRARY] = "The steam_api64.dll beside the game is too old for co-op. Replace it with one from a newer Steam "
|
||||
"game.",
|
||||
[UI_MENU_COOP_NO_CLIENT] = "Steam did not answer. Start Steam and sign in, then choose Look for Steam again.",
|
||||
[UI_MENU_COOP_RETRY] = "Look for Steam again",
|
||||
[UI_MENU_COOP_RETRY_DESC] = "Tries now to reach Steam; the game also tries by itself every few seconds.",
|
||||
[UI_MENU_COOP_CREATE] = "Create a room",
|
||||
[UI_MENU_COOP_CREATE_DESC] = "Makes a room for up to four players. You get a room ID to pass on, and you can invite Steam "
|
||||
"friends.",
|
||||
[UI_MENU_COOP_JOIN] = "Join a room",
|
||||
[UI_MENU_COOP_JOIN_DESC] = "Joins the room whose secret another player gave you. Nothing from the room reaches your "
|
||||
"save until you have seen who is in it and what it shares, and accepted it here.",
|
||||
[UI_MENU_COOP_NEED_SERVER] = "set the relay address first",
|
||||
[UI_MENU_COOP_SECRET] = "Room secret",
|
||||
[UI_MENU_COOP_SECRET_HINT] = "18 characters, as XXXXXX-XXXXXX-XXXXXX: any case, with or without dashes.",
|
||||
[UI_MENU_COOP_SECRET_BAD] = "This is not a room secret: it has 18 characters of 23456789BCDFGHJKMNPRSTVWXYZ.",
|
||||
[UI_MENU_COOP_PASTE] = "Paste", [UI_MENU_COOP_PASTE_EMPTY] = "The clipboard has no text.",
|
||||
[UI_MENU_COOP_OK] = "OK", [UI_MENU_COOP_STOP] = "Stop",
|
||||
[UI_MENU_COOP_STOP_DESC] = "Stops trying to reach the room.",
|
||||
[UI_MENU_COOP_CONNECTING] = "Connecting: %s",
|
||||
[UI_MENU_COOP_RECONNECTING] = "The relay went silent; getting back into the room: %s",
|
||||
[UI_MENU_COOP_LEFT] = "Not in a room: %s",
|
||||
[UI_MENU_COOP_NO_ROOM] = "No open room on the relay has this secret: check it, or ask its maker whether the room is "
|
||||
"still open.",
|
||||
[UI_MENU_COOP_NOT_STARTED] = "Co-op did not start; the log says why.",
|
||||
[UI_MENU_COOP_PLAYERS] = "Players", [UI_MENU_COOP_YOU] = "you", [UI_MENU_COOP_MAKER] = "made the room",
|
||||
[UI_MENU_COOP_HEARD] = "heard %u s ago", [UI_MENU_COOP_NOT_HEARD] = "not heard from yet", [UI_MENU_COOP_AWAY] = "away",
|
||||
[UI_MENU_COOP_MEMBER_DESC] = "A player in the room. Heard: when a message of theirs last arrived sealed with the "
|
||||
"room's secret; a player not heard from yet has not shown that they know it.",
|
||||
[UI_MENU_COOP_JOIN_DESC] = "Joins the room whose ID a friend gave you.",
|
||||
[UI_MENU_COOP_ROOM_ID] = "Room ID",
|
||||
[UI_MENU_COOP_ROOM_ID_DESC] = "Friends type this into Join a room. Press to copy it. Anyone who has it can join, so pass it on "
|
||||
"only to the people you want in your game.",
|
||||
[UI_MENU_COOP_ROOM_ID_HINT] = "8 letters and digits, as XXXX-XXXX: any case, with or without the dash.",
|
||||
[UI_MENU_COOP_ROOM_ID_BAD] = "This is not a room ID: check it for a mistyped character.",
|
||||
[UI_MENU_COOP_PASTE] = "Paste",
|
||||
[UI_MENU_COOP_PASTE_EMPTY] = "The clipboard has no text.",
|
||||
[UI_MENU_COOP_COPIED] = "copied",
|
||||
[UI_MENU_COOP_OK] = "OK",
|
||||
[UI_MENU_COOP_JOINING] = "Getting into the room…",
|
||||
[UI_MENU_COOP_STOP] = "Stop",
|
||||
[UI_MENU_COOP_STOP_DESC] = "Stops trying to get into the room.",
|
||||
[UI_MENU_COOP_INVITE] = "Invite a friend",
|
||||
[UI_MENU_COOP_INVITE_DESC] = "Sends a Steam invite to a friend. It reaches a friend whose NX2navi is running with co-op on; "
|
||||
"anyone else can use the room ID.",
|
||||
[UI_MENU_COOP_INVITE_TITLE] = "Invite a Steam friend",
|
||||
[UI_MENU_COOP_INVITE_NONE] = "Steam shows no friends.",
|
||||
[UI_MENU_COOP_INVITE_SENT] = "Invite sent to %s.",
|
||||
[UI_MENU_COOP_INVITE_IN_GAME] = "in co-op now",
|
||||
[UI_MENU_COOP_INVITE_ONLINE] = "online",
|
||||
[UI_MENU_COOP_INVITE_OFFLINE] = "offline",
|
||||
[UI_MENU_COOP_INVITE_STEAM] = "Steam's invite window",
|
||||
[UI_MENU_COOP_INVITE_CLOSE] = "Close",
|
||||
[UI_MENU_COOP_INVITED] = "%s invites you to a room.",
|
||||
[UI_MENU_COOP_INVITED_JOIN] = "Join their room",
|
||||
[UI_MENU_COOP_INVITED_JOIN_DESC] = "Joins the room you were invited to.",
|
||||
[UI_MENU_COOP_INVITED_NO] = "Not now",
|
||||
[UI_MENU_COOP_INVITED_NO_DESC] = "Puts the invite away.",
|
||||
[UI_MENU_COOP_PLAYERS] = "Players",
|
||||
[UI_MENU_COOP_YOU] = "you",
|
||||
[UI_MENU_COOP_HOST] = "host",
|
||||
[UI_MENU_COOP_PLAYER_DESC] = "A player in the room, and the area their Link is in.",
|
||||
[UI_MENU_COOP_PLAYER_REMOVE_DESC] = "A player in the room. As the host you can press to remove them from the room.",
|
||||
[UI_MENU_COOP_PLAYER_AWAY] = "not in the world",
|
||||
[UI_MENU_COOP_REMOVE] = "Remove",
|
||||
[UI_MENU_COOP_REMOVE_DESC] = "As the room's maker you can remove a player by their key: every game drops that key and "
|
||||
"gives back what it took from the pools, and the relay drops the player and refuses them "
|
||||
"again. Someone who knows the secret can come back under a new key, and everyone then gets "
|
||||
"a new offer to accept or not; to be sure, make a new room.",
|
||||
[UI_MENU_COOP_REMOVE_CONFIRM] = "Remove %s from the room?",
|
||||
[UI_MENU_COOP_SECRET_DESC] = "Anyone who has the secret can join the room: pass it on only to the players you invite, "
|
||||
"by voice or a private message. It shows only when you ask; hide it before you share your "
|
||||
"screen. The relay never learns it.",
|
||||
[UI_MENU_COOP_SHOW] = "press to show", [UI_MENU_COOP_HIDE] = "press to hide",
|
||||
[UI_MENU_COOP_COPY] = "Copy the secret",
|
||||
[UI_MENU_COOP_COPY_DESC] = "Puts the room's secret on the clipboard, to paste into a private message.",
|
||||
[UI_MENU_COOP_OFFER] = "This room waits for your answer",
|
||||
[UI_MENU_COOP_OFFER_WHO] = "In the room: %s.", [UI_MENU_COOP_OFFER_NOBODY] = "nobody else yet",
|
||||
[UI_MENU_COOP_OFFER_SHARED] = "Shared by everyone: %s.", [UI_MENU_COOP_OFFER_POOLED] = "In one pool for everyone: %s.",
|
||||
[UI_MENU_COOP_OFFER_NOTHING] = "The rules share nothing.",
|
||||
[UI_MENU_COOP_OFFER_COPY] = "Nothing from the room reaches your save before you accept. Then your whole save (every "
|
||||
"slot) is first copied to coop-backup/<date and time> in the profile folder, and only after "
|
||||
"that does the room's progress arrive.",
|
||||
[UI_MENU_COOP_OFFER_TRUST] = "A player in the room can do in your world what the rules share (open a chest, spend a "
|
||||
"pooled key), and the game cannot undo it: accept only players you trust with your save.",
|
||||
[UI_MENU_COOP_ANSWER] = "Accept or not",
|
||||
[UI_MENU_COOP_ANSWER_DESC] = "Shows the offer with Accept and Not now. A new player or other rules make a new offer, "
|
||||
"which waits for your answer again.",
|
||||
[UI_MENU_COOP_ACCEPT_CONFIRM] = "Accept this room?", [UI_MENU_COOP_ACCEPT] = "Accept", [UI_MENU_COOP_NOT_NOW] = "Not now",
|
||||
[UI_MENU_COOP_ACCEPTED] = "Accepted: the room's progress reaches your save. Your save as it was is in coop-backup in "
|
||||
"the profile folder.",
|
||||
[UI_MENU_COOP_COPY_FAILED] = "Accepted, but your save could not be copied, so nothing from the room is applied; the "
|
||||
"log says why.",
|
||||
[UI_MENU_COOP_RULES_ROOM] = "The room's rules", [UI_MENU_COOP_RULES_MINE] = "Rules of a room you make",
|
||||
[UI_MENU_COOP_RULES_UNKNOWN] = "The room's rules have not arrived yet.",
|
||||
[UI_MENU_COOP_RULES_CHANGE] = "A change is a new offer: the others take nothing more from the room until they accept it.",
|
||||
[UI_MENU_COOP_RULES_SET_BY] = "set by the room's maker", [UI_MENU_COOP_RULE_FOLLOWS] = "follows Progress",
|
||||
[UI_MENU_COOP_R_PROGRESS] = "Progress", [UI_MENU_COOP_R_ITEMS] = "Items", [UI_MENU_COOP_R_SONGS] = "Songs",
|
||||
[UI_MENU_COOP_R_QUEST] = "Quest items", [UI_MENU_COOP_R_KEYS] = "Small keys", [UI_MENU_COOP_R_RUPEES] = "Rupees",
|
||||
[UI_MENU_COOP_R_AMMO] = "Ammunition",
|
||||
[UI_MENU_COOP_R_PROGRESS_DESC] = "Story, world and dungeon flags: events, talks, chests, doors, switches, bosses, map "
|
||||
"and compass. Shared: what one player does happens in every world. Own: each world "
|
||||
"keeps its own, and small keys are then own too.",
|
||||
[UI_MENU_COOP_R_ITEMS_DESC] = "Equipment, key items, bottles owned, wallet, bag and quiver sizes, magic meter size; of "
|
||||
"a count, the highest wins. Own is possible only with Progress own: in a shared world a "
|
||||
"chest one player opened is empty for the others.",
|
||||
[UI_MENU_COOP_R_SONGS_DESC] = "The songs learned. Own is possible only with Progress own.",
|
||||
[UI_MENU_COOP_R_QUEST_DESC] = "Medallions, spiritual stones, the Stone of Agony and the Gerudo card. Own is possible "
|
||||
"only with Progress own.",
|
||||
[UI_MENU_COOP_R_KEYS_DESC] = "Small keys, per dungeon. Pool: a key anyone picks up goes into the dungeon's pool and a "
|
||||
"door anyone opens takes one out. Own with Progress own.",
|
||||
[UI_MENU_COOP_R_RUPEES_DESC] = "Pool: one purse that every player adds to and spends from. Own: each keeps their own.",
|
||||
[UI_MENU_COOP_R_AMMO_DESC] = "Bombs, bombchus, arrows, deku nuts, seeds and sticks, magic beans. Pool: one count that "
|
||||
"every player adds to and spends from.",
|
||||
[UI_MENU_COOP_SHARED] = "shared", [UI_MENU_COOP_OWN] = "own", [UI_MENU_COOP_POOL] = "pool",
|
||||
[UI_MENU_COOP_REMOVE_CONFIRM] = "Remove %s from the room? They cannot come back into this room.",
|
||||
[UI_MENU_COOP_LEAVE] = "Leave the room",
|
||||
[UI_MENU_COOP_LEAVE_DESC] = "Leaves the room. What the room gave your save stays in it.",
|
||||
[UI_MENU_COOP_LEAVE_CONFIRM] = "Leave the room? What it gave your save stays.",
|
||||
[UI_MENU_COOP_LEAVE_MAKER] = "You made this room: while you are away nobody can change its rules or remove a player, "
|
||||
"and if nobody else is in it, it closes.",
|
||||
[UI_MENU_COOP_LEAVE_DESC] = "Leaves the room. Your game and save go on as they are.",
|
||||
[UI_MENU_COOP_LEAVE_CONFIRM] = "Leave the room?",
|
||||
[UI_MENU_COOP_LEAVE_HOST] = "You are the host: the room goes on with another player as its host.",
|
||||
[UI_MENU_COOP_STAY] = "Stay",
|
||||
[UI_MENU_COOP_TOAST_JOINED] = "%s joined the room", [UI_MENU_COOP_TOAST_LEFT] = "%s left the room",
|
||||
[UI_MENU_COOP_TOAST_OFFER] = "The co-op room waits for your answer in the menu's Co-op tab",
|
||||
[UI_MENU_COOP_LOST] = "The relay lost the room; the game is getting back into it.",
|
||||
[UI_MENU_COOP_JOIN_LIMIT] = "The relay takes no more joins from your network for now; the game tries again in a minute.",
|
||||
[UI_MENU_COOP_NOT_IDENTIFIED] = "not identified", [UI_MENU_COOP_REMOVED] = "removed by the maker",
|
||||
[UI_MENU_COOP_KEY] = "key %s",
|
||||
[UI_MENU_COOP_OFFER_KEY] = "The rules are signed by key %s.",
|
||||
[UI_MENU_COOP_OFFER_COMPARE] = "Before you accept, ask the room's maker to read you their key, by voice or chat, and "
|
||||
"compare it with this one.",
|
||||
[UI_MENU_COOP_MY_KEY] = "Your key, which signs this room's rules: %s. Read it to the others, by voice or chat, so that "
|
||||
"they can compare it before they accept.",
|
||||
[UI_MENU_COOP_UNIDENTIFIED] = "Players in the room who are not identified: %d (they have not said who they are, or two "
|
||||
"keys say they are the same player). Nobody can accept the room while they are in it: the "
|
||||
"maker can remove them, or everyone moves to a new room.",
|
||||
[UI_MENU_COOP_DISAGREE] = "The players carry rules signed by different keys: ask the room's maker which key is theirs "
|
||||
"before you accept.",
|
||||
[UI_MENU_COOP_NEW_SAVE] = "Another save is played in this room: it gets the room's progress, which holds what the last "
|
||||
"save brought.",
|
||||
[UI_MENU_COOP_WARNINGS] = "Before you join a room with strangers",
|
||||
[UI_MENU_COOP_WARN_SAVE] = "1. Keep a save you can go back to. Anyone you accept can set story flags in your save, and so "
|
||||
"can anyone they accepted; a player in your pools can empty a dungeon's small keys. No "
|
||||
"removal takes a flag back: the copy in coop-backup/first-<date and time> does.",
|
||||
[UI_MENU_COOP_WARN_ROOM] = "2. Your acceptance is yours, the room is not. The players you accept pass on the flags of the "
|
||||
"players they accepted, and the maker alone decides who may use the pools. If anyone you do "
|
||||
"not know is in the room, do not accept: leave, and ask the maker for a new room.",
|
||||
[UI_MENU_COOP_WARN_KEY] = "3. Check the maker's key, and keep yours to yourself. Compare the key that signs the rules "
|
||||
"with the maker's, never start the game with settings or a script someone hands you, and "
|
||||
"never hand out a copy of your profile folder.",
|
||||
[UI_MENU_COOP_POOLS] = "Pools",
|
||||
[UI_MENU_COOP_SPENT] = "took %lld keys, %lld rupees, %lld ammunition beyond what it brought",
|
||||
[UI_MENU_COOP_NOT_IN_ROOM] = "not in the room",
|
||||
[UI_MENU_COOP_SPENT_NONE] = "Nobody took more from the pools than they brought.",
|
||||
[UI_MENU_COOP_SPENT_DESC] = "This key took more from the pools than it brought. A player who used keys others found is "
|
||||
"listed too; one nobody expected drained the pools. Removing the key gives back what it "
|
||||
"took, in every game, also after the player left. Remove it before a pool reset: a reset "
|
||||
"keeps what a player still in the room took.",
|
||||
[UI_MENU_COOP_RESET] = "Reset the pools",
|
||||
[UI_MENU_COOP_RESET_DESC] = "Every game joins the pools again with what it held for the players in the room. This "
|
||||
"recovers a pool that a player who left had emptied; flags stay as they are. A player who "
|
||||
"drained a pool and is still in the room keeps what they took: remove them first, then reset.",
|
||||
[UI_MENU_COOP_RESET_CONFIRM] = "Reset the pools for everyone in the room?",
|
||||
[UI_MENU_COOP_REMOVE_KEY_CONFIRM] = "Remove %s, key %s, from the room?",
|
||||
[UI_MENU_COOP_NOT_ACCEPTED] = "Not accepted: the room changed or a player in it is not identified. Look at the offer "
|
||||
"again.",
|
||||
[UI_MENU_COOP_ACCEPTED_AS] = "a key you accepted as %s",
|
||||
[UI_MENU_COOP_CHAT] = "Chat",
|
||||
[UI_MENU_COOP_CHAT_WRITE] = "Write a message",
|
||||
[UI_MENU_COOP_CHAT_WRITE_DESC] = "Sends a line of text to everyone in the room.",
|
||||
[UI_MENU_COOP_SEND] = "Send",
|
||||
[UI_MENU_COOP_CHAT_JOINED] = "%s joined the room",
|
||||
[UI_MENU_COOP_CHAT_LEFT] = "%s left the room",
|
||||
[UI_MENU_COOP_SETTINGS] = "Co-op settings",
|
||||
[UI_MENU_COOP_SHARE] = "Share progress",
|
||||
[UI_MENU_COOP_SHARE_DESC] = "In a room, what anyone achieves counts for everyone: story progress, chests, doors, items and "
|
||||
"songs. Before anything from a room reaches your save, the save is copied to coop-backup in the "
|
||||
"profile folder. Small keys, rupees, ammunition and hearts stay your own. Off: only names and "
|
||||
"chat are shared.",
|
||||
[UI_MENU_COOP_NAMES] = "Show player names",
|
||||
[UI_MENU_COOP_NAMES_DESC] = "Shows the name of each other player where their Link stands in your world, with the distance. "
|
||||
"Needs DLSS, FSR or TAA on (the game tells the menu where the camera looks only then).",
|
||||
[UI_MENU_COOP_CHAT_SHOW] = "Show chat over the game",
|
||||
[UI_MENU_COOP_CHAT_SHOW_DESC] = "New chat lines and who joined or left show for a few seconds while the menu is closed.",
|
||||
[UI_MENU_COOP_N_CREATE_FAILED] = "Steam could not make the room. Try again in a moment.",
|
||||
[UI_MENU_COOP_N_NO_ROOM] = "No room has this ID: check it, or ask your friend whether the room is still open.",
|
||||
[UI_MENU_COOP_N_FULL] = "The room is full.",
|
||||
[UI_MENU_COOP_N_REFUSED] = "The room did not let you in.",
|
||||
[UI_MENU_COOP_N_NOT_OURS] = "That is not an NX2navi room.",
|
||||
[UI_MENU_COOP_N_OTHER_VERSION] = "The room's host runs another version of NX2navi or of the game: use the same versions.",
|
||||
[UI_MENU_COOP_N_REMOVED] = "The host removed you from the room.",
|
||||
[UI_MENU_COOP_N_HOST_SILENT] = "The room's host did not answer.",
|
||||
[UI_MENU_COOP_N_LOST] = "Steam lost its connection; the room is gone.",
|
||||
[UI_MENU_COOP_N_LEFT] = "You left the room.",
|
||||
[UI_MENU_COOP_LOCAL] = "Test mode: a stand-in for Steam on this PC.",
|
||||
[UI_MENU_COOP_TOAST_INVITE] = "%s invites you to a room: open the menu's Co-op tab.",
|
||||
[UI_BOOT_TITLE] = "Preparing shaders",
|
||||
[UI_BOOT_STARTING] = "Starting", [UI_BOOT_SHADERS] = "Shaders: %lld of %lld", [UI_BOOT_PIPELINES] = "Pipelines: %lld of %lld",
|
||||
[UI_BOOT_COMPUTE] = "Compute pipelines: %lld of %lld", [UI_BOOT_DRIVER_CACHE] = "Driver cache: %lld of %lld",
|
||||
@@ -1438,148 +1388,96 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_SAVE_E_DAMAGED] = "%s повреждён: скачайте его заново.",
|
||||
[UI_MENU_SAVE_E_UNSAFE] = "%s отклонён: в нём файлы вне сохранения, ссылки или слишком много данных.",
|
||||
[UI_MENU_TAB_COOP] = "Кооператив",
|
||||
[UI_MENU_COOP_ON] = "Кооператив",
|
||||
[UI_MENU_COOP_ON_DESC] = "Игра с друзьями, у каждого своя игра и своё сохранение: комната на ретрансляторе делит между "
|
||||
"ними прогресс сюжета по своим правилам (docs/coop.md). Выкл.: игра совсем не использует "
|
||||
"сеть. «Создать комнату» и «Войти в комнату» включают его.",
|
||||
[UI_MENU_COOP_NAME] = "Ваше имя",
|
||||
[UI_MENU_COOP_NAME_DESC] = "Имя, которое видят другие игроки в комнате; его видит и ретранслятор. Не больше 24 байт. "
|
||||
"Пусто: Player- и четыре случайные цифры.",
|
||||
[UI_MENU_COOP_AUTO] = "автоматически",
|
||||
[UI_MENU_COOP_SERVER] = "Адрес ретранслятора",
|
||||
[UI_MENU_COOP_SERVER_DESC] = "Ретранслятор, который соединяет игры игроков: host, host:port или [IPv6]:port (порт "
|
||||
"24680, если не указан). Тот, кто его запускает (python tools/coop_relay.py), сообщает "
|
||||
"адрес остальным. Журнал и сведения о системе его не показывают.",
|
||||
[UI_MENU_COOP_NONE] = "нет",
|
||||
[UI_MENU_COOP_MAKE] = "Создать комнату",
|
||||
[UI_MENU_COOP_MAKE_DESC] = "Создаёт комнату с новым секретом из 18 символов, который вы передаёте приглашённым игрокам "
|
||||
"(голосом или личным сообщением). Созданная вами комната делит прогресс по правилам ниже, и "
|
||||
"их можно менять во время игры.",
|
||||
[UI_MENU_COOP_ON] = "Кооператив (эксперимент)",
|
||||
[UI_MENU_COOP_ON_DESC] = "Играйте с друзьями через Steam, каждый в своей игре и со своим сохранением. Настраивать роутер "
|
||||
"не нужно: комнаты и приглашения идут через Steam, который показывает, что вы играете в Spacewar, "
|
||||
"его тестовое приложение. Нужен запущенный Steam; файл его библиотеки лаунчер берёт из "
|
||||
"установленной у вас игры Steam. Выкл.: игра не использует сеть.",
|
||||
[UI_MENU_COOP_NO_LIBRARY] = "Файла библиотеки Steam, steam_api64.dll, нет рядом с игрой. Лаунчер кладёт его туда при запуске "
|
||||
"игры, из установленной у вас игры Steam: запустите игру из лаунчера при установленном Steam и "
|
||||
"хотя бы одной игре 2021 года или новее. Можно и самому скопировать файл из папки любой игры "
|
||||
"Steam в папку с ocarina.exe.",
|
||||
[UI_MENU_COOP_OLD_LIBRARY] = "Файл steam_api64.dll рядом с игрой слишком старый для кооператива. Замените его файлом из более "
|
||||
"новой игры Steam.",
|
||||
[UI_MENU_COOP_NO_CLIENT] = "Steam не ответил. Запустите Steam, войдите в аккаунт и выберите «Искать Steam снова».",
|
||||
[UI_MENU_COOP_RETRY] = "Искать Steam снова",
|
||||
[UI_MENU_COOP_RETRY_DESC] = "Пробует связаться со Steam сейчас; игра и сама пробует каждые несколько секунд.",
|
||||
[UI_MENU_COOP_CREATE] = "Создать комнату",
|
||||
[UI_MENU_COOP_CREATE_DESC] = "Создаёт комнату до четырёх игроков. Вы получите ID комнаты, который можно передать, и сможете "
|
||||
"пригласить друзей из Steam.",
|
||||
[UI_MENU_COOP_JOIN] = "Войти в комнату",
|
||||
[UI_MENU_COOP_JOIN_DESC] = "Входит в комнату, секрет которой вам дал другой игрок. Ничего из комнаты не попадёт в ваше "
|
||||
"сохранение, пока вы не увидите, кто в ней и что она делит, и не примете её здесь.",
|
||||
[UI_MENU_COOP_NEED_SERVER] = "сначала укажите адрес ретранслятора",
|
||||
[UI_MENU_COOP_SECRET] = "Секрет комнаты",
|
||||
[UI_MENU_COOP_SECRET_HINT] = "18 символов, вида XXXXXX-XXXXXX-XXXXXX: в любом регистре, с дефисами или без.",
|
||||
[UI_MENU_COOP_SECRET_BAD] = "Это не секрет комнаты: в нём 18 символов из 23456789BCDFGHJKMNPRSTVWXYZ.",
|
||||
[UI_MENU_COOP_PASTE] = "Вставить", [UI_MENU_COOP_PASTE_EMPTY] = "В буфере обмена нет текста.",
|
||||
[UI_MENU_COOP_OK] = "ОК", [UI_MENU_COOP_STOP] = "Остановить",
|
||||
[UI_MENU_COOP_STOP_DESC] = "Перестаёт пытаться попасть в комнату.",
|
||||
[UI_MENU_COOP_CONNECTING] = "Подключение: %s",
|
||||
[UI_MENU_COOP_RECONNECTING] = "Ретранслятор замолчал; возвращение в комнату: %s",
|
||||
[UI_MENU_COOP_LEFT] = "Не в комнате: %s",
|
||||
[UI_MENU_COOP_NO_ROOM] = "На ретрансляторе нет открытой комнаты с этим секретом: проверьте его или спросите создателя, "
|
||||
"открыта ли ещё комната.",
|
||||
[UI_MENU_COOP_NOT_STARTED] = "Кооператив не запустился; причина в журнале.",
|
||||
[UI_MENU_COOP_PLAYERS] = "Игроки", [UI_MENU_COOP_YOU] = "вы", [UI_MENU_COOP_MAKER] = "создатель комнаты",
|
||||
[UI_MENU_COOP_HEARD] = "на связи %u с назад", [UI_MENU_COOP_NOT_HEARD] = "ещё не на связи", [UI_MENU_COOP_AWAY] = "отошёл",
|
||||
[UI_MENU_COOP_MEMBER_DESC] = "Игрок в комнате. «На связи»: когда последний раз пришло его сообщение, запечатанное "
|
||||
"секретом комнаты; игрок, который ещё не на связи, пока не показал, что знает секрет.",
|
||||
[UI_MENU_COOP_JOIN_DESC] = "Вход в комнату, ID которой вам дал друг.",
|
||||
[UI_MENU_COOP_ROOM_ID] = "ID комнаты",
|
||||
[UI_MENU_COOP_ROOM_ID_DESC] = "Друзья вводят его в «Войти в комнату». Нажмите, чтобы скопировать. Войти может любой, у кого он "
|
||||
"есть, поэтому передавайте его только тем, кого хотите видеть в своей игре.",
|
||||
[UI_MENU_COOP_ROOM_ID_HINT] = "8 букв и цифр в виде XXXX-XXXX: в любом регистре, с дефисом или без.",
|
||||
[UI_MENU_COOP_ROOM_ID_BAD] = "Это не ID комнаты: проверьте, нет ли опечатки.",
|
||||
[UI_MENU_COOP_PASTE] = "Вставить",
|
||||
[UI_MENU_COOP_PASTE_EMPTY] = "В буфере обмена нет текста.",
|
||||
[UI_MENU_COOP_COPIED] = "скопировано",
|
||||
[UI_MENU_COOP_OK] = "ОК",
|
||||
[UI_MENU_COOP_JOINING] = "Вход в комнату…",
|
||||
[UI_MENU_COOP_STOP] = "Остановить",
|
||||
[UI_MENU_COOP_STOP_DESC] = "Прекращает попытку войти в комнату.",
|
||||
[UI_MENU_COOP_INVITE] = "Пригласить друга",
|
||||
[UI_MENU_COOP_INVITE_DESC] = "Отправляет другу приглашение через Steam. Оно дойдёт до друга, у которого запущена NX2navi с "
|
||||
"включённым кооперативом; остальные могут воспользоваться ID комнаты.",
|
||||
[UI_MENU_COOP_INVITE_TITLE] = "Пригласить друга из Steam",
|
||||
[UI_MENU_COOP_INVITE_NONE] = "Steam не показывает друзей.",
|
||||
[UI_MENU_COOP_INVITE_SENT] = "Приглашение отправлено: %s.",
|
||||
[UI_MENU_COOP_INVITE_IN_GAME] = "сейчас в кооперативе",
|
||||
[UI_MENU_COOP_INVITE_ONLINE] = "в сети",
|
||||
[UI_MENU_COOP_INVITE_OFFLINE] = "не в сети",
|
||||
[UI_MENU_COOP_INVITE_STEAM] = "Окно приглашений Steam",
|
||||
[UI_MENU_COOP_INVITE_CLOSE] = "Закрыть",
|
||||
[UI_MENU_COOP_INVITED] = "%s приглашает вас в комнату.",
|
||||
[UI_MENU_COOP_INVITED_JOIN] = "Войти в их комнату",
|
||||
[UI_MENU_COOP_INVITED_JOIN_DESC] = "Вход в комнату, в которую вас пригласили.",
|
||||
[UI_MENU_COOP_INVITED_NO] = "Не сейчас",
|
||||
[UI_MENU_COOP_INVITED_NO_DESC] = "Убирает приглашение.",
|
||||
[UI_MENU_COOP_PLAYERS] = "Игроки",
|
||||
[UI_MENU_COOP_YOU] = "вы",
|
||||
[UI_MENU_COOP_HOST] = "хост",
|
||||
[UI_MENU_COOP_PLAYER_DESC] = "Игрок в комнате и область, в которой находится его Линк.",
|
||||
[UI_MENU_COOP_PLAYER_REMOVE_DESC] = "Игрок в комнате. Как хост вы можете нажать, чтобы удалить его из комнаты.",
|
||||
[UI_MENU_COOP_PLAYER_AWAY] = "не в мире",
|
||||
[UI_MENU_COOP_REMOVE] = "Удалить",
|
||||
[UI_MENU_COOP_REMOVE_DESC] = "Как создатель комнаты вы можете удалить игрока по его ключу: каждая игра отбрасывает этот "
|
||||
"ключ и возвращает взятое им из запасов, а ретранслятор отключает игрока и больше не "
|
||||
"пускает. Тот, кто знает секрет, может вернуться с новым ключом, и тогда все получат новое "
|
||||
"предложение, которое можно принять или нет; для надёжности создайте новую комнату.",
|
||||
[UI_MENU_COOP_REMOVE_CONFIRM] = "Удалить %s из комнаты?",
|
||||
[UI_MENU_COOP_SECRET_DESC] = "Любой, у кого есть секрет, может войти в комнату: передавайте его только приглашённым "
|
||||
"игрокам, голосом или личным сообщением. Он показывается, только когда вы попросите; "
|
||||
"скройте его, прежде чем показывать экран другим. Ретранслятор его никогда не узнаёт.",
|
||||
[UI_MENU_COOP_SHOW] = "нажмите, чтобы показать", [UI_MENU_COOP_HIDE] = "нажмите, чтобы скрыть",
|
||||
[UI_MENU_COOP_COPY] = "Копировать секрет",
|
||||
[UI_MENU_COOP_COPY_DESC] = "Помещает секрет комнаты в буфер обмена, чтобы вставить его в личное сообщение.",
|
||||
[UI_MENU_COOP_OFFER] = "Комната ждёт вашего ответа",
|
||||
[UI_MENU_COOP_OFFER_WHO] = "В комнате: %s.", [UI_MENU_COOP_OFFER_NOBODY] = "больше пока никого",
|
||||
[UI_MENU_COOP_OFFER_SHARED] = "Общее для всех: %s.", [UI_MENU_COOP_OFFER_POOLED] = "Общий запас на всех: %s.",
|
||||
[UI_MENU_COOP_OFFER_NOTHING] = "Правила ничего не делят.",
|
||||
[UI_MENU_COOP_OFFER_COPY] = "Ничего из комнаты не попадёт в ваше сохранение, пока вы её не примете. Затем сначала всё "
|
||||
"ваше сохранение (все слоты) копируется в coop-backup/<дата и время> в папке профиля, и "
|
||||
"только после этого приходит прогресс комнаты.",
|
||||
[UI_MENU_COOP_OFFER_TRUST] = "Игрок в комнате может делать в вашем мире то, что делят правила (открыть сундук, "
|
||||
"потратить общий ключ), и игра не может это отменить: принимайте только тех, кому "
|
||||
"доверяете своё сохранение.",
|
||||
[UI_MENU_COOP_ANSWER] = "Принять или нет",
|
||||
[UI_MENU_COOP_ANSWER_DESC] = "Показывает предложение с кнопками «Принять» и «Не сейчас». Новый игрок или другие правила "
|
||||
"создают новое предложение, которое снова ждёт вашего ответа.",
|
||||
[UI_MENU_COOP_ACCEPT_CONFIRM] = "Принять эту комнату?", [UI_MENU_COOP_ACCEPT] = "Принять",
|
||||
[UI_MENU_COOP_NOT_NOW] = "Не сейчас",
|
||||
[UI_MENU_COOP_ACCEPTED] = "Принято: прогресс комнаты попадает в ваше сохранение. Ваше прежнее сохранение лежит в "
|
||||
"coop-backup в папке профиля.",
|
||||
[UI_MENU_COOP_COPY_FAILED] = "Принято, но сохранение не удалось скопировать, поэтому ничего из комнаты не применяется; "
|
||||
"причина в журнале.",
|
||||
[UI_MENU_COOP_RULES_ROOM] = "Правила комнаты", [UI_MENU_COOP_RULES_MINE] = "Правила комнаты, которую создадите вы",
|
||||
[UI_MENU_COOP_RULES_UNKNOWN] = "Правила комнаты ещё не пришли.",
|
||||
[UI_MENU_COOP_RULES_CHANGE] = "Изменение — это новое предложение: остальные ничего больше не берут из комнаты, пока не "
|
||||
"примут его.",
|
||||
[UI_MENU_COOP_RULES_SET_BY] = "задаёт создатель комнаты", [UI_MENU_COOP_RULE_FOLLOWS] = "следует за «Прогрессом»",
|
||||
[UI_MENU_COOP_R_PROGRESS] = "Прогресс", [UI_MENU_COOP_R_ITEMS] = "Предметы", [UI_MENU_COOP_R_SONGS] = "Мелодии",
|
||||
[UI_MENU_COOP_R_QUEST] = "Квестовые предметы", [UI_MENU_COOP_R_KEYS] = "Малые ключи", [UI_MENU_COOP_R_RUPEES] = "Рупии",
|
||||
[UI_MENU_COOP_R_AMMO] = "Боеприпасы",
|
||||
[UI_MENU_COOP_R_PROGRESS_DESC] = "Флаги сюжета, мира и подземелий: события, разговоры, сундуки, двери, переключатели, "
|
||||
"боссы, карта и компас. Общее: то, что делает один игрок, происходит в каждом мире. "
|
||||
"Своё: каждый мир хранит своё, и малые ключи тогда тоже свои.",
|
||||
[UI_MENU_COOP_R_ITEMS_DESC] = "Снаряжение, ключевые предметы, имеющиеся бутылки, размеры кошелька, сумки и колчана, "
|
||||
"размер шкалы магии; из количеств побеждает наибольшее. «Своё» возможно только при своём "
|
||||
"«Прогрессе»: в общем мире сундук, открытый одним игроком, пуст для остальных.",
|
||||
[UI_MENU_COOP_R_SONGS_DESC] = "Выученные мелодии. «Своё» возможно только при своём «Прогрессе».",
|
||||
[UI_MENU_COOP_R_QUEST_DESC] = "Медальоны, духовные камни, Камень Агонии и карта Герудо. «Своё» возможно только при своём "
|
||||
"«Прогрессе».",
|
||||
[UI_MENU_COOP_R_KEYS_DESC] = "Малые ключи, по подземельям. Запас: ключ, подобранный кем угодно, идёт в запас "
|
||||
"подземелья, а дверь, открытая кем угодно, забирает один. «Своё» при своём «Прогрессе».",
|
||||
[UI_MENU_COOP_R_RUPEES_DESC] = "Запас: один кошелёк, который все игроки пополняют и тратят. Своё: у каждого свой.",
|
||||
[UI_MENU_COOP_R_AMMO_DESC] = "Бомбы, бомбчу, стрелы, орехи деку, семена и палки, волшебные бобы. Запас: одно "
|
||||
"количество, которое все игроки пополняют и тратят.",
|
||||
[UI_MENU_COOP_SHARED] = "общее", [UI_MENU_COOP_OWN] = "своё", [UI_MENU_COOP_POOL] = "запас",
|
||||
[UI_MENU_COOP_LEAVE] = "Покинуть комнату",
|
||||
[UI_MENU_COOP_LEAVE_DESC] = "Выходит из комнаты. То, что комната дала вашему сохранению, остаётся в нём.",
|
||||
[UI_MENU_COOP_LEAVE_CONFIRM] = "Покинуть комнату? То, что она дала вашему сохранению, останется.",
|
||||
[UI_MENU_COOP_LEAVE_MAKER] = "Эту комнату создали вы: пока вас нет, никто не может менять её правила или удалять "
|
||||
"игроков, а если в ней больше никого нет, она закроется.",
|
||||
[UI_MENU_COOP_REMOVE_CONFIRM] = "Удалить %s из комнаты? Вернуться в эту комнату он не сможет.",
|
||||
[UI_MENU_COOP_LEAVE] = "Выйти из комнаты",
|
||||
[UI_MENU_COOP_LEAVE_DESC] = "Выход из комнаты. Ваша игра и сохранение остаются как есть.",
|
||||
[UI_MENU_COOP_LEAVE_CONFIRM] = "Выйти из комнаты?",
|
||||
[UI_MENU_COOP_LEAVE_HOST] = "Вы хост: комната продолжит работу, хостом станет другой игрок.",
|
||||
[UI_MENU_COOP_STAY] = "Остаться",
|
||||
[UI_MENU_COOP_TOAST_JOINED] = "%s входит в комнату", [UI_MENU_COOP_TOAST_LEFT] = "%s покидает комнату",
|
||||
[UI_MENU_COOP_TOAST_OFFER] = "Комната кооператива ждёт вашего ответа во вкладке «Кооператив» меню",
|
||||
[UI_MENU_COOP_LOST] = "Ретранслятор потерял комнату; игра возвращается в неё.",
|
||||
[UI_MENU_COOP_JOIN_LIMIT] = "Ретранслятор пока не принимает новых входов из вашей сети; игра попробует снова через минуту.",
|
||||
[UI_MENU_COOP_NOT_IDENTIFIED] = "не назвался", [UI_MENU_COOP_REMOVED] = "удалён создателем",
|
||||
[UI_MENU_COOP_KEY] = "ключ %s",
|
||||
[UI_MENU_COOP_OFFER_KEY] = "Правила подписаны ключом %s.",
|
||||
[UI_MENU_COOP_OFFER_COMPARE] = "Прежде чем принять, попросите создателя комнаты прочитать вам свой ключ голосом или в "
|
||||
"чате и сравните его с этим.",
|
||||
[UI_MENU_COOP_MY_KEY] = "Ваш ключ, которым подписаны правила этой комнаты: %s. Прочитайте его остальным голосом или в "
|
||||
"чате, чтобы они могли сравнить его, прежде чем принять.",
|
||||
[UI_MENU_COOP_UNIDENTIFIED] = "Игроков в комнате, которые не опознаны: %d (не назвались, или два ключа называют себя одним "
|
||||
"и тем же игроком). Пока они в ней, никто не может принять комнату: создатель может удалить "
|
||||
"их, или все переходят в новую комнату.",
|
||||
[UI_MENU_COOP_DISAGREE] = "У игроков правила, подписанные разными ключами: прежде чем принять, спросите создателя "
|
||||
"комнаты, какой ключ его.",
|
||||
[UI_MENU_COOP_NEW_SAVE] = "В этой комнате играют другое сохранение: оно получает прогресс комнаты, в котором есть то, "
|
||||
"что принесло прошлое сохранение.",
|
||||
[UI_MENU_COOP_WARNINGS] = "Прежде чем войти в комнату с незнакомцами",
|
||||
[UI_MENU_COOP_WARN_SAVE] = "1. Держите сохранение, к которому можно вернуться. Любой, кого вы приняли, может ставить "
|
||||
"сюжетные флаги в вашем сохранении, как и любой, кого принял он; игрок в ваших запасах может "
|
||||
"опустошить малые ключи подземелья. Никакое удаление не возвращает флаг: это делает копия в "
|
||||
"coop-backup/first-<дата и время>.",
|
||||
[UI_MENU_COOP_WARN_ROOM] = "2. Ваше согласие — ваше, комната — нет. Принятые вами игроки передают флаги тех, кого "
|
||||
"приняли они, а кто может пользоваться запасами, решает только создатель. Если в комнате "
|
||||
"есть кто-то незнакомый, не принимайте: выйдите и попросите у создателя новую комнату.",
|
||||
[UI_MENU_COOP_WARN_KEY] = "3. Сверьте ключ создателя и не отдавайте свой. Сравните ключ, которым подписаны правила, с "
|
||||
"ключом создателя, никогда не запускайте игру с настройками или скриптом, которые вам дали, "
|
||||
"и никому не отдавайте копию папки профиля.",
|
||||
[UI_MENU_COOP_POOLS] = "Запасы",
|
||||
[UI_MENU_COOP_SPENT] = "взял сверх принесённого: ключей %lld, рупий %lld, боеприпасов %lld",
|
||||
[UI_MENU_COOP_NOT_IN_ROOM] = "не в комнате",
|
||||
[UI_MENU_COOP_SPENT_NONE] = "Никто не взял из запасов больше, чем принёс.",
|
||||
[UI_MENU_COOP_SPENT_DESC] = "Этот ключ взял из запасов больше, чем принёс. Здесь и игрок, который пользовался ключами, "
|
||||
"найденными другими; тот, кого никто не ждал, опустошил запасы. Удаление ключа возвращает "
|
||||
"взятое во всех играх, и после ухода игрока тоже. Удалите ключ до сброса запасов: сброс "
|
||||
"оставляет взятое игроку, который ещё в комнате.",
|
||||
[UI_MENU_COOP_RESET] = "Сбросить запасы",
|
||||
[UI_MENU_COOP_RESET_DESC] = "Каждая игра заново входит в запасы с тем, что у неё было для игроков в комнате. Так "
|
||||
"восстанавливается запас, который опустошил ушедший игрок; флаги остаются как есть. Игрок, "
|
||||
"опустошивший запас и оставшийся в комнате, сохраняет взятое: сначала удалите его, потом сбросьте.",
|
||||
[UI_MENU_COOP_RESET_CONFIRM] = "Сбросить запасы для всех в комнате?",
|
||||
[UI_MENU_COOP_REMOVE_KEY_CONFIRM] = "Удалить %s (ключ %s) из комнаты?",
|
||||
[UI_MENU_COOP_NOT_ACCEPTED] = "Не принято: комната изменилась или кто-то в ней не опознан. Посмотрите предложение ещё раз.",
|
||||
[UI_MENU_COOP_ACCEPTED_AS] = "ключ, который вы приняли как %s",
|
||||
[UI_MENU_COOP_CHAT] = "Чат",
|
||||
[UI_MENU_COOP_CHAT_WRITE] = "Написать сообщение",
|
||||
[UI_MENU_COOP_CHAT_WRITE_DESC] = "Отправляет строку текста всем в комнате.",
|
||||
[UI_MENU_COOP_SEND] = "Отправить",
|
||||
[UI_MENU_COOP_CHAT_JOINED] = "%s входит в комнату",
|
||||
[UI_MENU_COOP_CHAT_LEFT] = "%s выходит из комнаты",
|
||||
[UI_MENU_COOP_SETTINGS] = "Настройки кооператива",
|
||||
[UI_MENU_COOP_SHARE] = "Общий прогресс",
|
||||
[UI_MENU_COOP_SHARE_DESC] = "В комнате достижения любого игрока засчитываются всем: сюжет, сундуки, двери, предметы и песни. "
|
||||
"Прежде чем что-либо из комнаты попадёт в ваше сохранение, оно копируется в coop-backup в папке "
|
||||
"профиля. Малые ключи, рупии, боеприпасы и сердца остаются вашими. Выкл.: общими остаются только "
|
||||
"имена и чат.",
|
||||
[UI_MENU_COOP_NAMES] = "Показывать имена игроков",
|
||||
[UI_MENU_COOP_NAMES_DESC] = "Показывает имя каждого другого игрока там, где его Линк стоит в вашем мире, и расстояние до "
|
||||
"него. Нужны включённые DLSS, FSR или TAA (только тогда меню знает, куда смотрит камера).",
|
||||
[UI_MENU_COOP_CHAT_SHOW] = "Показывать чат поверх игры",
|
||||
[UI_MENU_COOP_CHAT_SHOW_DESC] = "Новые строки чата и сообщения о входе и выходе игроков показываются несколько секунд, пока меню "
|
||||
"закрыто.",
|
||||
[UI_MENU_COOP_N_CREATE_FAILED] = "Steam не смог создать комнату. Попробуйте ещё раз чуть позже.",
|
||||
[UI_MENU_COOP_N_NO_ROOM] = "Комнаты с таким ID нет: проверьте его или спросите друга, открыта ли ещё комната.",
|
||||
[UI_MENU_COOP_N_FULL] = "Комната заполнена.",
|
||||
[UI_MENU_COOP_N_REFUSED] = "Комната вас не впустила.",
|
||||
[UI_MENU_COOP_N_NOT_OURS] = "Это не комната NX2navi.",
|
||||
[UI_MENU_COOP_N_OTHER_VERSION] = "У хоста комнаты другая версия NX2navi или игры: используйте одинаковые версии.",
|
||||
[UI_MENU_COOP_N_REMOVED] = "Хост удалил вас из комнаты.",
|
||||
[UI_MENU_COOP_N_HOST_SILENT] = "Хост комнаты не ответил.",
|
||||
[UI_MENU_COOP_N_LOST] = "Steam потерял соединение; комнаты больше нет.",
|
||||
[UI_MENU_COOP_N_LEFT] = "Вы вышли из комнаты.",
|
||||
[UI_MENU_COOP_LOCAL] = "Тестовый режим: замена Steam на этом ПК.",
|
||||
[UI_MENU_COOP_TOAST_INVITE] = "%s приглашает вас в комнату: откройте вкладку «Кооператив» в меню.",
|
||||
[UI_BOOT_TITLE] = "Подготовка шейдеров",
|
||||
[UI_BOOT_STARTING] = "Запуск", [UI_BOOT_SHADERS] = "Шейдеры: %lld из %lld", [UI_BOOT_PIPELINES] = "Конвейеры: %lld из %lld",
|
||||
[UI_BOOT_COMPUTE] = "Вычислительные конвейеры: %lld из %lld", [UI_BOOT_DRIVER_CACHE] = "Кэш драйвера: %lld из %lld",
|
||||
@@ -2163,151 +2061,96 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_SAVE_E_NEWER] = "%s foi feito por um NX2navi mais novo: atualize o NX2navi primeiro.",
|
||||
[UI_MENU_SAVE_E_DAMAGED] = "%s está danificado: baixe-o de novo.",
|
||||
[UI_MENU_SAVE_E_UNSAFE] = "%s foi recusado: contém arquivos fora de um save, links ou dados demais.",
|
||||
[UI_MENU_TAB_COOP] = "Cooperativo",
|
||||
[UI_MENU_COOP_ON] = "Cooperativo",
|
||||
[UI_MENU_COOP_ON_DESC] = "Jogue com amigos, cada um no seu próprio jogo e save: uma sala em um relay compartilha o "
|
||||
"progresso da história entre eles conforme as regras dela (docs/coop.md). Desligado: o jogo "
|
||||
"não usa a rede. Criar uma sala e Entrar em uma sala o ligam.",
|
||||
[UI_MENU_COOP_NAME] = "Seu nome",
|
||||
[UI_MENU_COOP_NAME_DESC] = "O nome que os outros jogadores da sala veem; o relay também o vê. No máximo 24 bytes. "
|
||||
"Vazio: Player- e quatro dígitos aleatórios.",
|
||||
[UI_MENU_COOP_AUTO] = "automático",
|
||||
[UI_MENU_COOP_SERVER] = "Endereço do relay",
|
||||
[UI_MENU_COOP_SERVER_DESC] = "O relay que conecta os jogos dos jogadores: host, host:porta ou [IPv6]:porta (porta 24680 "
|
||||
"se nenhuma for dada). Quem o executa (python tools/coop_relay.py) passa o endereço aos "
|
||||
"outros. O log e as informações do sistema não o mostram.",
|
||||
[UI_MENU_COOP_NONE] = "nenhum",
|
||||
[UI_MENU_COOP_MAKE] = "Criar uma sala",
|
||||
[UI_MENU_COOP_MAKE_DESC] = "Cria uma sala com um novo segredo de 18 caracteres, que você passa aos jogadores que "
|
||||
"convidar (por voz ou mensagem privada). Uma sala criada por você compartilha conforme as "
|
||||
"regras abaixo, e você pode mudá-las enquanto joga.",
|
||||
[UI_MENU_TAB_COOP] = "Co-op",
|
||||
[UI_MENU_COOP_ON] = "Co-op (experimental)",
|
||||
[UI_MENU_COOP_ON_DESC] = "Jogue com amigos pela Steam, cada um no seu jogo e no seu save. Ninguém configura roteador: "
|
||||
"salas e convites passam pela Steam, que mostra você jogando Spacewar, o app de teste dela. "
|
||||
"Precisa da Steam aberta; o launcher pega o arquivo da biblioteca da Steam de um jogo da Steam "
|
||||
"que você tem instalado. Desligado: o jogo não usa a rede.",
|
||||
[UI_MENU_COOP_NO_LIBRARY] = "O arquivo da biblioteca da Steam, steam_api64.dll, não está ao lado do jogo. O launcher o coloca "
|
||||
"lá ao iniciar o jogo, a partir de um jogo da Steam que você tem instalado: inicie o jogo pelo "
|
||||
"launcher, com a Steam e pelo menos um jogo de 2021 ou mais novo instalados. Você também pode "
|
||||
"copiar o arquivo da pasta de um jogo da Steam para a pasta do ocarina.exe.",
|
||||
[UI_MENU_COOP_OLD_LIBRARY] = "O steam_api64.dll ao lado do jogo é antigo demais para o co-op. Troque por um de um jogo mais "
|
||||
"novo da Steam.",
|
||||
[UI_MENU_COOP_NO_CLIENT] = "A Steam não respondeu. Abra a Steam, entre na sua conta e escolha Procurar a Steam de novo.",
|
||||
[UI_MENU_COOP_RETRY] = "Procurar a Steam de novo",
|
||||
[UI_MENU_COOP_RETRY_DESC] = "Tenta falar com a Steam agora; o jogo também tenta sozinho a cada poucos segundos.",
|
||||
[UI_MENU_COOP_CREATE] = "Criar uma sala",
|
||||
[UI_MENU_COOP_CREATE_DESC] = "Cria uma sala para até quatro jogadores. Você recebe um ID da sala para passar adiante e pode "
|
||||
"convidar amigos da Steam.",
|
||||
[UI_MENU_COOP_JOIN] = "Entrar em uma sala",
|
||||
[UI_MENU_COOP_JOIN_DESC] = "Entra na sala cujo segredo outro jogador lhe deu. Nada da sala chega ao seu save antes de "
|
||||
"você ver quem está nela e o que ela compartilha, e aceitá-la aqui.",
|
||||
[UI_MENU_COOP_NEED_SERVER] = "defina antes o endereço do relay",
|
||||
[UI_MENU_COOP_SECRET] = "Segredo da sala",
|
||||
[UI_MENU_COOP_SECRET_HINT] = "18 caracteres, como XXXXXX-XXXXXX-XXXXXX: maiúsculas ou minúsculas, com ou sem hífens.",
|
||||
[UI_MENU_COOP_SECRET_BAD] = "Isto não é um segredo de sala: ele tem 18 caracteres de 23456789BCDFGHJKMNPRSTVWXYZ.",
|
||||
[UI_MENU_COOP_PASTE] = "Colar", [UI_MENU_COOP_PASTE_EMPTY] = "A área de transferência não tem texto.",
|
||||
[UI_MENU_COOP_OK] = "OK", [UI_MENU_COOP_STOP] = "Parar",
|
||||
[UI_MENU_COOP_STOP_DESC] = "Para de tentar chegar à sala.",
|
||||
[UI_MENU_COOP_CONNECTING] = "Conectando: %s",
|
||||
[UI_MENU_COOP_RECONNECTING] = "O relay ficou em silêncio; voltando para a sala: %s",
|
||||
[UI_MENU_COOP_LEFT] = "Fora de uma sala: %s",
|
||||
[UI_MENU_COOP_NO_ROOM] = "Nenhuma sala aberta no relay tem este segredo: confira-o ou pergunte a quem criou a sala se "
|
||||
"ela ainda está aberta.",
|
||||
[UI_MENU_COOP_NOT_STARTED] = "O cooperativo não iniciou; o log diz por quê.",
|
||||
[UI_MENU_COOP_PLAYERS] = "Jogadores", [UI_MENU_COOP_YOU] = "você", [UI_MENU_COOP_MAKER] = "criou a sala",
|
||||
[UI_MENU_COOP_HEARD] = "ouvido há %u s", [UI_MENU_COOP_NOT_HEARD] = "ainda não ouvido", [UI_MENU_COOP_AWAY] = "ausente",
|
||||
[UI_MENU_COOP_MEMBER_DESC] = "Um jogador da sala. Ouvido: quando chegou a última mensagem dele selada com o segredo da "
|
||||
"sala; um jogador ainda não ouvido não mostrou que o conhece.",
|
||||
[UI_MENU_COOP_JOIN_DESC] = "Entra na sala cujo ID um amigo passou para você.",
|
||||
[UI_MENU_COOP_ROOM_ID] = "ID da sala",
|
||||
[UI_MENU_COOP_ROOM_ID_DESC] = "Os amigos digitam isto em Entrar em uma sala. Pressione para copiar. Quem tiver o ID pode "
|
||||
"entrar, então passe só para quem você quer no seu jogo.",
|
||||
[UI_MENU_COOP_ROOM_ID_HINT] = "8 letras e números, como XXXX-XXXX: maiúsculas ou minúsculas, com ou sem o traço.",
|
||||
[UI_MENU_COOP_ROOM_ID_BAD] = "Isto não é um ID de sala: veja se há algum caractere errado.",
|
||||
[UI_MENU_COOP_PASTE] = "Colar",
|
||||
[UI_MENU_COOP_PASTE_EMPTY] = "A área de transferência não tem texto.",
|
||||
[UI_MENU_COOP_COPIED] = "copiado",
|
||||
[UI_MENU_COOP_OK] = "OK",
|
||||
[UI_MENU_COOP_JOINING] = "Entrando na sala…",
|
||||
[UI_MENU_COOP_STOP] = "Parar",
|
||||
[UI_MENU_COOP_STOP_DESC] = "Para de tentar entrar na sala.",
|
||||
[UI_MENU_COOP_INVITE] = "Convidar um amigo",
|
||||
[UI_MENU_COOP_INVITE_DESC] = "Envia um convite da Steam a um amigo. Ele chega a quem está com o NX2navi aberto e o co-op "
|
||||
"ligado; os outros podem usar o ID da sala.",
|
||||
[UI_MENU_COOP_INVITE_TITLE] = "Convidar um amigo da Steam",
|
||||
[UI_MENU_COOP_INVITE_NONE] = "A Steam não mostra amigos.",
|
||||
[UI_MENU_COOP_INVITE_SENT] = "Convite enviado para %s.",
|
||||
[UI_MENU_COOP_INVITE_IN_GAME] = "no co-op agora",
|
||||
[UI_MENU_COOP_INVITE_ONLINE] = "online",
|
||||
[UI_MENU_COOP_INVITE_OFFLINE] = "offline",
|
||||
[UI_MENU_COOP_INVITE_STEAM] = "Janela de convites da Steam",
|
||||
[UI_MENU_COOP_INVITE_CLOSE] = "Fechar",
|
||||
[UI_MENU_COOP_INVITED] = "%s convida você para uma sala.",
|
||||
[UI_MENU_COOP_INVITED_JOIN] = "Entrar na sala",
|
||||
[UI_MENU_COOP_INVITED_JOIN_DESC] = "Entra na sala para a qual você foi convidado.",
|
||||
[UI_MENU_COOP_INVITED_NO] = "Agora não",
|
||||
[UI_MENU_COOP_INVITED_NO_DESC] = "Dispensa o convite.",
|
||||
[UI_MENU_COOP_PLAYERS] = "Jogadores",
|
||||
[UI_MENU_COOP_YOU] = "você",
|
||||
[UI_MENU_COOP_HOST] = "anfitrião",
|
||||
[UI_MENU_COOP_PLAYER_DESC] = "Um jogador da sala e a área em que o Link dele está.",
|
||||
[UI_MENU_COOP_PLAYER_REMOVE_DESC] = "Um jogador da sala. Como anfitrião, você pode pressionar para removê-lo da sala.",
|
||||
[UI_MENU_COOP_PLAYER_AWAY] = "fora do mundo",
|
||||
[UI_MENU_COOP_REMOVE] = "Remover",
|
||||
[UI_MENU_COOP_REMOVE_DESC] = "Como criador da sala, você pode remover um jogador pela chave dele: cada jogo descarta essa "
|
||||
"chave e devolve o que ela pegou dos estoques, e o relay desconecta o jogador e o recusa de "
|
||||
"novo. Quem conhece o segredo pode voltar com uma nova chave, e todos então recebem uma "
|
||||
"nova oferta para aceitar ou não; para ter certeza, crie uma nova sala.",
|
||||
[UI_MENU_COOP_REMOVE_CONFIRM] = "Remover %s da sala?",
|
||||
[UI_MENU_COOP_SECRET_DESC] = "Qualquer pessoa com o segredo pode entrar na sala: passe-o só aos jogadores que convidar, "
|
||||
"por voz ou mensagem privada. Ele só aparece quando você pede; esconda-o antes de "
|
||||
"compartilhar a tela. O relay nunca o conhece.",
|
||||
[UI_MENU_COOP_SHOW] = "pressione para mostrar", [UI_MENU_COOP_HIDE] = "pressione para esconder",
|
||||
[UI_MENU_COOP_COPY] = "Copiar o segredo",
|
||||
[UI_MENU_COOP_COPY_DESC] = "Coloca o segredo da sala na área de transferência, para colar em uma mensagem privada.",
|
||||
[UI_MENU_COOP_OFFER] = "Esta sala aguarda sua resposta",
|
||||
[UI_MENU_COOP_OFFER_WHO] = "Na sala: %s.", [UI_MENU_COOP_OFFER_NOBODY] = "ninguém mais ainda",
|
||||
[UI_MENU_COOP_OFFER_SHARED] = "Compartilhado por todos: %s.",
|
||||
[UI_MENU_COOP_OFFER_POOLED] = "Em um estoque comum para todos: %s.",
|
||||
[UI_MENU_COOP_OFFER_NOTHING] = "As regras não compartilham nada.",
|
||||
[UI_MENU_COOP_OFFER_COPY] = "Nada da sala chega ao seu save antes de você aceitar. Então todo o seu save (todos os "
|
||||
"slots) é primeiro copiado para coop-backup/<data e hora> na pasta do perfil, e só depois "
|
||||
"disso chega o progresso da sala.",
|
||||
[UI_MENU_COOP_OFFER_TRUST] = "Um jogador da sala pode fazer no seu mundo o que as regras compartilham (abrir um baú, "
|
||||
"gastar uma chave comum), e o jogo não pode desfazer: aceite só jogadores a quem você "
|
||||
"confiaria o seu save.",
|
||||
[UI_MENU_COOP_ANSWER] = "Aceitar ou não",
|
||||
[UI_MENU_COOP_ANSWER_DESC] = "Mostra a oferta com Aceitar e Agora não. Um novo jogador ou outras regras criam uma nova "
|
||||
"oferta, que aguarda sua resposta outra vez.",
|
||||
[UI_MENU_COOP_ACCEPT_CONFIRM] = "Aceitar esta sala?", [UI_MENU_COOP_ACCEPT] = "Aceitar",
|
||||
[UI_MENU_COOP_NOT_NOW] = "Agora não",
|
||||
[UI_MENU_COOP_ACCEPTED] = "Aceita: o progresso da sala chega ao seu save. O seu save como era está em coop-backup na "
|
||||
"pasta do perfil.",
|
||||
[UI_MENU_COOP_COPY_FAILED] = "Aceita, mas não foi possível copiar o seu save, então nada da sala é aplicado; o log diz "
|
||||
"por quê.",
|
||||
[UI_MENU_COOP_RULES_ROOM] = "Regras da sala", [UI_MENU_COOP_RULES_MINE] = "Regras de uma sala criada por você",
|
||||
[UI_MENU_COOP_RULES_UNKNOWN] = "As regras da sala ainda não chegaram.",
|
||||
[UI_MENU_COOP_RULES_CHANGE] = "Uma mudança é uma nova oferta: os outros não recebem mais nada da sala até aceitá-la.",
|
||||
[UI_MENU_COOP_RULES_SET_BY] = "definido por quem criou a sala", [UI_MENU_COOP_RULE_FOLLOWS] = "segue o Progresso",
|
||||
[UI_MENU_COOP_R_PROGRESS] = "Progresso", [UI_MENU_COOP_R_ITEMS] = "Itens", [UI_MENU_COOP_R_SONGS] = "Músicas",
|
||||
[UI_MENU_COOP_R_QUEST] = "Itens de missão", [UI_MENU_COOP_R_KEYS] = "Chaves pequenas", [UI_MENU_COOP_R_RUPEES] = "Rupias",
|
||||
[UI_MENU_COOP_R_AMMO] = "Munição",
|
||||
[UI_MENU_COOP_R_PROGRESS_DESC] = "Flags da história, do mundo e das masmorras: eventos, conversas, baús, portas, "
|
||||
"interruptores, chefes, mapa e bússola. Compartilhado: o que um jogador faz acontece "
|
||||
"em todos os mundos. Próprio: cada mundo mantém o seu, e as chaves pequenas também "
|
||||
"ficam próprias.",
|
||||
[UI_MENU_COOP_R_ITEMS_DESC] = "Equipamento, itens-chave, garrafas obtidas, tamanhos da carteira, da bolsa e da aljava, "
|
||||
"tamanho do medidor de magia; de uma quantidade, vence a maior. Próprio só é possível com "
|
||||
"Progresso próprio: num mundo compartilhado, um baú que um jogador abriu fica vazio para "
|
||||
"os outros.",
|
||||
[UI_MENU_COOP_R_SONGS_DESC] = "As músicas aprendidas. Próprio só é possível com Progresso próprio.",
|
||||
[UI_MENU_COOP_R_QUEST_DESC] = "Medalhões, pedras espirituais, a Pedra da Agonia e o cartão Gerudo. Próprio só é "
|
||||
"possível com Progresso próprio.",
|
||||
[UI_MENU_COOP_R_KEYS_DESC] = "Chaves pequenas, por masmorra. Estoque: uma chave que qualquer um pega vai para o estoque "
|
||||
"da masmorra, e uma porta que qualquer um abre tira uma. Próprio com Progresso próprio.",
|
||||
[UI_MENU_COOP_R_RUPEES_DESC] = "Estoque: uma carteira que todos os jogadores enchem e gastam. Próprio: cada um tem a sua.",
|
||||
[UI_MENU_COOP_R_AMMO_DESC] = "Bombas, bombchus, flechas, nozes deku, sementes e galhos, feijões mágicos. Estoque: uma "
|
||||
"quantidade que todos os jogadores enchem e gastam.",
|
||||
[UI_MENU_COOP_SHARED] = "compartilhado", [UI_MENU_COOP_OWN] = "próprio", [UI_MENU_COOP_POOL] = "estoque",
|
||||
[UI_MENU_COOP_REMOVE_CONFIRM] = "Remover %s da sala? Essa pessoa não poderá voltar a esta sala.",
|
||||
[UI_MENU_COOP_LEAVE] = "Sair da sala",
|
||||
[UI_MENU_COOP_LEAVE_DESC] = "Sai da sala. O que a sala deu ao seu save fica nele.",
|
||||
[UI_MENU_COOP_LEAVE_CONFIRM] = "Sair da sala? O que ela deu ao seu save fica.",
|
||||
[UI_MENU_COOP_LEAVE_MAKER] = "Você criou esta sala: enquanto estiver fora, ninguém pode mudar as regras nem remover um "
|
||||
"jogador, e se não houver mais ninguém nela, ela fecha.",
|
||||
[UI_MENU_COOP_LEAVE_DESC] = "Sai da sala. Seu jogo e seu save continuam como estão.",
|
||||
[UI_MENU_COOP_LEAVE_CONFIRM] = "Sair da sala?",
|
||||
[UI_MENU_COOP_LEAVE_HOST] = "Você é o anfitrião: a sala continua com outro jogador como anfitrião.",
|
||||
[UI_MENU_COOP_STAY] = "Ficar",
|
||||
[UI_MENU_COOP_TOAST_JOINED] = "%s entrou na sala", [UI_MENU_COOP_TOAST_LEFT] = "%s saiu da sala",
|
||||
[UI_MENU_COOP_TOAST_OFFER] = "A sala cooperativa aguarda sua resposta na aba Cooperativo do menu",
|
||||
[UI_MENU_COOP_LOST] = "O relay perdeu a sala; o jogo está voltando a ela.",
|
||||
[UI_MENU_COOP_JOIN_LIMIT] = "O relay não aceita mais entradas da sua rede por enquanto; o jogo tenta de novo em um minuto.",
|
||||
[UI_MENU_COOP_NOT_IDENTIFIED] = "não identificado", [UI_MENU_COOP_REMOVED] = "removido pelo criador",
|
||||
[UI_MENU_COOP_KEY] = "chave %s",
|
||||
[UI_MENU_COOP_OFFER_KEY] = "As regras são assinadas pela chave %s.",
|
||||
[UI_MENU_COOP_OFFER_COMPARE] = "Antes de aceitar, peça ao criador da sala que leia a chave dele para você, por voz ou "
|
||||
"chat, e compare-a com esta.",
|
||||
[UI_MENU_COOP_MY_KEY] = "Sua chave, que assina as regras desta sala: %s. Leia-a para os outros, por voz ou chat, para "
|
||||
"que possam compará-la antes de aceitar.",
|
||||
[UI_MENU_COOP_UNIDENTIFIED] = "Jogadores na sala que não estão identificados: %d (não disseram quem são, ou duas chaves "
|
||||
"dizem ser o mesmo jogador). Ninguém pode aceitar a sala enquanto eles estiverem nela: o "
|
||||
"criador pode removê-los, ou todos vão para uma nova sala.",
|
||||
[UI_MENU_COOP_DISAGREE] = "Os jogadores trazem regras assinadas por chaves diferentes: pergunte ao criador da sala qual "
|
||||
"chave é a dele antes de aceitar.",
|
||||
[UI_MENU_COOP_NEW_SAVE] = "Outro save é jogado nesta sala: ele recebe o progresso da sala, que inclui o que o último "
|
||||
"save trouxe.",
|
||||
[UI_MENU_COOP_WARNINGS] = "Antes de entrar em uma sala com desconhecidos",
|
||||
[UI_MENU_COOP_WARN_SAVE] = "1. Tenha um save para o qual possa voltar. Qualquer um que você aceitar pode definir flags da "
|
||||
"história no seu save, assim como quem essa pessoa aceitou; um jogador nos seus estoques pode "
|
||||
"esvaziar as chaves pequenas de uma masmorra. Nenhuma remoção desfaz uma flag: a cópia em "
|
||||
"coop-backup/first-<data e hora> desfaz.",
|
||||
[UI_MENU_COOP_WARN_ROOM] = "2. Sua aceitação é sua, a sala não. Os jogadores que você aceita repassam as flags dos "
|
||||
"jogadores que eles aceitaram, e só o criador decide quem pode usar os estoques. Se houver "
|
||||
"alguém que você não conhece na sala, não aceite: saia e peça ao criador uma nova sala.",
|
||||
[UI_MENU_COOP_WARN_KEY] = "3. Confira a chave do criador e guarde a sua. Compare a chave que assina as regras com a do "
|
||||
"criador, nunca inicie o jogo com configurações ou um script que alguém lhe passou, e nunca "
|
||||
"entregue uma cópia da sua pasta de perfil.",
|
||||
[UI_MENU_COOP_POOLS] = "Estoques",
|
||||
[UI_MENU_COOP_SPENT] = "pegou além do que trouxe: %lld chaves, %lld rupias, %lld munições",
|
||||
[UI_MENU_COOP_NOT_IN_ROOM] = "fora da sala",
|
||||
[UI_MENU_COOP_SPENT_NONE] = "Ninguém pegou dos estoques mais do que trouxe.",
|
||||
[UI_MENU_COOP_SPENT_DESC] = "Esta chave pegou dos estoques mais do que trouxe. Um jogador que usou chaves que outros "
|
||||
"acharam também aparece; alguém que ninguém esperava esvaziou os estoques. Remover a chave "
|
||||
"devolve o que ela pegou, em todos os jogos, também depois que o jogador saiu. Remova-a antes "
|
||||
"de redefinir os estoques: a redefinição mantém o que pegou um jogador que ainda está na sala.",
|
||||
[UI_MENU_COOP_RESET] = "Redefinir os estoques",
|
||||
[UI_MENU_COOP_RESET_DESC] = "Cada jogo entra de novo nos estoques com o que tinha para os jogadores na sala. Isso "
|
||||
"recupera um estoque que um jogador que saiu esvaziou; as flags ficam como estão. Um jogador "
|
||||
"que esvaziou um estoque e ainda está na sala fica com o que pegou: remova-o primeiro, depois redefina.",
|
||||
[UI_MENU_COOP_RESET_CONFIRM] = "Redefinir os estoques para todos na sala?",
|
||||
[UI_MENU_COOP_REMOVE_KEY_CONFIRM] = "Remover %s, chave %s, da sala?",
|
||||
[UI_MENU_COOP_NOT_ACCEPTED] = "Não aceito: a sala mudou ou alguém nela não está identificado. Veja a oferta de novo.",
|
||||
[UI_MENU_COOP_ACCEPTED_AS] = "uma chave que você aceitou como %s",
|
||||
[UI_MENU_COOP_CHAT] = "Chat",
|
||||
[UI_MENU_COOP_CHAT_WRITE] = "Escrever uma mensagem",
|
||||
[UI_MENU_COOP_CHAT_WRITE_DESC] = "Envia uma linha de texto a todos na sala.",
|
||||
[UI_MENU_COOP_SEND] = "Enviar",
|
||||
[UI_MENU_COOP_CHAT_JOINED] = "%s entrou na sala",
|
||||
[UI_MENU_COOP_CHAT_LEFT] = "%s saiu da sala",
|
||||
[UI_MENU_COOP_SETTINGS] = "Configurações do co-op",
|
||||
[UI_MENU_COOP_SHARE] = "Compartilhar progresso",
|
||||
[UI_MENU_COOP_SHARE_DESC] = "Em uma sala, o que qualquer um conquista vale para todos: história, baús, portas, itens e "
|
||||
"canções. Antes de algo da sala chegar ao seu save, ele é copiado para coop-backup na pasta do "
|
||||
"perfil. Chaves pequenas, rupias, munição e corações continuam seus. Desligado: só nomes e chat "
|
||||
"são compartilhados.",
|
||||
[UI_MENU_COOP_NAMES] = "Mostrar nomes dos jogadores",
|
||||
[UI_MENU_COOP_NAMES_DESC] = "Mostra o nome de cada outro jogador onde o Link dele está no seu mundo, com a distância. Precisa "
|
||||
"de DLSS, FSR ou TAA ligado (só assim o menu sabe para onde a câmera olha).",
|
||||
[UI_MENU_COOP_CHAT_SHOW] = "Mostrar o chat sobre o jogo",
|
||||
[UI_MENU_COOP_CHAT_SHOW_DESC] = "Novas linhas do chat e quem entrou ou saiu aparecem por alguns segundos com o menu fechado.",
|
||||
[UI_MENU_COOP_N_CREATE_FAILED] = "A Steam não conseguiu criar a sala. Tente de novo em instantes.",
|
||||
[UI_MENU_COOP_N_NO_ROOM] = "Nenhuma sala tem esse ID: confira, ou pergunte ao seu amigo se a sala ainda está aberta.",
|
||||
[UI_MENU_COOP_N_FULL] = "A sala está cheia.",
|
||||
[UI_MENU_COOP_N_REFUSED] = "A sala não deixou você entrar.",
|
||||
[UI_MENU_COOP_N_NOT_OURS] = "Essa não é uma sala do NX2navi.",
|
||||
[UI_MENU_COOP_N_OTHER_VERSION] = "O anfitrião da sala usa outra versão do NX2navi ou do jogo: usem as mesmas versões.",
|
||||
[UI_MENU_COOP_N_REMOVED] = "O anfitrião removeu você da sala.",
|
||||
[UI_MENU_COOP_N_HOST_SILENT] = "O anfitrião da sala não respondeu.",
|
||||
[UI_MENU_COOP_N_LOST] = "A Steam perdeu a conexão; a sala acabou.",
|
||||
[UI_MENU_COOP_N_LEFT] = "Você saiu da sala.",
|
||||
[UI_MENU_COOP_LOCAL] = "Modo de teste: um substituto da Steam neste PC.",
|
||||
[UI_MENU_COOP_TOAST_INVITE] = "%s convida você para uma sala: abra a aba Co-op do menu.",
|
||||
[UI_BOOT_TITLE] = "Preparando shaders",
|
||||
[UI_BOOT_STARTING] = "Iniciando", [UI_BOOT_SHADERS] = "Shaders: %lld de %lld", [UI_BOOT_PIPELINES] = "Pipelines: %lld de %lld",
|
||||
[UI_BOOT_COMPUTE] = "Pipelines de computação: %lld de %lld", [UI_BOOT_DRIVER_CACHE] = "Cache do driver: %lld de %lld",
|
||||
@@ -2974,119 +2817,84 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_SAVE_E_DAMAGED] = "%s 已损坏:请重新下载。",
|
||||
[UI_MENU_SAVE_E_UNSAFE] = "%s 被拒绝:其中含有存档以外的文件、链接或过多的数据。",
|
||||
[UI_MENU_TAB_COOP] = "合作",
|
||||
[UI_MENU_COOP_ON] = "合作",
|
||||
[UI_MENU_COOP_ON_DESC] = "与朋友一起玩,各自运行自己的游戏和存档:中继服务器上的房间按其规则在玩家之间共享剧情进度"
|
||||
"(docs/coop.md)。关闭:游戏完全不使用网络。“创建房间”和“加入房间”会将其打开。",
|
||||
[UI_MENU_COOP_NAME] = "你的名字",
|
||||
[UI_MENU_COOP_NAME_DESC] = "房间中其他玩家看到的名字,中继服务器也能看到。最多 24 字节。留空:Player- 加四位随机数字。",
|
||||
[UI_MENU_COOP_AUTO] = "自动",
|
||||
[UI_MENU_COOP_SERVER] = "中继地址",
|
||||
[UI_MENU_COOP_SERVER_DESC] = "连接各玩家游戏的中继服务器:host、host:port 或 [IPv6]:port(未指定时端口为 24680)。"
|
||||
"运行它的人(python tools/coop_relay.py)把地址告诉其他人。日志和系统信息不会显示它。",
|
||||
[UI_MENU_COOP_NONE] = "无",
|
||||
[UI_MENU_COOP_MAKE] = "创建房间",
|
||||
[UI_MENU_COOP_MAKE_DESC] = "创建一个带有新的 18 字符密钥的房间,由你告诉受邀的玩家(口头或私信)。你创建的房间按下方"
|
||||
"规则共享,游戏中也可以修改。",
|
||||
[UI_MENU_COOP_ON] = "合作(实验性)",
|
||||
[UI_MENU_COOP_ON_DESC] = "通过 Steam 与朋友一起玩,各自运行自己的游戏和存档。无需设置路由器:房间和邀请都经由 Steam,Steam 会显示你正在玩它的测试应用 Spacewar。需要 Steam "
|
||||
"正在运行;启动器会从你已安装的 Steam 游戏里取得 Steam 的库文件。关闭:游戏不使用网络。",
|
||||
[UI_MENU_COOP_NO_LIBRARY] = "游戏旁边没有 Steam 的库文件 steam_api64.dll。启动器在启动游戏时会从你已安装的 Steam 游戏里把它放到那里:请在安装了 Steam 和至少一款 2021 "
|
||||
"年或更新的游戏的情况下,从启动器启动游戏。你也可以自己从某个 Steam 游戏的文件夹里把这个文件复制到 ocarina.exe 所在的文件夹。",
|
||||
[UI_MENU_COOP_OLD_LIBRARY] = "游戏旁边的 steam_api64.dll 对合作模式来说太旧。请换成较新的 Steam 游戏里的那个文件。",
|
||||
[UI_MENU_COOP_NO_CLIENT] = "Steam 没有响应。请启动 Steam 并登录,然后选择“重新查找 Steam”。",
|
||||
[UI_MENU_COOP_RETRY] = "重新查找 Steam",
|
||||
[UI_MENU_COOP_RETRY_DESC] = "立即尝试连接 Steam;游戏每隔几秒也会自动尝试。",
|
||||
[UI_MENU_COOP_CREATE] = "创建房间",
|
||||
[UI_MENU_COOP_CREATE_DESC] = "创建一个最多四人的房间。你会得到一个可以告诉别人的房间 ID,也可以邀请 Steam 好友。",
|
||||
[UI_MENU_COOP_JOIN] = "加入房间",
|
||||
[UI_MENU_COOP_JOIN_DESC] = "加入其他玩家给你密钥的房间。在你看到房间里有谁、共享什么并在此接受之前,房间中的任何内容"
|
||||
"都不会进入你的存档。",
|
||||
[UI_MENU_COOP_NEED_SERVER] = "请先设置中继地址",
|
||||
[UI_MENU_COOP_SECRET] = "房间密钥",
|
||||
[UI_MENU_COOP_SECRET_HINT] = "18 个字符,形如 XXXXXX-XXXXXX-XXXXXX:大小写均可,带不带连字符均可。",
|
||||
[UI_MENU_COOP_SECRET_BAD] = "这不是房间密钥:密钥由 23456789BCDFGHJKMNPRSTVWXYZ 中的 18 个字符组成。",
|
||||
[UI_MENU_COOP_PASTE] = "粘贴", [UI_MENU_COOP_PASTE_EMPTY] = "剪贴板中没有文字。",
|
||||
[UI_MENU_COOP_OK] = "确定", [UI_MENU_COOP_STOP] = "停止",
|
||||
[UI_MENU_COOP_STOP_DESC] = "不再尝试进入房间。",
|
||||
[UI_MENU_COOP_CONNECTING] = "正在连接:%s",
|
||||
[UI_MENU_COOP_RECONNECTING] = "中继没有响应,正在重新进入房间:%s",
|
||||
[UI_MENU_COOP_LEFT] = "不在房间中:%s",
|
||||
[UI_MENU_COOP_NO_ROOM] = "中继上没有使用此密钥的开放房间:请检查密钥,或询问房主房间是否仍开放。",
|
||||
[UI_MENU_COOP_NOT_STARTED] = "合作未能启动,原因见日志。",
|
||||
[UI_MENU_COOP_PLAYERS] = "玩家", [UI_MENU_COOP_YOU] = "你", [UI_MENU_COOP_MAKER] = "房主",
|
||||
[UI_MENU_COOP_HEARD] = "%u 秒前有消息", [UI_MENU_COOP_NOT_HEARD] = "尚无消息", [UI_MENU_COOP_AWAY] = "离开",
|
||||
[UI_MENU_COOP_MEMBER_DESC] = "房间中的玩家。消息:其最近一条用房间密钥封装的消息到达的时间;尚无消息的玩家还没有证明"
|
||||
"自己知道密钥。",
|
||||
[UI_MENU_COOP_REMOVE] = "移除",
|
||||
[UI_MENU_COOP_REMOVE_DESC] = "作为房主,你可以按身份指纹移除玩家:每个游戏都会丢弃该身份并归还它从共用中取走的东西,"
|
||||
"中继会断开该玩家并拒绝其再次进入。知道房间密钥的人可以换一个新身份回来,届时所有人都会"
|
||||
"收到新的提议,可以接受或不接受;要确保安全,请创建新房间。",
|
||||
[UI_MENU_COOP_REMOVE_CONFIRM] = "将 %s 移出房间?",
|
||||
[UI_MENU_COOP_SECRET_DESC] = "任何拥有密钥的人都能加入房间:只通过口头或私信告诉受邀的玩家。只有在你要求时才显示;"
|
||||
"分享屏幕前请将其隐藏。中继永远不会知道它。",
|
||||
[UI_MENU_COOP_SHOW] = "按下以显示", [UI_MENU_COOP_HIDE] = "按下以隐藏",
|
||||
[UI_MENU_COOP_COPY] = "复制密钥",
|
||||
[UI_MENU_COOP_COPY_DESC] = "将房间密钥放入剪贴板,以便粘贴到私信中。",
|
||||
[UI_MENU_COOP_OFFER] = "此房间正等待你的答复",
|
||||
[UI_MENU_COOP_OFFER_WHO] = "房间中:%s。", [UI_MENU_COOP_OFFER_NOBODY] = "暂无其他人",
|
||||
[UI_MENU_COOP_OFFER_SHARED] = "所有人共享:%s。", [UI_MENU_COOP_OFFER_POOLED] = "所有人共用一份:%s。",
|
||||
[UI_MENU_COOP_OFFER_NOTHING] = "规则不共享任何内容。",
|
||||
[UI_MENU_COOP_OFFER_COPY] = "接受之前,房间中的任何内容都不会进入你的存档。接受后,会先把你的整个存档(所有存档位)"
|
||||
"复制到配置文件夹中的 coop-backup/<日期和时间>,之后房间的进度才会到来。",
|
||||
[UI_MENU_COOP_OFFER_TRUST] = "房间中的玩家可以在你的世界里做规则所共享的事(打开宝箱、花掉共用的钥匙),且游戏无法撤销:"
|
||||
"只接受你愿意托付存档的玩家。",
|
||||
[UI_MENU_COOP_ANSWER] = "接受与否",
|
||||
[UI_MENU_COOP_ANSWER_DESC] = "显示提议及“接受”和“暂不”。新玩家或其他规则会产生新的提议,再次等待你的答复。",
|
||||
[UI_MENU_COOP_ACCEPT_CONFIRM] = "接受此房间?", [UI_MENU_COOP_ACCEPT] = "接受", [UI_MENU_COOP_NOT_NOW] = "暂不",
|
||||
[UI_MENU_COOP_ACCEPTED] = "已接受:房间的进度会进入你的存档。你原来的存档在配置文件夹的 coop-backup 中。",
|
||||
[UI_MENU_COOP_COPY_FAILED] = "已接受,但无法复制你的存档,因此不会应用房间中的任何内容;原因见日志。",
|
||||
[UI_MENU_COOP_RULES_ROOM] = "房间规则", [UI_MENU_COOP_RULES_MINE] = "你创建的房间的规则",
|
||||
[UI_MENU_COOP_RULES_UNKNOWN] = "房间规则尚未到达。",
|
||||
[UI_MENU_COOP_RULES_CHANGE] = "修改即是新的提议:其他人在接受之前不会再从房间获取任何内容。",
|
||||
[UI_MENU_COOP_RULES_SET_BY] = "由房主设定", [UI_MENU_COOP_RULE_FOLLOWS] = "随“进度”而定",
|
||||
[UI_MENU_COOP_R_PROGRESS] = "进度", [UI_MENU_COOP_R_ITEMS] = "道具", [UI_MENU_COOP_R_SONGS] = "乐曲",
|
||||
[UI_MENU_COOP_R_QUEST] = "任务道具", [UI_MENU_COOP_R_KEYS] = "小钥匙", [UI_MENU_COOP_R_RUPEES] = "卢比",
|
||||
[UI_MENU_COOP_R_AMMO] = "弹药",
|
||||
[UI_MENU_COOP_R_PROGRESS_DESC] = "剧情、世界和迷宫的标志:事件、对话、宝箱、门、开关、头目、地图和指南针。共享:一名玩家"
|
||||
"做的事会在每个世界中发生。各自:每个世界保留自己的,此时小钥匙也各自独立。",
|
||||
[UI_MENU_COOP_R_ITEMS_DESC] = "装备、关键道具、拥有的瓶子、钱包、袋子和箭筒的容量、魔力槽的大小;数量取最大值。只有在"
|
||||
"“进度”为各自时才能设为各自:在共享的世界里,一名玩家打开的宝箱对其他人是空的。",
|
||||
[UI_MENU_COOP_R_SONGS_DESC] = "学会的乐曲。只有在“进度”为各自时才能设为各自。",
|
||||
[UI_MENU_COOP_R_QUEST_DESC] = "徽章、精灵石、痛苦之石和格鲁德会员证。只有在“进度”为各自时才能设为各自。",
|
||||
[UI_MENU_COOP_R_KEYS_DESC] = "小钥匙,按迷宫计。共用:任何人捡到的钥匙进入该迷宫的共用数量,任何人开门都会用掉一把。"
|
||||
"“进度”为各自时为各自。",
|
||||
[UI_MENU_COOP_R_RUPEES_DESC] = "共用:所有玩家共同存入和花费的一个钱包。各自:每人有自己的。",
|
||||
[UI_MENU_COOP_R_AMMO_DESC] = "炸弹、炸弹老鼠、箭、德库坚果、种子和木棒、魔豆。共用:所有玩家共同增加和消耗的一个数量。",
|
||||
[UI_MENU_COOP_SHARED] = "共享", [UI_MENU_COOP_OWN] = "各自", [UI_MENU_COOP_POOL] = "共用",
|
||||
[UI_MENU_COOP_JOIN_DESC] = "加入朋友给你的房间 ID 对应的房间。",
|
||||
[UI_MENU_COOP_ROOM_ID] = "房间 ID",
|
||||
[UI_MENU_COOP_ROOM_ID_DESC] = "朋友在“加入房间”里输入它。按下即可复制。拿到它的人都能加入,所以只告诉你想一起玩的人。",
|
||||
[UI_MENU_COOP_ROOM_ID_HINT] = "8 位字母和数字,形如 XXXX-XXXX:不分大小写,带不带连字符都可以。",
|
||||
[UI_MENU_COOP_ROOM_ID_BAD] = "这不是房间 ID:请检查是否输错了字符。",
|
||||
[UI_MENU_COOP_PASTE] = "粘贴",
|
||||
[UI_MENU_COOP_PASTE_EMPTY] = "剪贴板里没有文字。",
|
||||
[UI_MENU_COOP_COPIED] = "已复制",
|
||||
[UI_MENU_COOP_OK] = "确定",
|
||||
[UI_MENU_COOP_JOINING] = "正在进入房间…",
|
||||
[UI_MENU_COOP_STOP] = "停止",
|
||||
[UI_MENU_COOP_STOP_DESC] = "停止尝试进入房间。",
|
||||
[UI_MENU_COOP_INVITE] = "邀请好友",
|
||||
[UI_MENU_COOP_INVITE_DESC] = "向好友发送 Steam 邀请。只有正在运行 NX2navi 并开启了合作模式的好友能收到;其他人可以使用房间 ID。",
|
||||
[UI_MENU_COOP_INVITE_TITLE] = "邀请 Steam 好友",
|
||||
[UI_MENU_COOP_INVITE_NONE] = "Steam 没有显示任何好友。",
|
||||
[UI_MENU_COOP_INVITE_SENT] = "已向 %s 发送邀请。",
|
||||
[UI_MENU_COOP_INVITE_IN_GAME] = "正在合作模式中",
|
||||
[UI_MENU_COOP_INVITE_ONLINE] = "在线",
|
||||
[UI_MENU_COOP_INVITE_OFFLINE] = "离线",
|
||||
[UI_MENU_COOP_INVITE_STEAM] = "Steam 的邀请窗口",
|
||||
[UI_MENU_COOP_INVITE_CLOSE] = "关闭",
|
||||
[UI_MENU_COOP_INVITED] = "%s 邀请你加入房间。",
|
||||
[UI_MENU_COOP_INVITED_JOIN] = "加入对方的房间",
|
||||
[UI_MENU_COOP_INVITED_JOIN_DESC] = "加入邀请你的那个房间。",
|
||||
[UI_MENU_COOP_INVITED_NO] = "暂不",
|
||||
[UI_MENU_COOP_INVITED_NO_DESC] = "忽略这次邀请。",
|
||||
[UI_MENU_COOP_PLAYERS] = "玩家",
|
||||
[UI_MENU_COOP_YOU] = "你",
|
||||
[UI_MENU_COOP_HOST] = "房主",
|
||||
[UI_MENU_COOP_PLAYER_DESC] = "房间里的一名玩家,以及其林克所在的区域。",
|
||||
[UI_MENU_COOP_PLAYER_REMOVE_DESC] = "房间里的一名玩家。作为房主,你可以按下将其移出房间。",
|
||||
[UI_MENU_COOP_PLAYER_AWAY] = "不在世界中",
|
||||
[UI_MENU_COOP_REMOVE] = "移出",
|
||||
[UI_MENU_COOP_REMOVE_CONFIRM] = "将 %s 移出房间?对方将无法再回到这个房间。",
|
||||
[UI_MENU_COOP_LEAVE] = "离开房间",
|
||||
[UI_MENU_COOP_LEAVE_DESC] = "离开房间。房间给你存档的内容会保留。",
|
||||
[UI_MENU_COOP_LEAVE_CONFIRM] = "离开房间?它给你存档的内容会保留。",
|
||||
[UI_MENU_COOP_LEAVE_MAKER] = "这个房间是你创建的:你不在时,没人能修改规则或移除玩家;如果房间里没有其他人,它会关闭。",
|
||||
[UI_MENU_COOP_LEAVE_DESC] = "离开房间。你的游戏和存档保持现状。",
|
||||
[UI_MENU_COOP_LEAVE_CONFIRM] = "离开房间?",
|
||||
[UI_MENU_COOP_LEAVE_HOST] = "你是房主:房间会继续存在,由另一名玩家担任房主。",
|
||||
[UI_MENU_COOP_STAY] = "留下",
|
||||
[UI_MENU_COOP_TOAST_JOINED] = "%s 加入了房间", [UI_MENU_COOP_TOAST_LEFT] = "%s 离开了房间",
|
||||
[UI_MENU_COOP_TOAST_OFFER] = "合作房间正在菜单的“合作”页等待你的答复",
|
||||
[UI_MENU_COOP_LOST] = "中继丢失了房间;游戏正在重新进入。",
|
||||
[UI_MENU_COOP_JOIN_LIMIT] = "中继暂时不再接受来自你的网络的加入;游戏会在一分钟后重试。",
|
||||
[UI_MENU_COOP_NOT_IDENTIFIED] = "未表明身份", [UI_MENU_COOP_REMOVED] = "已被房主移除",
|
||||
[UI_MENU_COOP_KEY] = "身份指纹 %s",
|
||||
[UI_MENU_COOP_OFFER_KEY] = "规则由身份指纹为 %s 的玩家签署。",
|
||||
[UI_MENU_COOP_OFFER_COMPARE] = "接受之前,请房主通过语音或聊天把他的身份指纹读给你,并与这里的比对。",
|
||||
[UI_MENU_COOP_MY_KEY] = "你的身份指纹(用于签署此房间的规则):%s。请通过语音或聊天读给其他人,以便他们在接受前比对。",
|
||||
[UI_MENU_COOP_UNIDENTIFIED] = "房间中未确认身份的玩家:%d(尚未表明身份,或有两个身份指纹自称是同一名玩家)。只要他们还在"
|
||||
"房间里,任何人都无法接受此房间:房主可以移除他们,或者大家换到新房间。",
|
||||
[UI_MENU_COOP_DISAGREE] = "玩家们携带的规则由不同的身份签署:接受之前,请向房主确认哪个身份指纹是他的。",
|
||||
[UI_MENU_COOP_NEW_SAVE] = "此房间中正在玩另一个存档:它会得到房间的进度,其中包含上一个存档带来的内容。",
|
||||
[UI_MENU_COOP_WARNINGS] = "与陌生人进入房间之前",
|
||||
[UI_MENU_COOP_WARN_SAVE] = "1. 保留一个可以回退的存档。你接受的任何人都能在你的存档中设置剧情标记,他们接受的人也一样;"
|
||||
"共用中的玩家可以用光一个迷宫的小钥匙。移除玩家不会撤销标记:coop-backup/first-<日期和时间> "
|
||||
"中的副本才能。",
|
||||
[UI_MENU_COOP_WARN_ROOM] = "2. 接受与否由你决定,房间却不由你决定。你接受的玩家会转交他们所接受的玩家的标记,而谁能使用"
|
||||
"共用只由房主决定。如果房间里有你不认识的人,不要接受:离开,并请房主开一个新房间。",
|
||||
[UI_MENU_COOP_WARN_KEY] = "3. 核对房主的身份指纹,并保管好你自己的。把签署规则的身份指纹与房主的比对;绝不要用别人给你的"
|
||||
"设置或脚本启动游戏;绝不要交出你的配置文件夹的副本。",
|
||||
[UI_MENU_COOP_POOLS] = "共用",
|
||||
[UI_MENU_COOP_SPENT] = "超出所带来的部分取走了:%lld 把钥匙、%lld 卢比、%lld 份弹药",
|
||||
[UI_MENU_COOP_NOT_IN_ROOM] = "不在房间中",
|
||||
[UI_MENU_COOP_SPENT_NONE] = "没有人从共用中取走的比带来的多。",
|
||||
[UI_MENU_COOP_SPENT_DESC] = "这个身份从共用中取走的比带来的多。用了别人找到的钥匙的玩家也会列在这里;没人预料到的那个人"
|
||||
"掏空了共用。移除这个身份会在所有游戏中归还它取走的东西,玩家离开后也是如此。请在重置共用之前"
|
||||
"移除它:重置时仍在房间中的玩家会保留已取走的东西。",
|
||||
[UI_MENU_COOP_RESET] = "重置共用",
|
||||
[UI_MENU_COOP_RESET_DESC] = "每个游戏都会带着它为房间中玩家保存的数量重新加入共用。这能恢复被已离开的玩家掏空的共用;"
|
||||
"标记保持不变。掏空了共用且仍在房间中的玩家会保留已取走的东西:先移除,再重置。",
|
||||
[UI_MENU_COOP_RESET_CONFIRM] = "为房间中的所有人重置共用?",
|
||||
[UI_MENU_COOP_REMOVE_KEY_CONFIRM] = "将 %s(身份指纹 %s)移出房间?",
|
||||
[UI_MENU_COOP_NOT_ACCEPTED] = "未接受:房间已变化,或其中有玩家未确认身份。请重新查看提议。",
|
||||
[UI_MENU_COOP_ACCEPTED_AS] = "你曾以“%s”之名接受的身份指纹",
|
||||
[UI_MENU_COOP_CHAT] = "聊天",
|
||||
[UI_MENU_COOP_CHAT_WRITE] = "写消息",
|
||||
[UI_MENU_COOP_CHAT_WRITE_DESC] = "向房间里的所有人发送一行文字。",
|
||||
[UI_MENU_COOP_SEND] = "发送",
|
||||
[UI_MENU_COOP_CHAT_JOINED] = "%s 加入了房间",
|
||||
[UI_MENU_COOP_CHAT_LEFT] = "%s 离开了房间",
|
||||
[UI_MENU_COOP_SETTINGS] = "合作设置",
|
||||
[UI_MENU_COOP_SHARE] = "共享进度",
|
||||
[UI_MENU_COOP_SHARE_DESC] = "在房间里,任何人取得的进展都算作所有人的:剧情、宝箱、门、道具和乐曲。在房间里的任何内容写入你的存档之前,存档会先复制到配置文件夹里的 "
|
||||
"coop-backup。小钥匙、卢比、弹药和心保持各自独立。关闭:只共享名字和聊天。",
|
||||
[UI_MENU_COOP_NAMES] = "显示玩家名字",
|
||||
[UI_MENU_COOP_NAMES_DESC] = "在其他玩家的林克所处的位置显示其名字和距离。需要开启 DLSS、FSR 或 TAA(只有这样菜单才知道摄像机的朝向)。",
|
||||
[UI_MENU_COOP_CHAT_SHOW] = "在游戏画面上显示聊天",
|
||||
[UI_MENU_COOP_CHAT_SHOW_DESC] = "菜单关闭时,新的聊天内容以及玩家加入或离开的提示会显示几秒钟。",
|
||||
[UI_MENU_COOP_N_CREATE_FAILED] = "Steam 无法创建房间。请稍后再试。",
|
||||
[UI_MENU_COOP_N_NO_ROOM] = "没有使用这个 ID 的房间:请检查一下,或者问问朋友房间是否还开着。",
|
||||
[UI_MENU_COOP_N_FULL] = "房间已满。",
|
||||
[UI_MENU_COOP_N_REFUSED] = "房间没有让你进入。",
|
||||
[UI_MENU_COOP_N_NOT_OURS] = "那不是 NX2navi 的房间。",
|
||||
[UI_MENU_COOP_N_OTHER_VERSION] = "房主使用的 NX2navi 或游戏版本与你不同:请使用相同的版本。",
|
||||
[UI_MENU_COOP_N_REMOVED] = "房主已将你移出房间。",
|
||||
[UI_MENU_COOP_N_HOST_SILENT] = "房主没有响应。",
|
||||
[UI_MENU_COOP_N_LOST] = "Steam 断开了连接;房间已不存在。",
|
||||
[UI_MENU_COOP_N_LEFT] = "你已离开房间。",
|
||||
[UI_MENU_COOP_LOCAL] = "测试模式:在本机上代替 Steam。",
|
||||
[UI_MENU_COOP_TOAST_INVITE] = "%s 邀请你加入房间:请打开菜单的“合作”页。",
|
||||
[UI_BOOT_TITLE] = "正在准备着色器",
|
||||
[UI_BOOT_STARTING] = "正在启动", [UI_BOOT_SHADERS] = "着色器:%lld / %lld", [UI_BOOT_PIPELINES] = "管线:%lld / %lld",
|
||||
[UI_BOOT_COMPUTE] = "计算管线:%lld / %lld", [UI_BOOT_DRIVER_CACHE] = "驱动缓存:%lld / %lld",
|
||||
|
||||
@@ -279,50 +279,27 @@ typedef enum {
|
||||
UI_MENU_SAVE_E_STAGE,
|
||||
UI_MENU_SAVE_E_NOT_SAVE, UI_MENU_SAVE_E_OTHER_GAME, UI_MENU_SAVE_E_NEWER, UI_MENU_SAVE_E_DAMAGED,
|
||||
UI_MENU_SAVE_E_UNSAFE,
|
||||
// the Co-op tab (ui/coop_page.cpp, docs/coop.md)
|
||||
UI_MENU_TAB_COOP,
|
||||
UI_MENU_COOP_ON, UI_MENU_COOP_ON_DESC,
|
||||
UI_MENU_COOP_NAME, UI_MENU_COOP_NAME_DESC, UI_MENU_COOP_AUTO,
|
||||
UI_MENU_COOP_SERVER, UI_MENU_COOP_SERVER_DESC, UI_MENU_COOP_NONE,
|
||||
UI_MENU_COOP_MAKE, UI_MENU_COOP_MAKE_DESC, UI_MENU_COOP_JOIN, UI_MENU_COOP_JOIN_DESC,
|
||||
UI_MENU_COOP_NEED_SERVER, // under Make and Join while no relay is set
|
||||
UI_MENU_COOP_SECRET, UI_MENU_COOP_SECRET_HINT, UI_MENU_COOP_SECRET_BAD, UI_MENU_COOP_PASTE, UI_MENU_COOP_PASTE_EMPTY,
|
||||
UI_MENU_COOP_OK, UI_MENU_COOP_STOP, UI_MENU_COOP_STOP_DESC,
|
||||
UI_MENU_COOP_CONNECTING, UI_MENU_COOP_RECONNECTING, UI_MENU_COOP_LEFT, // "%s": the co-op layer's reason (English)
|
||||
UI_MENU_COOP_NO_ROOM, UI_MENU_COOP_NOT_STARTED,
|
||||
UI_MENU_COOP_PLAYERS, UI_MENU_COOP_YOU, UI_MENU_COOP_MAKER, UI_MENU_COOP_HEARD /* "%u": seconds */,
|
||||
UI_MENU_COOP_NOT_HEARD, UI_MENU_COOP_AWAY, UI_MENU_COOP_MEMBER_DESC,
|
||||
UI_MENU_COOP_REMOVE, UI_MENU_COOP_REMOVE_DESC, UI_MENU_COOP_REMOVE_CONFIRM /* "%s": the player's name */,
|
||||
UI_MENU_COOP_SECRET_DESC, UI_MENU_COOP_SHOW, UI_MENU_COOP_HIDE, UI_MENU_COOP_COPY, UI_MENU_COOP_COPY_DESC,
|
||||
UI_MENU_COOP_OFFER, UI_MENU_COOP_OFFER_WHO /* "%s": names */, UI_MENU_COOP_OFFER_NOBODY,
|
||||
UI_MENU_COOP_OFFER_SHARED, UI_MENU_COOP_OFFER_POOLED /* "%s": rule names */, UI_MENU_COOP_OFFER_NOTHING,
|
||||
UI_MENU_COOP_OFFER_COPY, UI_MENU_COOP_OFFER_TRUST,
|
||||
UI_MENU_COOP_ANSWER, UI_MENU_COOP_ANSWER_DESC, UI_MENU_COOP_ACCEPT_CONFIRM, UI_MENU_COOP_ACCEPT, UI_MENU_COOP_NOT_NOW,
|
||||
UI_MENU_COOP_ACCEPTED, UI_MENU_COOP_COPY_FAILED,
|
||||
UI_MENU_COOP_RULES_ROOM, UI_MENU_COOP_RULES_MINE, UI_MENU_COOP_RULES_UNKNOWN, UI_MENU_COOP_RULES_CHANGE,
|
||||
UI_MENU_COOP_RULES_SET_BY, UI_MENU_COOP_RULE_FOLLOWS,
|
||||
UI_MENU_COOP_R_PROGRESS, UI_MENU_COOP_R_ITEMS, UI_MENU_COOP_R_SONGS, UI_MENU_COOP_R_QUEST, UI_MENU_COOP_R_KEYS,
|
||||
UI_MENU_COOP_R_RUPEES, UI_MENU_COOP_R_AMMO, // in coop_state.h's category order, as are the descriptions
|
||||
UI_MENU_COOP_R_PROGRESS_DESC, UI_MENU_COOP_R_ITEMS_DESC, UI_MENU_COOP_R_SONGS_DESC, UI_MENU_COOP_R_QUEST_DESC,
|
||||
UI_MENU_COOP_R_KEYS_DESC, UI_MENU_COOP_R_RUPEES_DESC, UI_MENU_COOP_R_AMMO_DESC,
|
||||
UI_MENU_COOP_SHARED, UI_MENU_COOP_OWN, UI_MENU_COOP_POOL,
|
||||
UI_MENU_COOP_LEAVE, UI_MENU_COOP_LEAVE_DESC, UI_MENU_COOP_LEAVE_CONFIRM, UI_MENU_COOP_LEAVE_MAKER, UI_MENU_COOP_STAY,
|
||||
UI_MENU_COOP_TOAST_JOINED, UI_MENU_COOP_TOAST_LEFT /* "%s": a name */, UI_MENU_COOP_TOAST_OFFER,
|
||||
// what the hardened layer adds to the Co-op tab: the relay's states, keys and identification, the maker's key, the
|
||||
// three warnings before the first Accept, the pools' contributors and the maker's reset
|
||||
UI_MENU_COOP_LOST, UI_MENU_COOP_JOIN_LIMIT,
|
||||
UI_MENU_COOP_NOT_IDENTIFIED, UI_MENU_COOP_REMOVED, UI_MENU_COOP_KEY /* "%s": a key's fingerprint */,
|
||||
UI_MENU_COOP_OFFER_KEY /* "%s": a key's fingerprint */, UI_MENU_COOP_OFFER_COMPARE,
|
||||
UI_MENU_COOP_MY_KEY /* "%s": a key's fingerprint */,
|
||||
UI_MENU_COOP_UNIDENTIFIED /* "%d": players */, UI_MENU_COOP_DISAGREE, UI_MENU_COOP_NEW_SAVE,
|
||||
UI_MENU_COOP_WARNINGS, UI_MENU_COOP_WARN_SAVE, UI_MENU_COOP_WARN_ROOM, UI_MENU_COOP_WARN_KEY,
|
||||
UI_MENU_COOP_POOLS, UI_MENU_COOP_SPENT /* "%lld": keys, rupees, ammunition */, UI_MENU_COOP_NOT_IN_ROOM,
|
||||
UI_MENU_COOP_SPENT_NONE, UI_MENU_COOP_SPENT_DESC,
|
||||
UI_MENU_COOP_RESET, UI_MENU_COOP_RESET_DESC, UI_MENU_COOP_RESET_CONFIRM,
|
||||
UI_MENU_COOP_REMOVE_KEY_CONFIRM /* "%s": the player's name, "%s": the key's fingerprint */, UI_MENU_COOP_NOT_ACCEPTED,
|
||||
// a key the player accepted, now signed under another name: a new offer (CoopOfferMember.accepted_as)
|
||||
UI_MENU_COOP_ACCEPTED_AS /* "%s": the name it was accepted under */,
|
||||
UI_MENU_LAST_ID = UI_MENU_COOP_ACCEPTED_AS,
|
||||
// the Co-op tab and what co-op draws over the game (ui/coop_page.cpp, docs/coop.md)
|
||||
UI_MENU_TAB_COOP, UI_MENU_COOP_ON, UI_MENU_COOP_ON_DESC, UI_MENU_COOP_NO_LIBRARY, UI_MENU_COOP_OLD_LIBRARY,
|
||||
UI_MENU_COOP_NO_CLIENT, UI_MENU_COOP_RETRY, UI_MENU_COOP_RETRY_DESC, UI_MENU_COOP_CREATE,
|
||||
UI_MENU_COOP_CREATE_DESC, UI_MENU_COOP_JOIN, UI_MENU_COOP_JOIN_DESC, UI_MENU_COOP_ROOM_ID,
|
||||
UI_MENU_COOP_ROOM_ID_DESC, UI_MENU_COOP_ROOM_ID_HINT, UI_MENU_COOP_ROOM_ID_BAD, UI_MENU_COOP_PASTE,
|
||||
UI_MENU_COOP_PASTE_EMPTY, UI_MENU_COOP_COPIED, UI_MENU_COOP_OK, UI_MENU_COOP_JOINING, UI_MENU_COOP_STOP,
|
||||
UI_MENU_COOP_STOP_DESC, UI_MENU_COOP_INVITE, UI_MENU_COOP_INVITE_DESC, UI_MENU_COOP_INVITE_TITLE,
|
||||
UI_MENU_COOP_INVITE_NONE, UI_MENU_COOP_INVITE_SENT, UI_MENU_COOP_INVITE_IN_GAME, UI_MENU_COOP_INVITE_ONLINE,
|
||||
UI_MENU_COOP_INVITE_OFFLINE, UI_MENU_COOP_INVITE_STEAM, UI_MENU_COOP_INVITE_CLOSE, UI_MENU_COOP_INVITED,
|
||||
UI_MENU_COOP_INVITED_JOIN, UI_MENU_COOP_INVITED_JOIN_DESC, UI_MENU_COOP_INVITED_NO,
|
||||
UI_MENU_COOP_INVITED_NO_DESC, UI_MENU_COOP_PLAYERS, UI_MENU_COOP_YOU, UI_MENU_COOP_HOST,
|
||||
UI_MENU_COOP_PLAYER_DESC, UI_MENU_COOP_PLAYER_REMOVE_DESC, UI_MENU_COOP_PLAYER_AWAY, UI_MENU_COOP_REMOVE,
|
||||
UI_MENU_COOP_REMOVE_CONFIRM, UI_MENU_COOP_LEAVE, UI_MENU_COOP_LEAVE_DESC, UI_MENU_COOP_LEAVE_CONFIRM,
|
||||
UI_MENU_COOP_LEAVE_HOST, UI_MENU_COOP_STAY, UI_MENU_COOP_CHAT, UI_MENU_COOP_CHAT_WRITE,
|
||||
UI_MENU_COOP_CHAT_WRITE_DESC, UI_MENU_COOP_SEND, UI_MENU_COOP_CHAT_JOINED, UI_MENU_COOP_CHAT_LEFT,
|
||||
UI_MENU_COOP_SETTINGS, UI_MENU_COOP_SHARE, UI_MENU_COOP_SHARE_DESC, UI_MENU_COOP_NAMES, UI_MENU_COOP_NAMES_DESC,
|
||||
UI_MENU_COOP_CHAT_SHOW, UI_MENU_COOP_CHAT_SHOW_DESC, UI_MENU_COOP_N_CREATE_FAILED, UI_MENU_COOP_N_NO_ROOM,
|
||||
UI_MENU_COOP_N_FULL, UI_MENU_COOP_N_REFUSED, UI_MENU_COOP_N_NOT_OURS, UI_MENU_COOP_N_OTHER_VERSION,
|
||||
UI_MENU_COOP_N_REMOVED, UI_MENU_COOP_N_HOST_SILENT, UI_MENU_COOP_N_LOST, UI_MENU_COOP_N_LEFT,
|
||||
UI_MENU_COOP_LOCAL, UI_MENU_COOP_TOAST_INVITE,
|
||||
UI_MENU_LAST_ID = UI_MENU_COOP_TOAST_INVITE,
|
||||
// the boot screen while the boot prewarm prepares shaders and pipelines (boot.c, ui/menu.cpp menu_boot_frame)
|
||||
UI_BOOT_TITLE, UI_BOOT_STARTING,
|
||||
UI_BOOT_SHADERS, UI_BOOT_PIPELINES, // printf: "%lld" done, "%lld" total
|
||||
|
||||
Reference in New Issue
Block a user