From b21dadeef0b6e0a34cf8ff88a0b24e81918a239e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 1 May 2021 19:46:17 +0200 Subject: [PATCH] - we need to wait a bit before starting the intro scene. The game timer actually starts before the main loop is ready so we have to wait with the cutscene until the loop is in sync with the timer. --- source/core/gamestate.h | 1 + source/core/mainloop.cpp | 8 +++++++- source/core/screenjob.cpp | 4 +++- source/core/screenjob.h | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/source/core/gamestate.h b/source/core/gamestate.h index 26d7f6767..431eac31c 100644 --- a/source/core/gamestate.h +++ b/source/core/gamestate.h @@ -49,3 +49,4 @@ enum gameaction_t : int }; extern gamestate_t gamestate; extern gameaction_t gameaction; +extern int intermissiondelay; diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index 1bd454228..156beead2 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -105,6 +105,7 @@ bool r_NoInterpolate; int entertic; int oldentertics; int gametic; +int intermissiondelay; FString BackupSaveGame; @@ -349,6 +350,11 @@ static void GameTicker() break; case GS_INTERMISSION: case GS_INTRO: + if (intermissiondelay > 0) + { + intermissiondelay--; + break; + } if (ScreenJobTick()) { // synchronize termination with the playsim. @@ -393,7 +399,7 @@ void Display() case GS_INTRO: case GS_INTERMISSION: // screen jobs are not bound by the game ticker so they need to be ticked in the display loop. - ScreenJobDraw(); + if (intermissiondelay <= 0) ScreenJobDraw(); break; case GS_LEVEL: diff --git a/source/core/screenjob.cpp b/source/core/screenjob.cpp index 8dfaee5a2..439ccd801 100644 --- a/source/core/screenjob.cpp +++ b/source/core/screenjob.cpp @@ -374,6 +374,8 @@ bool StartCutscene(CutsceneDef& cs, int flags, const CompletionFunc& completion_ runner = nullptr; return false; } + if (flags & SJ_DELAY) intermissiondelay = 10; // need to wait a bit at the start to let the timer catch up. + else intermissiondelay = 0; gameaction = (flags & SJ_BLOCKUI) ? ga_intro : ga_intermission; } catch (...) @@ -410,7 +412,7 @@ void PlayLogos(gameaction_t complete_ga, gameaction_t def_ga, bool stopmusic) } else { - if (!StartCutscene(globalCutscenes.Intro, SJ_BLOCKUI, [=](bool) { + if (!StartCutscene(globalCutscenes.Intro, SJ_BLOCKUI|SJ_DELAY, [=](bool) { gameaction = complete_ga; })) gameaction = def_ga; } diff --git a/source/core/screenjob.h b/source/core/screenjob.h index a4f6eff5c..94c445158 100644 --- a/source/core/screenjob.h +++ b/source/core/screenjob.h @@ -13,6 +13,7 @@ void Job_Init(); enum { SJ_BLOCKUI = 1, + SJ_DELAY = 2, }; void EndScreenJob();