From 6fc96e7070aa82e4b3168b9b2776d89d874bbf3f Mon Sep 17 00:00:00 2001 From: serge_shubin Date: Mon, 23 Mar 2026 05:08:38 +0800 Subject: [PATCH] Auto-stop demo recording on map change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SV_SpawnServer reinitializes the game module, invalidating all entity and configstring state. Recording across a map boundary would produce corrupt deltas. Stop recording automatically at the start of SV_SpawnServer (before game shutdown). map_restart is unaffected — it has its own path (SV_MapRestart_f) which doesn't call SV_SpawnServer. Co-Authored-By: Claude Opus 4.6 (1M context) --- code/server/sv_init.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/server/sv_init.c b/code/server/sv_init.c index e07731e..2c66a0d 100644 --- a/code/server/sv_init.c +++ b/code/server/sv_init.c @@ -351,6 +351,12 @@ void SV_SpawnServer( char *server, qboolean killBots ) { char systemInfo[16384]; const char *p; + // stop any active demo recording (one demo = one map) + if ( SVD_IsRecording() ) { + Com_Printf( "Map change — stopping demo recording.\n" ); + SVD_StopRecord_f(); + } + // shut down the existing game if it is running SV_ShutdownGameProgs();