Pause demo playback when no spectators are watching
svdemo_pauseEmpty (default: 1) pauses frame processing when no client is CS_ACTIVE during demo playback. Prevents the demo from advancing with nobody watching. Time residual is cleared so the demo resumes from where it paused when a spectator connects. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b79eb77bb3
commit
300e7c431a
4 changed files with 28 additions and 0 deletions
|
|
@ -357,6 +357,7 @@ void SVD_Stop_f( void );
|
|||
qboolean SVD_PlaybackFrame( void );
|
||||
qboolean SVD_IsRecording( void );
|
||||
qboolean SVD_IsPlaying( void );
|
||||
qboolean SVD_ShouldPause( void );
|
||||
|
||||
//============================================================
|
||||
//
|
||||
|
|
|
|||
|
|
@ -624,6 +624,7 @@ void SV_Init (void) {
|
|||
// server-side demo settings
|
||||
Cvar_Get ("svdemo_autorecord", "0", CVAR_ARCHIVE);
|
||||
Cvar_Get ("svdemo_compress", "1", CVAR_ARCHIVE);
|
||||
Cvar_Get ("svdemo_pauseEmpty", "1", CVAR_ARCHIVE);
|
||||
|
||||
// initialize bot cvars so they are listed and can be set before loading the botlib
|
||||
SV_BotInitCvars();
|
||||
|
|
|
|||
|
|
@ -828,6 +828,12 @@ void SV_Frame( int msec ) {
|
|||
|
||||
if (com_dedicated->integer) SV_BotFrame( svs.time );
|
||||
|
||||
// demo playback: pause if no spectators are watching
|
||||
if ( SVD_IsPlaying() && SVD_ShouldPause() ) {
|
||||
sv.timeResidual = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// run the game simulation in chunks
|
||||
while ( sv.timeResidual >= frameMsec ) {
|
||||
sv.timeResidual -= frameMsec;
|
||||
|
|
|
|||
|
|
@ -1017,3 +1017,23 @@ qboolean SVD_IsPlaying( void ) {
|
|||
return demo.playing;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns qtrue if demo playback should pause (no active spectators).
|
||||
Controlled by svdemo_pauseEmpty cvar.
|
||||
*/
|
||||
qboolean SVD_ShouldPause( void ) {
|
||||
int i;
|
||||
|
||||
if ( !Cvar_VariableIntegerValue( "svdemo_pauseEmpty" ) ) {
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
for ( i = 0; i < sv_maxclients->integer; i++ ) {
|
||||
if ( svs.clients[i].state == CS_ACTIVE ) {
|
||||
return qfalse; // someone is watching
|
||||
}
|
||||
}
|
||||
|
||||
return qtrue; // nobody connected, pause
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue