relocate savedata code from P_LoadLevel to G_InitNew as well

(this doesn't fix !1064 yet, this just makes the code a bit tidier)
This commit is contained in:
Monster Iestyn 2023-07-31 20:06:28 +01:00
parent d20ca3d919
commit 77d70aaa1b
2 changed files with 14 additions and 12 deletions

View file

@ -5061,6 +5061,7 @@ void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean
players[i].starpostx = players[i].starposty = players[i].starpostz = 0; players[i].starpostx = players[i].starposty = players[i].starpostz = 0;
players[i].recordscore = 0; players[i].recordscore = 0;
// default lives, continues and score
if (netgame || multiplayer) if (netgame || multiplayer)
{ {
if (!FLS || (players[i].lives < 1)) if (!FLS || (players[i].lives < 1))
@ -5120,6 +5121,19 @@ void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean
automapactive = false; automapactive = false;
imcontinuing = false; imcontinuing = false;
// fetch saved data if available
if (savedata.lives > 0)
{
numgameovers = savedata.numgameovers;
players[consoleplayer].continues = savedata.continues;
players[consoleplayer].lives = savedata.lives;
players[consoleplayer].score = savedata.score;
if ((botingame = ((botskin = savedata.botskin) != 0)))
botcolor = skins[botskin-1].prefcolor;
emeralds = savedata.emeralds;
savedata.lives = 0;
}
if ((gametyperules & GTR_CUTSCENES) && !skipprecutscene && mapheaderinfo[gamemap-1]->precutscenenum && !modeattacking && !(marathonmode & MA_NOCUTSCENES)) // Start a custom cutscene. if ((gametyperules & GTR_CUTSCENES) && !skipprecutscene && mapheaderinfo[gamemap-1]->precutscenenum && !modeattacking && !(marathonmode & MA_NOCUTSCENES)) // Start a custom cutscene.
F_StartCustomCutscene(mapheaderinfo[gamemap-1]->precutscenenum-1, true, resetplayer, FLS); F_StartCustomCutscene(mapheaderinfo[gamemap-1]->precutscenenum-1, true, resetplayer, FLS);
else else

View file

@ -7795,18 +7795,6 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
R_InitMobjInterpolators(); R_InitMobjInterpolators();
P_InitCachedActions(); P_InitCachedActions();
if (!fromnetsave && savedata.lives > 0)
{
numgameovers = savedata.numgameovers;
players[consoleplayer].continues = savedata.continues;
players[consoleplayer].lives = savedata.lives;
players[consoleplayer].score = savedata.score;
if ((botingame = ((botskin = savedata.botskin) != 0)))
botcolor = skins[botskin-1].prefcolor;
emeralds = savedata.emeralds;
savedata.lives = 0;
}
// internal game map // internal game map
maplumpname = G_BuildMapName(gamemap); maplumpname = G_BuildMapName(gamemap);
lastloadedmaplumpnum = W_CheckNumForMap(maplumpname); lastloadedmaplumpnum = W_CheckNumForMap(maplumpname);