From 4a7430c8e41b50aa6a94fae238a31ca42bedaa2f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Apr 2021 00:51:14 +0200 Subject: [PATCH] - got rid of JobDesc. --- source/core/screenjob.cpp | 67 ++++++++++--------- source/core/screenjob.h | 12 +--- source/games/blood/src/credits.cpp | 23 ++++--- source/games/blood/src/endgame.cpp | 10 +-- source/games/duke/src/2d_d.cpp | 92 +++++++++++++-------------- source/games/duke/src/2d_r.cpp | 48 +++++++------- source/games/exhumed/src/2d.cpp | 39 ++++++------ source/games/exhumed/src/exhumed.h | 6 +- source/games/exhumed/src/gameloop.cpp | 8 +-- source/games/sw/src/2d.cpp | 34 +++++----- 10 files changed, 165 insertions(+), 174 deletions(-) diff --git a/source/core/screenjob.cpp b/source/core/screenjob.cpp index 5a9991e51..8e8b83bd8 100644 --- a/source/core/screenjob.cpp +++ b/source/core/screenjob.cpp @@ -117,15 +117,14 @@ void DImageScreen::Draw(double smoothratio) // //--------------------------------------------------------------------------- -ScreenJobRunner::ScreenJobRunner(JobDesc* jobs_, int count, CompletionFunc completion_, bool clearbefore_, bool skipall_) +ScreenJobRunner::ScreenJobRunner(TArray& jobs_, CompletionFunc completion_, bool clearbefore_, bool skipall_) : completion(std::move(completion_)), clearbefore(clearbefore_), skipall(skipall_) { - jobs.Resize(count); - memcpy(jobs.Data(), jobs_, count * sizeof(JobDesc)); + jobs = std::move(jobs_); // Release all jobs from the garbage collector - the code as it is cannot deal with them getting collected. This should be removed later once the GC is working. - for (int i = 0; i < count; i++) + for (unsigned i = 0; i < jobs.Size(); i++) { - jobs[i].job->Release(); + jobs[i]->Release(); } AdvanceJob(false); } @@ -145,8 +144,8 @@ void ScreenJobRunner::DeleteJobs() { for (auto& job : jobs) { - job.job->ObjectFlags |= OF_YesReallyDelete; - delete job.job; + job->ObjectFlags |= OF_YesReallyDelete; + delete job; } jobs.Clear(); } @@ -162,19 +161,19 @@ void ScreenJobRunner::AdvanceJob(bool skip) if (index >= 0) { //if (jobs[index].postAction) jobs[index].postAction(); - jobs[index].job->Destroy(); + jobs[index]->Destroy(); } index++; - while (index < jobs.Size() && (jobs[index].job == nullptr || (skip && skipall))) + while (index < jobs.Size() && (jobs[index] == nullptr || (skip && skipall))) { - if (jobs[index].job != nullptr) jobs[index].job->Destroy(); + if (jobs[index] != nullptr) jobs[index]->Destroy(); index++; } actionState = clearbefore ? State_Clear : State_Run; if (index < jobs.Size()) { - jobs[index].job->fadestate = !paused && jobs[index].job->flags & DScreenJob::fadein? DScreenJob::fadein : DScreenJob::visible; - jobs[index].job->Start(); + jobs[index]->fadestate = !paused && jobs[index]->flags & DScreenJob::fadein? DScreenJob::fadein : DScreenJob::visible; + jobs[index]->Start(); } inputState.ClearAllInput(); } @@ -189,16 +188,16 @@ int ScreenJobRunner::DisplayFrame(double smoothratio) { auto& job = jobs[index]; auto now = I_GetTimeNS(); - bool processed = job.job->ProcessInput(); + bool processed = job->ProcessInput(); - if (job.job->fadestate == DScreenJob::fadein) + if (job->fadestate == DScreenJob::fadein) { - double ms = (job.job->ticks + smoothratio) * 1000 / GameTicRate / job.job->fadetime; + double ms = (job->ticks + smoothratio) * 1000 / GameTicRate / job->fadetime; float screenfade = (float)clamp(ms, 0., 1.); twod->SetScreenFade(screenfade); - if (screenfade == 1.f) job.job->fadestate = DScreenJob::visible; + if (screenfade == 1.f) job->fadestate = DScreenJob::visible; } - int state = job.job->DrawFrame(smoothratio); + int state = job->DrawFrame(smoothratio); twod->SetScreenFade(1.f); return state; } @@ -206,10 +205,10 @@ int ScreenJobRunner::DisplayFrame(double smoothratio) int ScreenJobRunner::FadeoutFrame(double smoothratio) { auto& job = jobs[index]; - double ms = (fadeticks + smoothratio) * 1000 / GameTicRate / job.job->fadetime; + double ms = (fadeticks + smoothratio) * 1000 / GameTicRate / job->fadetime; float screenfade = 1.f - (float)clamp(ms, 0., 1.); twod->SetScreenFade(screenfade); - job.job->DrawFrame(1.); + job->DrawFrame(1.); return (screenfade > 0.f); } @@ -234,9 +233,9 @@ bool ScreenJobRunner::OnEvent(event_t* ev) } } - if (jobs[index].job->state != DScreenJob::running) return false; + if (jobs[index]->state != DScreenJob::running) return false; - return jobs[index].job->OnEvent(ev); + return jobs[index]->OnEvent(ev); } void ScreenJobRunner::OnFinished() @@ -258,12 +257,12 @@ void ScreenJobRunner::OnTick() } else { - if (jobs[index].job->state == DScreenJob::running) + if (jobs[index]->state == DScreenJob::running) { - jobs[index].job->ticks++; - jobs[index].job->OnTick(); + jobs[index]->ticks++; + jobs[index]->OnTick(); } - else if (jobs[index].job->state == DScreenJob::stopping) + else if (jobs[index]->state == DScreenJob::stopping) { fadeticks++; } @@ -289,8 +288,8 @@ bool ScreenJobRunner::RunFrame() // ensure that we won't go back in time if the menu is dismissed without advancing our ticker bool menuon = paused; - if (menuon) last_paused_tic = jobs[index].job->ticks; - else if (last_paused_tic == jobs[index].job->ticks) menuon = true; + if (menuon) last_paused_tic = jobs[index]->ticks; + else if (last_paused_tic == jobs[index]->ticks) menuon = true; double smoothratio = menuon ? 1. : I_GetTimeFrac(); if (actionState == State_Clear) @@ -304,10 +303,10 @@ bool ScreenJobRunner::RunFrame() if (terminateState < 1) { // Must lock before displaying. - if (jobs[index].job->flags & DScreenJob::fadeout) + if (jobs[index]->flags & DScreenJob::fadeout) { - jobs[index].job->fadestate = DScreenJob::fadeout; - jobs[index].job->state = DScreenJob::stopping; + jobs[index]->fadestate = DScreenJob::fadeout; + jobs[index]->state = DScreenJob::stopping; actionState = State_Fadeout; fadeticks = 0; } @@ -322,7 +321,7 @@ bool ScreenJobRunner::RunFrame() int ended = FadeoutFrame(smoothratio); if (ended < 1) { - jobs[index].job->state = DScreenJob::stopped; + jobs[index]->state = DScreenJob::stopped; AdvanceJob(terminateState < 0); } } @@ -337,13 +336,13 @@ bool ScreenJobRunner::RunFrame() ScreenJobRunner *runner; -void RunScreenJob(JobDesc* jobs, int count, CompletionFunc completion, int flags) +void RunScreenJob(TArray& jobs, CompletionFunc completion, int flags) { assert(completion != nullptr); videoclearFade(); - if (count) + if (jobs.Size()) { - runner = new ScreenJobRunner(jobs, count, completion, !(flags & SJ_DONTCLEAR), !!(flags & SJ_SKIPALL)); + runner = new ScreenJobRunner(jobs, completion, !(flags & SJ_DONTCLEAR), !!(flags & SJ_SKIPALL)); gameaction = (flags & SJ_BLOCKUI)? ga_intro : ga_intermission; } else diff --git a/source/core/screenjob.h b/source/core/screenjob.h index 4dd35dd56..aa02c075e 100644 --- a/source/core/screenjob.h +++ b/source/core/screenjob.h @@ -138,12 +138,6 @@ public: // //--------------------------------------------------------------------------- -struct JobDesc -{ - DScreenJob* job; -}; - - class ScreenJobRunner { enum @@ -152,7 +146,7 @@ class ScreenJobRunner State_Run, State_Fadeout }; - TArray jobs; + TArray jobs; CompletionFunc completion; int index = -1; float screenfade; @@ -164,7 +158,7 @@ class ScreenJobRunner int last_paused_tic = -1; public: - ScreenJobRunner(JobDesc* jobs_, int count, CompletionFunc completion_, bool clearbefore_, bool skipall_); + ScreenJobRunner(TArray& jobs, CompletionFunc completion_, bool clearbefore_, bool skipall_); ~ScreenJobRunner(); void DeleteJobs(); void AdvanceJob(bool skip); @@ -186,7 +180,7 @@ enum }; -void RunScreenJob(JobDesc *jobs, int count, CompletionFunc completion, int flags = 0); +void RunScreenJob(TArray& jobs, CompletionFunc completion, int flags = 0); void EndScreenJob(); void DeleteScreenJob(); bool ScreenJobResponder(event_t* ev); diff --git a/source/games/blood/src/credits.cpp b/source/games/blood/src/credits.cpp index 89efa42ed..4919c2219 100644 --- a/source/games/blood/src/credits.cpp +++ b/source/games/blood/src/credits.cpp @@ -59,8 +59,7 @@ public: void playlogos() { - JobDesc jobs[6]; - int job = 0; + TArray jobs; static AnimSound logosound[] = { { 1, -1 }, @@ -80,25 +79,25 @@ void playlogos() { if (fileSystem.FindFile("logo.smk") != -1) { - jobs[job++] = { PlayVideo("logo.smk", &logosound[0], 0) }; + jobs.Push(PlayVideo("logo.smk", &logosound[0], 0)); } else { - jobs[job++] = { Create(2050) }; + jobs.Push(Create(2050)); } if (fileSystem.FindFile("gti.smk") != -1) { - jobs[job++] = { PlayVideo("gti.smk", &logosound[2], 0) }; + jobs.Push(PlayVideo("gti.smk", &logosound[2], 0)); } else { - jobs[job++] = { Create(2052) }; + jobs.Push(Create(2052)); } } - jobs[job++] = { Create(1) }; - jobs[job++] = { Create(2518, DScreenJob::fadein, true) }; + jobs.Push(Create(1)); + jobs.Push(Create(2518, DScreenJob::fadein, true)); - RunScreenJob(jobs, job, [](bool) { + RunScreenJob(jobs, [](bool) { Mus_Stop(); gameaction = ga_mainmenu; }, SJ_BLOCKUI); @@ -106,7 +105,7 @@ void playlogos() void playSmk(const char *smk, const char *wav, int wavid, CompletionFunc func) { - JobDesc jobs{}; + TArray jobs; static AnimSound smksound[] = { { 1, -1 }, @@ -127,8 +126,8 @@ void playSmk(const char *smk, const char *wav, int wavid, CompletionFunc func) FString smkk = smk; FixPathSeperator(smkk); smksound[0].soundnum = id; - jobs.job = PlayVideo(smkk, smksound, nullptr); - RunScreenJob(&jobs, 1, func); + jobs.Push(PlayVideo(smkk, smksound, nullptr)); + RunScreenJob(jobs, func); } void levelPlayIntroScene(int nEpisode, CompletionFunc completion) diff --git a/source/games/blood/src/endgame.cpp b/source/games/blood/src/endgame.cpp index a50b2e298..16f163b5b 100644 --- a/source/games/blood/src/endgame.cpp +++ b/source/games/blood/src/endgame.cpp @@ -173,10 +173,11 @@ class DBloodSummaryScreen : public DSkippableScreenJob void GameInterface::LevelCompleted(MapRecord *map, int skill) { - JobDesc job = { Create() }; + TArray job(1, true); + job[0] = Create(); sndStartSample(268, 128, -1, false, CHANF_UI); Mus_Stop(); - RunScreenJob(&job, 1, [=](bool) + RunScreenJob(job, [=](bool) { soundEngine->StopAllChannels(); gameaction = ga_nextlevel; @@ -301,8 +302,9 @@ public: void loadscreen(const char *caption, MapRecord* rec, CompletionFunc func) { - JobDesc job = { Create(caption, rec) }; - RunScreenJob(&job, 1, func); + TArray job(1, true); + job[0] = Create(caption, rec); + RunScreenJob(job, func); } diff --git a/source/games/duke/src/2d_d.cpp b/source/games/duke/src/2d_d.cpp index da895e94d..f4cce3d97 100644 --- a/source/games/duke/src/2d_d.cpp +++ b/source/games/duke/src/2d_d.cpp @@ -312,15 +312,15 @@ void Logo_d(const CompletionFunc &completion) }; static const int logoframetimes[] = { 9, 9, 9 }; - JobDesc jobs[3]; + TArray jobs; int job = 0; if (!userConfig.nologo) { - if (!isShareware()) jobs[job++] = { PlayVideo("logo.anm", logosound, logoframetimes) }; - if (!isNam()) jobs[job++] = { Create(), }; + if (!isShareware()) jobs.Push(PlayVideo("logo.anm", logosound, logoframetimes)); + if (!isNam()) jobs.Push(Create()); } - jobs[job++] = { Create() }; - RunScreenJob(jobs, job, completion, SJ_BLOCKUI); + jobs.Push(Create()); + RunScreenJob(jobs, completion, SJ_BLOCKUI); } //--------------------------------------------------------------------------- @@ -612,7 +612,7 @@ public: // //--------------------------------------------------------------------------- -static void bonussequence_d(int num, JobDesc *jobs, int &job) +static void bonussequence_d(int num, TArray& jobs) { static const AnimSound cineov2sound[] = { @@ -679,45 +679,45 @@ static void bonussequence_d(int num, JobDesc *jobs, int &job) switch (num) { case 0: - jobs[job++] = { Create() }; - jobs[job++] = { Create(E1ENDSCREEN, DScreenJob::fadein|DScreenJob::fadeout|DScreenJob::stopmusic, 0x7fffffff) }; + jobs.Push(Create()); + jobs.Push(Create(E1ENDSCREEN, DScreenJob::fadein|DScreenJob::fadeout|DScreenJob::stopmusic, 0x7fffffff)); break; case 1: Mus_Stop(); - jobs[job++] = { PlayVideo("cineov2.anm", cineov2sound, framespeed_18) }; - jobs[job++] = { Create() }; + jobs.Push(PlayVideo("cineov2.anm", cineov2sound, framespeed_18)); + jobs.Push(Create()); break; case 2: Mus_Stop(); if (g_gameType & GAMEFLAG_DUKEDC) { - jobs[job++] = { PlayVideo("radlogo.anm", dukedcsound, framespeed_10) }; + jobs.Push(PlayVideo("radlogo.anm", dukedcsound, framespeed_10)); } else { - jobs[job++] = { PlayVideo("cineov3.anm", cineov3sound, framespeed_10) }; - jobs[job++] = { Create(200, DScreenJob::stopsound) }; - jobs[job++] = { Create() }; - if (!isPlutoPak()) jobs[job++] = { Create(TexMan.GetGameTextureByName("DUKETEAM.ANM", false, FTextureManager::TEXMAN_ForceLookup), - DScreenJob::fadein | DScreenJob::fadeout | DScreenJob::stopsound, 0x7fffffff) }; + jobs.Push(PlayVideo("cineov3.anm", cineov3sound, framespeed_10)); + jobs.Push(Create(200, DScreenJob::stopsound)); + jobs.Push(Create()); + if (!isPlutoPak()) jobs.Push(Create(TexMan.GetGameTextureByName("DUKETEAM.ANM", false, FTextureManager::TEXMAN_ForceLookup), + DScreenJob::fadein | DScreenJob::fadeout | DScreenJob::stopsound, 0x7fffffff)); } break; case 3: Mus_Stop(); - jobs[job++] = { PlayVideo("vol4e1.anm", vol4e1, framespeed_10) }; - jobs[job++] = { PlayVideo("vol4e2.anm", vol4e2, framespeed_10) }; - jobs[job++] = { PlayVideo("vol4e3.anm", vol4e3, framespeed_10) }; - jobs[job++] = { Create() }; - jobs[job++] = { Create(TexMan.GetGameTextureByName("DUKETEAM.ANM", false, FTextureManager::TEXMAN_ForceLookup), - DScreenJob::fadein | DScreenJob::fadeout | DScreenJob::stopsound, 0x7fffffff) }; + jobs.Push(PlayVideo("vol4e1.anm", vol4e1, framespeed_10)); + jobs.Push(PlayVideo("vol4e2.anm", vol4e2, framespeed_10)); + jobs.Push(PlayVideo("vol4e3.anm", vol4e3, framespeed_10)); + jobs.Push(Create()); + jobs.Push(Create(TexMan.GetGameTextureByName("DUKETEAM.ANM", false, FTextureManager::TEXMAN_ForceLookup), + DScreenJob::fadein | DScreenJob::fadeout | DScreenJob::stopsound, 0x7fffffff)); break; case 4: Mus_Stop(); - jobs[job++] = { Create() }; + jobs.Push(Create()); break; } } @@ -730,22 +730,20 @@ static void bonussequence_d(int num, JobDesc *jobs, int &job) void showtwoscreens(const CompletionFunc& completion) { - JobDesc jobs[2]; - int job = 0; + TArray jobs; - jobs[job++] = { Create(3291) }; - jobs[job++] = { Create(3290) }; - RunScreenJob(jobs, job, completion); + jobs.Push(Create(3291)); + jobs.Push(Create(3290)); + RunScreenJob(jobs, completion); } void doorders(const CompletionFunc& completion) { - JobDesc jobs[4]; - int job = 0; + TArray jobs; for (int i = 0; i < 4; i++) - jobs[job++] = { Create(ORDERING + i) }; - RunScreenJob(jobs, job, completion); + jobs.Push(Create(ORDERING + i)); + RunScreenJob(jobs, completion); } //--------------------------------------------------------------------------- @@ -1097,29 +1095,28 @@ public: void dobonus_d(int bonusonly, const CompletionFunc& completion) { - JobDesc jobs[20]; - int job = 0; + TArray jobs; FX_StopAllSounds(); if (bonusonly < 0 && numplayers < 2 && ud.from_bonus == 0) { - bonussequence_d(volfromlevelnum(currentLevel->levelNumber), jobs, job); + bonussequence_d(volfromlevelnum(currentLevel->levelNumber), jobs); } else Mus_Stop(); if (playerswhenstarted > 1 && ud.coop != 1) { - jobs[job++] = { Create(playerswhenstarted) }; + jobs.Push(Create(playerswhenstarted)); } else if (bonusonly <= 0 && ud.multimode <= 1) { - jobs[job++] = { Create() }; + jobs.Push(Create()); } - if (job) + if (jobs.Size()) { - RunScreenJob(jobs, job, completion); + RunScreenJob(jobs, completion); } else if (completion) completion(false); } @@ -1132,8 +1129,7 @@ void dobonus_d(int bonusonly, const CompletionFunc& completion) void e4intro(const CompletionFunc& completion) { - JobDesc jobs[5]; - int job = 0; + TArray jobs; static const AnimSound vol42a[] = { @@ -1163,10 +1159,10 @@ void e4intro(const CompletionFunc& completion) static const int framespeed_14[] = { 14, 14, 14 }; S_PlaySpecialMusic(MUS_BRIEFING); - jobs[job++] = { PlayVideo("vol41a.anm", vol41a, framespeed_10) }; - jobs[job++] = { PlayVideo("vol42a.anm", vol42a, framespeed_14) }; - jobs[job++] = { PlayVideo("vol43a.anm", vol43a, framespeed_10) }; - RunScreenJob(jobs, job, completion, SJ_SKIPALL); + jobs.Push(PlayVideo("vol41a.anm", vol41a, framespeed_10)); + jobs.Push(PlayVideo("vol42a.anm", vol42a, framespeed_14)); + jobs.Push(PlayVideo("vol43a.anm", vol43a, framespeed_10)); + RunScreenJob(jobs, completion, SJ_SKIPALL); } //--------------------------------------------------------------------------- @@ -1194,8 +1190,10 @@ public: void loadscreen_d(MapRecord *rec, CompletionFunc func) { - JobDesc job = { Create(rec) }; - RunScreenJob(&job, 1, func); + TArray jobs(1, true); + + jobs[0] = Create(rec); + RunScreenJob(jobs, func); } void PrintPaused_d() diff --git a/source/games/duke/src/2d_r.cpp b/source/games/duke/src/2d_r.cpp index 27bd4bd1d..101c41567 100644 --- a/source/games/duke/src/2d_r.cpp +++ b/source/games/duke/src/2d_r.cpp @@ -186,8 +186,7 @@ void Logo_r(const CompletionFunc& completion) static const int framespeed[] = { 9, 9, 9 }; // same for all 3 anims - JobDesc jobs[3]; - int job = 0; + TArray jobs; if (userConfig.nologo) { @@ -196,15 +195,15 @@ void Logo_r(const CompletionFunc& completion) } else if (!isRRRA()) { - jobs[job++] = { PlayVideo("rr_intro.anm", introsound, framespeed) }; - jobs[job++] = { PlayVideo("redneck.anm", rednecksound, framespeed) }; - jobs[job++] = { PlayVideo("xatlogo.anm", xatrixsound, framespeed) }; + jobs.Push(PlayVideo("rr_intro.anm", introsound, framespeed)); + jobs.Push(PlayVideo("redneck.anm", rednecksound, framespeed)); + jobs.Push(PlayVideo("xatlogo.anm", xatrixsound, framespeed)); } else { - jobs[job++] = { PlayVideo("redint.mve") }; + jobs.Push(PlayVideo("redint.mve")); } - RunScreenJob(jobs, job, completion, SJ_BLOCKUI); + RunScreenJob(jobs, completion, SJ_BLOCKUI); } //--------------------------------------------------------------------------- @@ -213,7 +212,7 @@ void Logo_r(const CompletionFunc& completion) // //--------------------------------------------------------------------------- -static void bonussequence_r(int num, JobDesc* jobs, int& job) +static void bonussequence_r(int num, TArray& jobs) { static const AnimSound turdmov[] = { @@ -235,13 +234,13 @@ static void bonussequence_r(int num, JobDesc* jobs, int& job) switch (num) { case 0: - jobs[job++] = { PlayVideo("turdmov.anm", turdmov, framespeed) }; - jobs[job++] = { Create(TENSCREEN) }; + jobs.Push(PlayVideo("turdmov.anm", turdmov, framespeed)); + jobs.Push(Create(TENSCREEN)); break; case 1: - jobs[job++] = { PlayVideo("rr_outro.anm", rr_outro, framespeed) }; - jobs[job++] = { Create(TENSCREEN) }; + jobs.Push(PlayVideo("rr_outro.anm", rr_outro, framespeed)); + jobs.Push(Create(TENSCREEN)); break; default: @@ -594,8 +593,7 @@ public: void dobonus_r(int bonusonly, const CompletionFunc& completion) { - JobDesc jobs[20]; - int job = 0; + TArray jobs; FX_StopAllSounds(); Mus_Stop(); @@ -603,32 +601,32 @@ void dobonus_r(int bonusonly, const CompletionFunc& completion) if (bonusonly < 0 && !isRRRA() && numplayers < 2 && ud.from_bonus == 0) { int vol = volfromlevelnum(currentLevel->levelNumber); - bonussequence_r(vol, jobs, job); + bonussequence_r(vol, jobs); } if (playerswhenstarted > 1 && ud.coop != 1) { - jobs[job++] = { Create(playerswhenstarted) }; + jobs.Push(Create(playerswhenstarted)); } else if (bonusonly <= 0 && ud.multimode <= 1) { if (isRRRA() && !(currentLevel->flags & MI_USERMAP) && currentLevel->levelNumber < 106) // fixme: The logic here is awful. Shift more control to the map records. { - jobs[job++] = { Create(true) }; + jobs.Push(Create(true)); int levnum = clamp((currentLevel->levelNumber / 100) * 7 + (currentLevel->levelNumber % 100), 0, 13); char fn[20]; mysnprintf(fn, 20, "lvl%d.anm", levnum + 1); static const int framespeed[] = { 20, 20, 7200 }; // wait for one minute on the final frame so that the video doesn't stop before the user notices. - jobs[job++] = { PlayVideo(fn, nullptr, framespeed) }; + jobs.Push(PlayVideo(fn, nullptr, framespeed)); if (bonusonly < 0 && currentLevel->levelNumber > 100) { - jobs[job++] = { Create() }; + jobs.Push(Create()); } } - else jobs[job++] = { Create(false) }; + else jobs.Push(Create(false)); } - if (job) - RunScreenJob(jobs, job, completion); + if (jobs.Size()) + RunScreenJob(jobs, completion); else if (completion) completion(false); } @@ -658,8 +656,10 @@ public: void loadscreen_r(MapRecord* rec, CompletionFunc func) { - JobDesc job = { Create(rec) }; - RunScreenJob(&job, 1, func); + TArray jobs(1, true); + + jobs[0] = Create(rec); + RunScreenJob(jobs, func); } void PrintPaused_r() diff --git a/source/games/exhumed/src/2d.cpp b/source/games/exhumed/src/2d.cpp index 7c0b8da0f..b982bc7e1 100644 --- a/source/games/exhumed/src/2d.cpp +++ b/source/games/exhumed/src/2d.cpp @@ -520,15 +520,14 @@ DScreenJob *PlayMovie(const char* fileName); void DoTitle(CompletionFunc completion) { - JobDesc jobs[5]; - int job = 0; + TArray jobs; - jobs[job++] = { Create(tileGetTexture(PublisherLogo()), DScreenJob::fadein | DScreenJob::fadeout) }; - jobs[job++] = { Create(tileGetTexture(seq_GetSeqPicnum(kSeqScreens, 0, 0)), DScreenJob::fadein | DScreenJob::fadeout) }; - jobs[job++] = { PlayMovie("book.mov") }; - jobs[job++] = { Create() }; + jobs.Push(Create(tileGetTexture(PublisherLogo()), DScreenJob::fadein | DScreenJob::fadeout)); + jobs.Push(Create(tileGetTexture(seq_GetSeqPicnum(kSeqScreens, 0, 0)), DScreenJob::fadein | DScreenJob::fadeout)); + jobs.Push(PlayMovie("book.mov")); + jobs.Push(Create()); - RunScreenJob(jobs, job, completion, SJ_BLOCKUI); + RunScreenJob(jobs, completion, SJ_BLOCKUI); } @@ -815,7 +814,7 @@ public: } }; - void menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest, TArray &jobs) + void menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest, TArray &jobs) { if (nLevel > kMap20 || nLevelNew > kMap20) // max single player levels { @@ -829,7 +828,7 @@ public: if (nLevelNew < 1) nLevelNew = nLevel; // 0-offset the level numbers - jobs.Push( { Create(nLevel-1, nLevelNew-1, nLevelBest-1) }); + jobs.Push(Create(nLevel-1, nLevelNew-1, nLevelBest-1)); } //--------------------------------------------------------------------------- @@ -1346,37 +1345,37 @@ public: void DoGameOverScene(bool finallevel) { - JobDesc job; + TArray jobs(1, true); if (finallevel) { - job = { Create(CINEMA_LOSE_SCENE) }; + jobs[0] = Create(CINEMA_LOSE_SCENE); } else { StopCD(); PlayGameOverSound(); - job = { Create(tileGetTexture(kTile3591), DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff, TRANSLATION(Translation_BasePalettes, 16)) }; + jobs[0] = Create(tileGetTexture(kTile3591), DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff, TRANSLATION(Translation_BasePalettes, 16)); } - RunScreenJob(&job, 1, [](bool) { gameaction = ga_mainmenu; }); + RunScreenJob(jobs, [](bool) { gameaction = ga_mainmenu; }); } -void DoAfterCinemaScene(int nLevel, TArray& jobs) +void DoAfterCinemaScene(int nLevel, TArray& jobs) { int scene = -1; if (nLevel == 10) scene = CINEMA_AFTER_LEVEL_10; if (nLevel == 15) scene = CINEMA_AFTER_LEVEL_15; if (nLevel == 20) scene = CINEMA_AFTER_LEVEL_20; - if (scene > 0) jobs.Push({ Create(scene) }); - if (nLevel == 19) { jobs.Push({ Create() }); selectedlevelnew = 20; } - if (nLevel == 20) jobs.Push({ Create() }); + if (scene > 0) jobs.Push(Create(scene)); + if (nLevel == 19) { jobs.Push(Create()); selectedlevelnew = 20; } + if (nLevel == 20) jobs.Push(Create()); } -void DoBeforeCinemaScene(int nLevel, TArray& jobs) +void DoBeforeCinemaScene(int nLevel, TArray& jobs) { - if (nLevel == 5) jobs.Push({ Create(CINEMA_BEFORE_LEVEL_5) }); - else if (nLevel == 11) jobs.Push({ Create(CINEMA_BEFORE_LEVEL_11, 11) }); + if (nLevel == 5) jobs.Push(Create(CINEMA_BEFORE_LEVEL_5)); + else if (nLevel == 11) jobs.Push(Create(CINEMA_BEFORE_LEVEL_11, 11)); } END_PS_NS diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index 87bdc393e..81ae0916d 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -54,8 +54,8 @@ void SetHiRes(); void BlackOut(); void DoGameOverScene(bool finallevel); -void DoAfterCinemaScene(int nLevel, TArray &jobs); -void DoBeforeCinemaScene(int nLevel, TArray& jobs); +void DoAfterCinemaScene(int nLevel, TArray &jobs); +void DoBeforeCinemaScene(int nLevel, TArray& jobs); int Query(short n, short l, ...); @@ -88,7 +88,7 @@ void InitNewGame(); int showmap(short nLevel, short nLevelNew, short nLevelBest); void menu_DoPlasma(); -void menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest, TArray& jobs); +void menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest, TArray& jobs); void DoEnergyTile(); void InitEnergyTile(); diff --git a/source/games/exhumed/src/gameloop.cpp b/source/games/exhumed/src/gameloop.cpp index d810eab56..dd3ef421e 100644 --- a/source/games/exhumed/src/gameloop.cpp +++ b/source/games/exhumed/src/gameloop.cpp @@ -62,7 +62,7 @@ void DrawClock(); double calc_smoothratio(); void DoTitle(CompletionFunc completion); -static void showmap(short nLevel, short nLevelNew, short nLevelBest, TArray &jobs) +static void showmap(short nLevel, short nLevelNew, short nLevelBest, TArray &jobs) { if (nLevelNew == 5 && !(nCinemaSeen & 1)) { nCinemaSeen |= 1; @@ -135,7 +135,7 @@ void GameInterface::DrawBackground() static void Intermission(MapRecord *from_map, MapRecord *to_map) { - TArray jobs; + TArray jobs; if (from_map) StopAllSounds(); bCamera = false; @@ -167,7 +167,7 @@ static void Intermission(MapRecord *from_map, MapRecord *to_map) showmap(from_map ? from_map->levelNumber : -1, to_map->levelNumber, nBestLevel, jobs); } else - jobs.Push({ Create(1) }); // we need something in here even in the multiplayer case. + jobs.Push(Create(1)); // we need something in here even in the multiplayer case. } } else @@ -179,7 +179,7 @@ static void Intermission(MapRecord *from_map, MapRecord *to_map) if (jobs.Size() > 0) { - RunScreenJob(jobs.Data(), jobs.Size(), [=](bool) + RunScreenJob(jobs, [=](bool) { if (!to_map) gameaction = ga_startup; // this was the end of the game else diff --git a/source/games/sw/src/2d.cpp b/source/games/sw/src/2d.cpp index 325a44430..eca216415 100644 --- a/source/games/sw/src/2d.cpp +++ b/source/games/sw/src/2d.cpp @@ -88,11 +88,10 @@ void Logo(const CompletionFunc& completion) if (!userConfig.nologo) { - JobDesc jobs[3]; - int job = 0; - jobs[job++] = { Create() }; - jobs[job++] = { PlayVideo("sw.anm", logosound, logoframetimes, true)}; - RunScreenJob(jobs, job, completion, SJ_BLOCKUI); + TArray jobs; + jobs.Push(Create()); + jobs.Push(PlayVideo("sw.anm", logosound, logoframetimes, true)); + RunScreenJob(jobs, completion, SJ_BLOCKUI); } else completion(false); } @@ -606,26 +605,25 @@ class DSWMultiSummaryScreen : public DSkippableScreenJob void StatScreen(int FinishAnim, CompletionFunc completion) { - JobDesc jobs[5]; - int job = 0; + TArray jobs; if (FinishAnim) { StopSound(); - jobs[job++] = { GetFinishAnim(FinishAnim) }; - jobs[job++] = { Create() }; + jobs.Push(GetFinishAnim(FinishAnim)); + jobs.Push(Create()); if (FinishAnim == ANIM_ZILLA) - jobs[job++] = { Create() }; + jobs.Push(Create()); } else if (gNet.MultiGameType != MULTI_GAME_COMMBAT) { - jobs[job++] = { Create() }; + jobs.Push(Create()); } else { - jobs[job++] = { Create() }; + jobs.Push(Create()); } - RunScreenJob(jobs, job, completion); + RunScreenJob(jobs, completion); } //--------------------------------------------------------------------------- @@ -639,8 +637,9 @@ void SybexScreen(CompletionFunc completion) if (!SW_SHAREWARE || CommEnabled) completion(false); else { - JobDesc job = { Create(tileGetTexture(5261), DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff) }; - RunScreenJob(&job, 1, completion, SJ_BLOCKUI); + TArray jobs(1, true); + jobs[0] = Create(tileGetTexture(5261), DScreenJob::fadein | DScreenJob::fadeout, 0x7fffffff); + RunScreenJob(jobs, completion, SJ_BLOCKUI); } } @@ -670,8 +669,9 @@ public: void loadscreen(MapRecord* rec, CompletionFunc func) { - JobDesc job = { Create(rec) }; - RunScreenJob(&job, 1, func); + TArray jobs(1, true); + jobs[0] = Create(rec); + RunScreenJob(jobs, func); } END_SW_NS