From 90b26dc2a1bc4a95461bcc1c305f20cab6f97e4e Mon Sep 17 00:00:00 2001 From: serge_shubin Date: Mon, 23 Mar 2026 05:53:53 +0800 Subject: [PATCH] Capture per-client chat commands for demo recording Chat messages use per-client trap_SendServerCommand (not broadcast), so they weren't captured. Move capture hook to SV_GameSendServerCommand which is the game module boundary. Capture broadcasts (clientNum=-1) and chat/tchat commands sent to client 0 (first in the per-client loop, deduplicated by only capturing once). Co-Authored-By: Claude Opus 4.6 (1M context) --- code/server/sv_game.c | 14 +++++++++++++- code/server/sv_main.c | 3 --- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/code/server/sv_game.c b/code/server/sv_game.c index 202994e..4063fc7 100644 --- a/code/server/sv_game.c +++ b/code/server/sv_game.c @@ -83,13 +83,25 @@ Sends a command string to a client =============== */ void SV_GameSendServerCommand( int clientNum, const char *text ) { + // capture for demo recording (deduplicate: only capture broadcasts + // and first per-client send of chat/print commands) + if ( clientNum == -1 ) { + SVD_CaptureServerCommand( text ); + } else if ( clientNum == 0 ) { + // per-client commands sent to client 0 first — capture "chat" and + // "tchat" once (they'll be sent to all clients in a loop) + if ( !strncmp( text, "chat", 4 ) || !strncmp( text, "tchat", 5 ) ) { + SVD_CaptureServerCommand( text ); + } + } + if ( clientNum == -1 ) { SV_SendServerCommand( NULL, "%s", text ); } else { if ( clientNum < 0 || clientNum >= sv_maxclients->integer ) { return; } - SV_SendServerCommand( svs.clients + clientNum, "%s", text ); + SV_SendServerCommand( svs.clients + clientNum, "%s", text ); } } diff --git a/code/server/sv_main.c b/code/server/sv_main.c index 7d980b2..da5e89a 100644 --- a/code/server/sv_main.c +++ b/code/server/sv_main.c @@ -177,9 +177,6 @@ void QDECL SV_SendServerCommand(client_t *cl, const char *fmt, ...) { return; } - // capture broadcast commands for demo recording - SVD_CaptureServerCommand( (char *)message ); - // hack to echo broadcast prints to console if ( com_dedicated->integer && !strncmp( (char *)message, "print", 5) ) { Com_Printf ("broadcast: %s\n", SV_ExpandNewlines((char *)message) );