Files
psxrecomp/runtime/include/netplay_exit_reason.h
T
Alexandros Mandravillis 5c7a37146c netplay: say why a match ended, and end a boot mismatch in 3 s
A netplay match that ends early returns both players to the lobby. The
runtime knew why (netplay_soft_exit's origin) but only printed it to
stdout, so players saw the lobby again with no reason. A boot-digest
mismatch (peers booted different BIOS images or boot settings) first
held a black window for the full 20 s admit-stall watchdog.

netplay_soft_exit now records a sentence for its origin, and the soft
return to the lobby puts it on the launcher's status line through
last_error (the room and browser views already show it). The dig0 gate
timestamps a mismatch; once the same pair of digests has held for 3 s,
the watchdog ends the match with its own reason. A peer that gets the
other side's BYE while it sees the same mismatch reports the mismatch,
not "the other player left". A CLI match prints the sentence to stderr.

The origin-to-text map and the grace decision live in
netplay_exit_reason.c, covered by netplay_exit_reason_test. Builds on
the previous commit's psx_lobby_set_last_error.
2026-09-30 15:59:58 +03:00

38 lines
1.4 KiB
C

/* netplay_exit_reason.h — why a netplay match ended, in words.
*
* A match that ends early returns every player to the lobby. The runtime knew
* why (netplay_soft_exit's origin) but only printed it to stdout, so players
* saw the lobby again with no reason. These map an origin to one sentence for
* the launcher's status line, and decide when a boot-digest mismatch is final.
*/
#ifndef NETPLAY_EXIT_REASON_H
#define NETPLAY_EXIT_REASON_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* The player-facing sentence for a netplay_soft_exit origin, or NULL when the
* player ended the match themselves (window close, Escape) or the origin is
* unknown. */
const char *netplay_exit_reason_text(const char *origin);
/* The rollback boot digests of the two peers are both known and different.
* The peers booted differently, and waiting does not fix that; before this change
* only the generic 20 s admit-stall watchdog ended it. The mismatch is final
* once the same pair of digests has held for grace_ms (the short wait lets a
* stale peer digest be replaced, and the peer reach the same verdict).
* mismatch_since_ms is 0 when there is no mismatch. */
int netplay_boot_mismatch_final(uint32_t mismatch_since_ms, uint32_t now_ms,
uint32_t grace_ms);
#define NETPLAY_BOOT_MISMATCH_GRACE_MS 3000u
#ifdef __cplusplus
}
#endif
#endif /* NETPLAY_EXIT_REASON_H */