- removed debug output and fixed fade flag setup and missing OnTick return

This commit is contained in:
Christoph Oelckers 2021-04-26 23:21:16 +02:00
parent 26a7700579
commit 06abc0cfe2
3 changed files with 5 additions and 26 deletions

View file

@ -333,7 +333,6 @@ static void GameTicker()
case GS_INTRO:
if (ScreenJobTick())
{
Printf("Sending event\n");
// synchronize termination with the playsim.
Net_WriteByte(DEM_ENDSCREENJOB);
}

View file

@ -232,7 +232,6 @@ void DeleteScreenJob()
void EndScreenJob()
{
Printf("EndScreenJob\n");
DeleteScreenJob();
if (completion) completion(false);
completion = nullptr;
@ -275,7 +274,8 @@ bool ScreenJobTick()
{
int result = 0;
VMValue parm[] = { runner };
VMCall(func, parm, 1, nullptr, 0);
VMReturn ret(&result);
VMCall(func, parm, 1, &ret, 1);
return result;
}
}

View file

@ -25,9 +25,9 @@ class ScreenJob : Object
stopsound = 8,
};
void Init(int flags = 0, float fadet = 250.f)
void Init(int fflags = 0, float fadet = 250.f)
{
flags = fadet;
flags = fflags;
fadetime = fadet;
jobstate = running;
}
@ -76,10 +76,8 @@ class SkippableScreenJob : ScreenJob
override bool OnEvent(InputEvent evt)
{
Console.Printf("OnEvent");
if (evt.type == InputEvent.Type_KeyDown && !Raze.specialKeyEvent(evt))
{
Console.Printf("Skip requested");
jobstate = skipped;
OnSkip();
}
@ -272,25 +270,19 @@ class MoviePlayerJob : SkippableScreenJob
override void Draw(double smoothratio)
{
Console.Printf("MoviePlayer.Draw state = %d", jobstate);
if (!player)
{
Console.Printf("MoviePlayer.Draw: end");
jobstate = stopped;
return;
}
if (!started)
{
Console.Printf("MoviePlayer.Draw: start");
started = true;
player.Start();
}
double clock = (ticks + smoothratio) * 1000000000. / GameTicRate;
Console.Printf("MoviePlayer.Frame %d %f", ticks, clock);
if (jobstate == running && !player.Frame(clock))
{
Console.Printf("MoviePlayer.finish");
jobstate = finished;
}
}
@ -358,7 +350,6 @@ class ScreenJobRunner : Object
void Append(ScreenJob job)
{
Console.Printf("Appending job of type " .. job.GetClassName() );
jobs.Push(job);
}
@ -372,7 +363,6 @@ class ScreenJobRunner : Object
{
if (index == jobs.Size()-1)
{
Console.Printf("AdvanceJob: reached end of list");
index++;
return; // we need to retain the last element until the runner is done.
}
@ -387,7 +377,6 @@ class ScreenJobRunner : Object
actionState = clearbefore ? State_Clear : State_Run;
if (index < jobs.Size())
{
Console.Printf("AdvanceJob: starting job at index %d, type %s", index, jobs[index].GetClassName());
jobs[index].fadestate = !paused && jobs[index].flags & ScreenJob.fadein? ScreenJob.fadein : ScreenJob.visible;
jobs[index].Start();
}
@ -415,7 +404,6 @@ class ScreenJobRunner : Object
double ms = (job.ticks + smoothratio) * 1000 / GameTicRate / job.fadetime;
double screenfade = clamp(ms, 0., 1.);
Screen.SetScreenFade(screenfade);
Console.Printf("DisplayFrame: fading in %s with %f", job.GetClassName(), screenfade);
if (screenfade == 1.) job.fadestate = ScreenJob.visible;
}
int state = job.DrawFrame(smoothratio);
@ -438,7 +426,6 @@ class ScreenJobRunner : Object
Screen.SetScreenFade(screenfade);
job.DrawFrame(1.);
Screen.SetScreenFade(1.);
Console.Printf("FadeoutFrame: fading out %s with %f", job.GetClassName(), screenfade);
return (screenfade > 0.);
}
@ -452,7 +439,6 @@ class ScreenJobRunner : Object
{
if (paused || index >= jobs.Size()) return false;
if (jobs[index].jobstate != ScreenJob.running) return false;
if (ev.type == InputEvent.Type_KeyDown) Console.Printf("OnEvent: dispatching key %d to job %s", ev.keyScan, jobs[index].GetClassName());
return jobs[index].OnEvent(ev);
}
@ -472,19 +458,16 @@ class ScreenJobRunner : Object
AdvanceJob(terminateState < 0);
if (index >= jobs.Size())
{
Console.Printf("OnTick: done");
return true;
}
}
if (jobs[index].jobstate == ScreenJob.running)
{
jobs[index].ticks++;
Console.Printf("OnTick: job %s, ticks = %d", jobs[index].GetClassName(), jobs[index].ticks);
jobs[index].OnTick();
}
else if (jobs[index].jobstate == ScreenJob.stopping)
{
Console.Printf("OnTick: fadeticks for %s", jobs[index].GetClassName());
fadeticks++;
}
return false;
@ -518,8 +501,6 @@ class ScreenJobRunner : Object
terminateState = DisplayFrame(smoothratio);
if (terminateState < 1 && index < jobs.Size())
{
Console.Printf("RunFrame: job %s, state %d", jobs[index].GetClassName(), terminateState);
if (jobs[index].flags & ScreenJob.fadeout)
{
jobs[index].fadestate = ScreenJob.fadeout;
@ -529,7 +510,6 @@ class ScreenJobRunner : Object
}
else
{
Console.Printf("RunState: advancing");
advance = true;
}
}