Fix use of closed demo file when playback stopped due to error

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.
This commit is contained in:
Robert Müller 2023-10-25 20:10:12 +02:00
parent 92206044d1
commit 4845639a00

View file

@ -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();
@ -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;