- 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 e4intro(CompletionFunc completion);
void clearfrags(void);
int exitlevel();
void exitlevel();
int enterlevel(MapRecord* mi, int gm);
void newgame(MapRecord* mi, int sk, CompletionFunc completion);
void donewgame(MapRecord* map, int sk);

View file

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

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