- changed startnewgame to handle the screen jobs asynchronously.

This commit is contained in:
Christoph Oelckers 2020-07-19 00:26:36 +02:00
parent a3e9ea97a8
commit a1001c5fdd
3 changed files with 32 additions and 25 deletions

View file

@ -55,7 +55,8 @@ static void dowarp(MapRecord *map)
if (ps[myconnectindex].gm & MODE_GAME)
{
newgame(map, ud.m_player_skill);
ready2send = 0;
donewgame(map, ud.m_player_skill);
ps[myconnectindex].gm = MODE_RESTART;
}
else startnewgame(map, ud.m_player_skill);

View file

@ -225,7 +225,8 @@ void e4intro(CompletionFunc completion);
void clearfrags(void);
int exitlevel();
int enterlevel(MapRecord* mi, int gm);
void newgame(MapRecord* mi, int sk);
void newgame(MapRecord* mi, int sk, CompletionFunc completion);
void donewgame(MapRecord* map, int sk);
void startnewgame(MapRecord* map, int skill);
void setlocalplayerinput(player_struct *pp);
void PlayerColorChanged(void);

View file

@ -771,7 +771,7 @@ void resettimevars(void)
//
//---------------------------------------------------------------------------
static void donewgame(MapRecord* map, int sk)
void donewgame(MapRecord* map, int sk)
{
auto p = &ps[0];
show_shareware = 26 * 34;
@ -837,29 +837,33 @@ static void donewgame(MapRecord* map, int sk)
}
}
void newgame(MapRecord* map, int sk)
void newgame(MapRecord* map, int sk, CompletionFunc completion)
{
handleevents();
ready2send = 0;
auto completion = [=](bool)
auto completion1 = [=](bool res)
{
if (!isRR() && map->levelNumber == levelnum(3, 0) && (ud.multimode < 2))
{
e4intro([=](bool) { donewgame(map, sk); });
e4intro([=](bool) { donewgame(map, sk); if (completion) completion(res); });
}
else
{
donewgame(map, sk);
if (completion) completion(res);
}
else donewgame(map, sk);
};
if (ud.m_recstat != 2 && ud.last_level >= 0 && ud.multimode > 1 && ud.coop != 1)
dobonus(1, completion);
dobonus(1, completion1);
#if 0 // this is one lousy hack job that's hopefully not needed anymore.
else if (isRR() && !isRRRA() && map->levelNumber == levelnum(0, 6))
dobonus(0, completion);
dobonus(0, completion1);
#endif
else completion(false);
else completion1(false);
}
//---------------------------------------------------------------------------
@ -1029,8 +1033,8 @@ int enterlevel(MapRecord *mi, int gamemode)
void startnewgame(MapRecord* map, int skill)
{
newgame(map, skill);
newgame(map, skill, [=](bool)
{
if (enterlevel(map, MODE_GAME))
{
ps[myconnectindex].gm = 0;
@ -1044,6 +1048,7 @@ void startnewgame(MapRecord* map, int skill)
inputState.ClearAllInput();
gamestate = GS_LEVEL;
}
});
}
//---------------------------------------------------------------------------