diff --git a/c/common/netdev_soft.c b/c/common/netdev_soft.c index 667353f..31a815d 100644 --- a/c/common/netdev_soft.c +++ b/c/common/netdev_soft.c @@ -29,6 +29,13 @@ uint8_t net_device; #else #define BIN_ARG "" #endif +#ifdef NET_PLATFORM /* plat_config.h: which machine this is, for the relay's statistics */ +#define PF_ARG "&pf=" NET_PLATFORM +#else +#define PF_ARG "" +#endif +/* The longest: /net?game=16974&code=ABCD&bin=1&pf=element-zx-128k */ +static char path[52]; #define MSGQ 4 #define E_BUILD 6 #define E_NOROOM 8 @@ -330,12 +337,11 @@ uint8_t net_status(net_status_t *st) { } uint8_t net_create(uint16_t build, uint8_t slots, const uint8_t *settings, uint8_t len, char code[5], uint8_t *slot) { - static char path[40]; char *p; uint8_t r; if (slots < 1 || slots > NET_SLOTS) return E_PARAM; if (len > 16) len = 16; - p = put_u(put_s(path, "/net?game="), NET_GAME_ID); put_s(p, "&create=1" BIN_ARG)[0] = 0; + p = put_u(put_s(path, "/net?game="), NET_GAME_ID); put_s(p, "&create=1" BIN_ARG PF_ARG)[0] = 0; p = put_u(put_s(out, "{\"op\":\"create\",\"game\":"), NET_GAME_ID); p = put_u(put_s(p, ",\"build\":"), build); p = put_u(put_s(p, ",\"slots\":"), slots); @@ -349,10 +355,9 @@ uint8_t net_create(uint16_t build, uint8_t slots, const uint8_t *settings, uint8 } uint8_t net_join(uint16_t build, const char *code, uint8_t *slot, uint8_t *slots, uint8_t *settings, uint8_t *len) { - static char path[40]; char *p; uint8_t r; - p = put_u(put_s(path, "/net?game="), NET_GAME_ID); put_s(put_s(put_s(p, "&code="), code), BIN_ARG)[0] = 0; + p = put_u(put_s(path, "/net?game="), NET_GAME_ID); put_s(put_s(put_s(p, "&code="), code), BIN_ARG PF_ARG)[0] = 0; p = put_u(put_s(out, "{\"op\":\"join\",\"game\":"), NET_GAME_ID); p = put_u(put_s(p, ",\"build\":"), build); put_s(put_s(put_s(p, ",\"code\":\""), code), "\"}")[0] = 0; diff --git a/c/platform/amiga/plat_config.h b/c/platform/amiga/plat_config.h index 617131c..224fd88 100644 --- a/c/platform/amiga/plat_config.h +++ b/c/platform/amiga/plat_config.h @@ -6,4 +6,5 @@ #define PLAT_HASH_PORTABLE 1 /* the state hash field by field (core/game.c): the 68000 is big-endian */ #define PLAT_RUNAHEAD 1 /* a frame ahead of the agreed one in a match (docs/rollback-plan.md) */ #define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1) */ +#define NET_PLATFORM "amiga" /* the relay's statistics: &pf= (docs/net-protocol.md) */ #endif diff --git a/c/platform/atari/plat_config.h b/c/platform/atari/plat_config.h index 6fe3f48..b7371a3 100644 --- a/c/platform/atari/plat_config.h +++ b/c/platform/atari/plat_config.h @@ -6,4 +6,5 @@ #define JOY_ATARI 1 /* the two joystick ports */ #define PLAT_ASM_COMPOSITE 1 /* cpu/6502/loops.s */ #define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1): ~7 bytes on FujiNet's bus, not ~50 */ +#define NET_PLATFORM "atari-xl" /* the relay's statistics: &pf= (docs/net-protocol.md) */ #endif diff --git a/c/platform/atarist/plat_config.h b/c/platform/atarist/plat_config.h index 908191f..f471673 100644 --- a/c/platform/atarist/plat_config.h +++ b/c/platform/atarist/plat_config.h @@ -6,4 +6,5 @@ #define PLAT_HASH_PORTABLE 1 /* the state hash field by field (core/game.c): the 68000 is big-endian */ #define PLAT_RUNAHEAD 1 /* a frame ahead of the agreed one in a match (docs/rollback-plan.md) */ #define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1) */ +#define NET_PLATFORM "atari-st" /* the relay's statistics: &pf= (docs/net-protocol.md) */ #endif diff --git a/c/platform/c64/plat_config.h b/c/platform/c64/plat_config.h index ae8159c..194f8cd 100644 --- a/c/platform/c64/plat_config.h +++ b/c/platform/c64/plat_config.h @@ -5,4 +5,5 @@ #define PLAT_JOY_TYPES 2 #define PLAT_ASM_COMPOSITE 1 /* cpu/6502/loops.s */ #define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1) */ +#define NET_PLATFORM "c64" /* the relay's statistics: &pf= (docs/net-protocol.md) */ #endif diff --git a/c/platform/cpc/plat_config.h b/c/platform/cpc/plat_config.h index 8f90dcd..a866ff5 100644 --- a/c/platform/cpc/plat_config.h +++ b/c/platform/cpc/plat_config.h @@ -10,4 +10,5 @@ (unused with NET_BINARY_INPUT) */ #define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1): about 7 bytes, not 50 */ #define PLAT_ASM_TEXT 1 /* print_string, hud_text, title_text* in cpu/z80/loops.c */ +#define NET_PLATFORM "amstrad-cpc" /* the relay's statistics: &pf= (docs/net-protocol.md) */ #endif diff --git a/c/platform/pc/plat_config.h b/c/platform/pc/plat_config.h index b371b3d..63bb5ee 100644 --- a/c/platform/pc/plat_config.h +++ b/c/platform/pc/plat_config.h @@ -6,4 +6,5 @@ #define PLAT_HASH_PORTABLE 1 /* the state hash field by field (core/game.c): Watcom pads structures */ #define PLAT_RUNAHEAD 1 /* a frame ahead of the agreed one in a match (docs/rollback-plan.md) */ #define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1) */ +#define NET_PLATFORM "pc-dos" /* the relay's statistics: &pf= (docs/net-protocol.md) */ #endif diff --git a/c/platform/web/plat_config.h b/c/platform/web/plat_config.h index 105aa3d..c3968fe 100644 --- a/c/platform/web/plat_config.h +++ b/c/platform/web/plat_config.h @@ -7,4 +7,5 @@ #define PLAT_HASH_PORTABLE 1 /* the state hash field by field (core/game.c) */ #define PLAT_RUNAHEAD 1 /* a frame ahead of the agreed one in a match (docs/rollback-plan.md) */ #define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1) */ +#define NET_PLATFORM "browser" /* the relay's statistics: &pf= (docs/net-protocol.md) */ #endif diff --git a/c/platform/zx/plat_config.h b/c/platform/zx/plat_config.h index f0c5be7..9af9df4 100644 --- a/c/platform/zx/plat_config.h +++ b/c/platform/zx/plat_config.h @@ -13,4 +13,9 @@ (unused with NET_BINARY_INPUT) */ #define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1): about 7 bytes, not 50 */ #define PLAT_ASM_TEXT 1 /* print_string, hud_text, title_text* in cpu/z80/loops.c */ +#ifdef ZX128 /* the relay's statistics: &pf= (docs/net-protocol.md) */ +#define NET_PLATFORM "element-zx-128k" +#else +#define NET_PLATFORM "zx-spectrum-48k" +#endif #endif diff --git a/docs/net-protocol.md b/docs/net-protocol.md index bab5ecc..1e40d25 100644 --- a/docs/net-protocol.md +++ b/docs/net-protocol.md @@ -110,6 +110,14 @@ One socket per device. JSON frames: <- {"op":"error","code":6..11,"text":"..."} ``` +**Which machine** (`&pf=` in the URL, optional): the machine's name for +the production relay's statistics, the id of its port in the catalog (`c64`, +`amiga`, `atari-xl`, `atari-st`, `amstrad-cpc`, `pc-dos`, `zx-spectrum-48k`, +`element-zx-128k`, `browser`). It changes nothing in a game; the production +relay counts an unknown id as if there were none, and `relay/relay.py` ignores +it. `NET_PLATFORM` in a platform's `plat_config.h` sets it; the MZ-800 needs +none, because the MZPico firmware makes the connection and names itself. + Rooms die 10 minutes after their last message (a host may wait a while). Codes are 4 letters from a 26-letter alphabet without I/O. A room is bound to (game, build).