File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ void Gekko::SpectatorSession::Init(GekkoConfig* config)
2828
2929 // setup game event system
3030 _game_events.Init (_config.input_size * _config.num_players );
31+
32+ // start paused so the buffer fills before playback begins
33+ _delay_spectator = (_config.spectator_delay > 0 );
3134}
3235
3336void Gekko::SpectatorSession::SetLocalDelay (i32 player, u8 delay)
@@ -167,7 +170,9 @@ bool Gekko::SpectatorSession::AllActorsValid()
167170
168171 // if none returned that the session is ready!
169172 _msg.session_events .AddSessionStartedEvent ();
170-
173+ if (_config.spectator_delay > 0 ) {
174+ _msg.session_events .AddSpectatorPausedEvent ();
175+ }
171176 _started = true ;
172177
173178 return true ;
@@ -226,14 +231,11 @@ bool Gekko::SpectatorSession::ShouldDelaySpectator()
226231 return true ;
227232 }
228233
229- // check every 600 frames (10 seconds at 60 fps) whether it should add delay.
230- if (current % 600 == 0 ) {
231- _delay_spectator = diff < delay;
232-
233- if (_delay_spectator) {
234- _msg.session_events .AddSpectatorPausedEvent ();
235- return true ;
236- }
234+ // Re-pause only when the buffer is completely exhausted
235+ if (diff == 0 ) {
236+ _delay_spectator = true ;
237+ _msg.session_events .AddSpectatorPausedEvent ();
238+ return true ;
237239 }
238240
239241 return false ;
You can’t perform that action at this time.
0 commit comments