From 4845639a00d3b8f514174da103125173f822d59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Wed, 25 Oct 2023 20:10:12 +0200 Subject: [PATCH] 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. --- src/engine/shared/demo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/shared/demo.cpp b/src/engine/shared/demo.cpp index 6666752a3..2b10b5554 100644 --- a/src/engine/shared/demo.cpp +++ b/src/engine/shared/demo.cpp @@ -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;