- halt the game timer when setting up a cutscene and when starting movie playback.

These are both lengthy operations that can take several 100s of milliseconds, so when starting a streaming video they can throw off the timing quite significantly.
With this the intermissiondelay counter could be removed as it was only there to flush the accumulated time before starting video playback.
This commit is contained in:
Christoph Oelckers 2021-05-23 14:36:54 +02:00
parent cc1def8d77
commit d98a567597
8 changed files with 17 additions and 15 deletions

View file

@ -797,7 +797,9 @@ DEFINE_ACTION_FUNCTION(_MoviePlayer, Create)
DEFINE_ACTION_FUNCTION(_MoviePlayer, Start)
{
PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer);
I_FreezeTime(true);
self->Start();
I_FreezeTime(false);
return 0;
}

View file

@ -59,7 +59,6 @@ PClass* runnerclass;
PType* runnerclasstype;
CompletionFunc completion;
static int ticks;
int intermissiondelay;
//=============================================================================
//
@ -287,6 +286,7 @@ bool ScreenJobValidate()
VMValue parm[] = { runner };
VMReturn ret(&res);
VMCall(func, parm, 1, &ret, 1);
I_ResetFrameTime();
return res;
}
}
@ -315,8 +315,6 @@ 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;
if (sysCallbacks.StartCutscene) sysCallbacks.StartCutscene(flags & SJ_BLOCKUI);
}
catch (...)

View file

@ -17,7 +17,6 @@ void Job_Init();
enum
{
SJ_BLOCKUI = 1,
SJ_DELAY = 2,
};
struct CutsceneDef
@ -51,7 +50,6 @@ DObject* CreateRunner(bool clearbefore = true);
void AddGenericVideo(DObject* runner, const FString& fn, int soundid, int fps);
extern int intermissiondelay;
extern DObject* runner;
extern PClass* runnerclass;
extern PType* runnerclasstype;

View file

@ -26,4 +26,3 @@ enum gamestate_t : int
extern gamestate_t gamestate;
extern int intermissiondelay;

View file

@ -195,9 +195,16 @@ void I_FreezeTime(bool frozen)
else
{
assert(FreezeTime != 0);
FirstFrameStartTime += GetClockTimeNS() - FreezeTime;
if (FirstFrameStartTime != 0) FirstFrameStartTime += GetClockTimeNS() - FreezeTime;
FreezeTime = 0;
I_SetFrameTime();
}
}
void I_ResetFrameTime()
{
// Reset the starting point of the current frame to now. For use after lengthy operations that should not result in tic accumulation.
auto ft = CurrentFrameStartTime;
I_SetFrameTime();
FirstFrameStartTime += (CurrentFrameStartTime - ft);
}

View file

@ -38,3 +38,6 @@ uint64_t I_msTimeFS();
// Nanosecond-accurate time
uint64_t I_nsTime();
// Reset the timer after a lengthy operation
void I_ResetFrameTime();

View file

@ -372,11 +372,6 @@ static void GameTicker()
break;
case GS_CUTSCENE:
case GS_INTRO:
if (intermissiondelay > 0)
{
intermissiondelay--;
break;
}
if (ScreenJobTick())
{
// synchronize termination with the playsim.
@ -421,7 +416,7 @@ void Display()
case GS_INTRO:
case GS_CUTSCENE:
// screen jobs are not bound by the game ticker so they need to be ticked in the display loop.
if (intermissiondelay <= 0) ScreenJobDraw();
ScreenJobDraw();
break;
case GS_LEVEL:

View file

@ -72,7 +72,7 @@ void Local_Job_Init()
//
//=============================================================================
void CallCreateMapFunction(const char* qname, DObject* runner, MapRecord* map)
static void CallCreateMapFunction(const char* qname, DObject* runner, MapRecord* map)
{
auto func = LookupFunction(qname);
if (func->Proto->ArgumentTypes.Size() == 1) return CallCreateFunction(qname, runner); // accept functions without map parameter as well here.
@ -143,7 +143,7 @@ void PlayLogos(gameaction_t complete_ga, gameaction_t def_ga, bool stopmusic)
}
else
{
if (!StartCutscene(globalCutscenes.Intro, SJ_BLOCKUI|SJ_DELAY, [=](bool) {
if (!StartCutscene(globalCutscenes.Intro, SJ_BLOCKUI, [=](bool) {
gameaction = complete_ga;
})) gameaction = def_ga;
}