Start demo playback only when spectator enters game
Move pause check from SV_Frame (which blocked connection handshake) into SVD_PlaybackFrame. The server runs frames normally so clients can connect and load, but demo data isn't consumed until a client reaches CS_ACTIVE. The spectator sees the demo from the very first frame without missing any gameplay. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fcd5fc6ce8
commit
0b4eb7b69f
2 changed files with 9 additions and 8 deletions
|
|
@ -828,12 +828,6 @@ void SV_Frame( int msec ) {
|
||||||
|
|
||||||
if (com_dedicated->integer) SV_BotFrame( svs.time );
|
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
|
// run the game simulation in chunks
|
||||||
while ( sv.timeResidual >= frameMsec ) {
|
while ( sv.timeResidual >= frameMsec ) {
|
||||||
sv.timeResidual -= frameMsec;
|
sv.timeResidual -= frameMsec;
|
||||||
|
|
|
||||||
|
|
@ -1007,6 +1007,13 @@ qboolean SVD_PlaybackFrame( void ) {
|
||||||
return qfalse;
|
return qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wait for a spectator to be fully in-game before starting playback.
|
||||||
|
// the server keeps running frames (so the connection handshake completes)
|
||||||
|
// but no demo data is consumed until someone is CS_ACTIVE.
|
||||||
|
if ( SVD_ShouldPause() ) {
|
||||||
|
return qfalse;
|
||||||
|
}
|
||||||
|
|
||||||
// apply recorded configstrings once after map load
|
// apply recorded configstrings once after map load
|
||||||
if ( demo.needConfigstrings ) {
|
if ( demo.needConfigstrings ) {
|
||||||
SVD_ApplyConfigstrings();
|
SVD_ApplyConfigstrings();
|
||||||
|
|
@ -1047,8 +1054,8 @@ qboolean SVD_ShouldPause( void ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i = 0; i < sv_maxclients->integer; i++ ) {
|
for ( i = 0; i < sv_maxclients->integer; i++ ) {
|
||||||
if ( svs.clients[i].state >= CS_CONNECTED ) {
|
if ( svs.clients[i].state == CS_ACTIVE ) {
|
||||||
return qfalse; // someone is connected or connecting
|
return qfalse; // someone is in-game and watching
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue