mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 02:09:57 -04:00
Merge co-op, off by default: rooms through a relay, progress sync between the players' own saves, and a Co-op tab.
Without the other players drawn in the world, which are unfinished. No relay address is built in, and with co-op off nothing opens a socket. Built on Windows and tested against a relay on this PC only; two games in one room and any real network have not been tried. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -359,6 +359,7 @@ void plat_file_delete(const char *path);
|
||||
int plat_file_truncate(const char *path, uint64_t size); // 1 on success
|
||||
int64_t plat_file_size(const char *path); // bytes of a file, -1 when missing or unreadable
|
||||
int plat_file_set_readonly(const char *path, int on); // sets or clears the read-only attribute; 1 on success
|
||||
int plat_file_private(const char *path); // only this account may read it (0600, a folder 0700); 1 on success
|
||||
// A file that only grows and other processes may read meanwhile: each write lands whole at its end, from any thread,
|
||||
// and reaches the file even if the process dies right after (no user-space buffer, no flush to the disk).
|
||||
typedef struct PlatAppend PlatAppend;
|
||||
@@ -447,8 +448,12 @@ 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" and "Open log folder"
|
||||
// ---- desktop: the in-game menu's "Copy system info", "Open log folder" and the Co-op tab's secret
|
||||
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
|
||||
// gfx_window_paste (ui/menu.h).
|
||||
int plat_clipboard_get(char *out, size_t cap);
|
||||
int plat_open_folder(const char *path); // shows the folder in the file manager; 1 on success
|
||||
|
||||
// ---- dynamic libraries: a library some machines lack (a GPU vendor's), loaded at run time. A bare name is searched
|
||||
@@ -519,6 +524,34 @@ 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
|
||||
// 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.
|
||||
typedef struct PlatUdp PlatUdp;
|
||||
typedef struct { uint8_t b[32]; } PlatAddr;
|
||||
// host (a name, or an IPv4 or IPv6 literal without brackets) and port into *out. Blocks while the resolver runs: call
|
||||
// it on a thread that may wait, never on the game's. An IPv4 answer is preferred over an IPv6 one. 1 on success.
|
||||
int plat_net_resolve(const char *host, uint16_t port, PlatAddr *out);
|
||||
// A non-blocking UDP socket bound to port (0: any free port) on every local address. dual_stack 1: IPv6 with IPv4 in the
|
||||
// same socket (IPv4 alone where the machine has no IPv6); 0: IPv4 only. NULL on failure.
|
||||
PlatUdp *plat_udp_open(uint16_t port, int dual_stack);
|
||||
uint16_t plat_udp_port(const PlatUdp *u); // the port it is bound to; 0 on failure
|
||||
// One datagram to *to; never blocks. 1 when it was sent or the OS dropped it (a full send buffer, no route, an ICMP
|
||||
// error: a datagram may be lost anyway), 0 when it can never be sent (too long, an address the socket cannot reach).
|
||||
int plat_udp_send(PlatUdp *u, const PlatAddr *to, const void *p, size_t n);
|
||||
// The next datagram into buf, waiting at most ms for it; *from (may be NULL) gets its sender. Bytes received (a datagram
|
||||
// longer than cap is cut to cap), 0 when none came in time, -1 when the socket is unusable.
|
||||
int plat_udp_recv(PlatUdp *u, void *buf, size_t cap, PlatAddr *from, uint32_t ms);
|
||||
void plat_udp_close(PlatUdp *u);
|
||||
// Address helpers that need no OS (common.c); the back ends build addresses with plat_addr_set.
|
||||
void plat_addr_set(PlatAddr *a, const uint8_t ip[16], uint16_t port, uint32_t scope);
|
||||
void plat_addr_get(const PlatAddr *a, uint8_t ip[16], uint32_t *scope);
|
||||
uint16_t plat_addr_port(const PlatAddr *a);
|
||||
int plat_addr_eq(const PlatAddr *a, const PlatAddr *b);
|
||||
// "1.2.3.4:5" or "[::1]:5" ("%scope" after a link-local address) into out; its length, 0 when it does not fit cap.
|
||||
int plat_addr_str(const PlatAddr *a, char *out, size_t cap);
|
||||
|
||||
// ---- restart: this program again, in a new process that starts once this one is gone
|
||||
// Starts this executable again with the same command line, environment and working folder, and no handle of this
|
||||
// process. 1 when it started; the caller then exits.
|
||||
|
||||
Reference in New Issue
Block a user