- use lambdas instead of templates for chaining ExitFromMenu's actions.

This commit is contained in:
Christoph Oelckers 2020-11-29 00:04:04 +01:00
parent f2f095c469
commit 7887c4e80d
2 changed files with 19 additions and 28 deletions

View file

@ -195,7 +195,6 @@ void initcrane(DDukeActor* actj, DDukeActor* acti, int CRANEPOLE);
void initwaterdrip(DDukeActor* actj, DDukeActor* acti);
int initreactor(DDukeActor* actj, DDukeActor* acti, bool isrecon);
void spawneffector(DDukeActor* actor);
void gameexitfrommenu();
int startrts(int lumpNum, int localPlayer);
void pickrandomspot(int pn);

View file

@ -84,27 +84,6 @@ GameStats GameInterface::getStats()
//
//---------------------------------------------------------------------------
template<class func>
void runbonus(func completion)
{
// MP scoreboard
if (playerswhenstarted > 1 && !ud.coop)
{
dobonus(1, completion);
}
else completion(false);
}
template <class func>
void runtwoscreens(func completion)
{
// shareware and TEN screens
if (isShareware() && !isRR())
showtwoscreens(completion);
else completion(false);
}
static void endthegame(bool)
{
endoomName = isRR() ? "redneck.bin" : !isShareware() ? "duke3d.bin" : "dukesw.bin";
@ -112,14 +91,27 @@ static void endthegame(bool)
}
void gameexitfrommenu()
{
runbonus([](bool aborted) { runtwoscreens(endthegame); });
}
void GameInterface::ExitFromMenu()
{
gameexitfrommenu();
auto runbonus = [=](auto completion)
{
// MP scoreboard
if (playerswhenstarted > 1 && !ud.coop)
{
dobonus(1, completion);
}
else completion(false);
};
auto runtwoscreens = [](auto completion)
{
// shareware and TEN screens
if (isShareware() && !isRR())
showtwoscreens(completion);
else completion(false);
};
runbonus([=](bool aborted) { runtwoscreens(endthegame); });
}
//---------------------------------------------------------------------------