- restructured exitlevel for asynchronous handling of the summary screen.

This commit is contained in:
Christoph Oelckers 2020-07-19 00:53:13 +02:00
parent a1001c5fdd
commit 72bf70811e
3 changed files with 41 additions and 36 deletions

View file

@ -223,7 +223,7 @@ void prelevel_d(int g);
void prelevel_r(int g); void prelevel_r(int g);
void e4intro(CompletionFunc completion); void e4intro(CompletionFunc completion);
void clearfrags(void); void clearfrags(void);
int exitlevel(); void exitlevel();
int enterlevel(MapRecord* mi, int gm); int enterlevel(MapRecord* mi, int gm);
void newgame(MapRecord* mi, int sk, CompletionFunc completion); void newgame(MapRecord* mi, int sk, CompletionFunc completion);
void donewgame(MapRecord* map, int sk); void donewgame(MapRecord* map, int sk);

View file

@ -350,11 +350,7 @@ bool GameTicker()
if (ps[myconnectindex].gm & (MODE_EOL | MODE_RESTART)) if (ps[myconnectindex].gm & (MODE_EOL | MODE_RESTART))
{ {
switch (exitlevel()) exitlevel();
{
case 1: return false;
case 2: return true;
}
} }

View file

@ -1102,7 +1102,19 @@ bool setnextmap(bool checksecretexit)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int exitlevel(void) int exitlevelend()
{
ready2send = 0;
if (numplayers > 1)
ps[myconnectindex].gm = MODE_GAME;
int res = enterlevel(ud.nextLevel, ps[myconnectindex].gm);
ud.nextLevel = nullptr;
return res;
}
void exitlevel(void)
{ {
bool endofgame = ud.eog || (currentLevel->flags & MI_FORCEEOG) || ud.nextLevel == nullptr; bool endofgame = ud.eog || (currentLevel->flags & MI_FORCEEOG) || ud.nextLevel == nullptr;
STAT_Update(endofgame); STAT_Update(endofgame);
@ -1117,7 +1129,8 @@ int exitlevel(void)
if (ps[myconnectindex].gm & MODE_EOL) if (ps[myconnectindex].gm & MODE_EOL)
{ {
ready2send = 0; ready2send = 0;
dobonus(0, nullptr); dobonus(0, [=](bool)
{
// Clear potentially loaded per-map ART only after the bonus screens. // Clear potentially loaded per-map ART only after the bonus screens.
artClearMapArt(); artClearMapArt();
@ -1127,27 +1140,23 @@ int exitlevel(void)
ud.eog = 0; ud.eog = 0;
if (ud.multimode < 2) if (ud.multimode < 2)
{ {
if (!VOLUMEALL)
doorders([](bool) {});
ps[myconnectindex].gm = 0; ps[myconnectindex].gm = 0;
return 2; if (!VOLUMEALL)
doorders([](bool) { gamestate = GS_STARTUP; });
else gamestate = GS_STARTUP;
return;
} }
else else
{ {
ud.nextLevel = FindMapByLevelNum(0); ud.nextLevel = FindMapByLevelNum(0);
if (!ud.nextLevel) return 2; if (!ud.nextLevel || exitlevelend())
gamestate = GS_STARTUP;
} }
} }
});
} }
if (exitlevelend())
ready2send = 0; gamestate = GS_STARTUP;
if (numplayers > 1)
ps[myconnectindex].gm = MODE_GAME;
int res = enterlevel(ud.nextLevel, ps[myconnectindex].gm);
ud.nextLevel = nullptr;
return res ? 2 : 1;
} }