From 7dece398f446e0212fb90da09141546ed79e8164 Mon Sep 17 00:00:00 2001 From: husho Date: Mon, 13 Aug 2018 03:30:16 +0300 Subject: [PATCH] Fix segfault when script timer runs out --- rwgame/RWGame.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index 839fbba1..efb75020 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -510,10 +510,7 @@ void RWGame::tick(float dt) { while (scriptTimerAccumulator >= timerClockRate) { // Original game uses milliseconds (*state.scriptTimerVariable) -= timerClockRate * 1000; - if (*state.scriptTimerVariable <= 0) { - (*state.scriptTimerVariable) = 0; - state.scriptTimerVariable = nullptr; - } + // 11 seconds if (*state.scriptTimerVariable <= 11000 && beepTime - *state.scriptTimerVariable >= 1000) { @@ -521,6 +518,12 @@ void RWGame::tick(float dt) { // @todo beep } + + if (*state.scriptTimerVariable <= 0) { + (*state.scriptTimerVariable) = 0; + state.scriptTimerVariable = nullptr; + } + scriptTimerAccumulator -= timerClockRate; } }