Skip to content

Commit

Permalink
Fix use of closed demo file when playback stopped due to error
Browse files Browse the repository at this point in the history
Check whether the demo file has been closed due to a playback error when calling `DoTick` in loops, to prevent crashes on operating systems with assertions for correct C library usage. On Windows, `warning: Invalid parameter passed to C runtime function` was printed to the debug console in this case.
  • Loading branch information
Robyt3 committed Oct 25, 2023
1 parent 9220604 commit 4845639
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/engine/shared/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ int CDemoPlayer::SetPos(int WantedTick)
m_Info.m_PreviousTick = -1;

// playback everything until we hit our tick
while(m_Info.m_NextTick < WantedTick)
while(m_Info.m_NextTick < WantedTick && IsPlaying())
DoTick();

Play();
Expand Down Expand Up @@ -976,7 +976,7 @@ int CDemoPlayer::Update(bool RealTime)
{
m_Info.m_CurrentTime += (int64_t)(Deltatime * (double)m_Info.m_Info.m_Speed);

while(!m_Info.m_Info.m_Paused)
while(!m_Info.m_Info.m_Paused && IsPlaying())
{
int64_t CurtickStart = m_Info.m_Info.m_CurrentTick * Freq / SERVER_TICK_SPEED;

Expand Down

0 comments on commit 4845639

Please sign in to comment.