diff --git a/src/d_main.c b/src/d_main.c index 1a58ee89a..9702eda1b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -709,7 +709,8 @@ void D_StartTitle(void) botskin = 0; cv_debug = 0; emeralds = 0; - + lastmaploaded = 0; + // In case someone exits out at the same time they start a time attack run, // reset modeattacking modeattacking = ATTACKING_NONE; diff --git a/src/doomstat.h b/src/doomstat.h index 5e99a5978..8eec860c3 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -42,6 +42,7 @@ extern UINT8 globalweather; extern INT32 curWeather; extern INT32 cursaveslot; extern INT16 lastmapsaved; +extern INT16 lastmaploaded; extern boolean gamecomplete; #define PRECIP_NONE 0 diff --git a/src/g_game.c b/src/g_game.c index 7769555ba..1923be04a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -78,6 +78,7 @@ UINT8 globalweather = 0; INT32 curWeather = PRECIP_NONE; INT32 cursaveslot = -1; // Auto-save 1p savegame slot INT16 lastmapsaved = 0; // Last map we auto-saved at +INT16 lastmaploaded = 0; // Last map the game loaded boolean gamecomplete = false; UINT16 mainwads = 0; diff --git a/src/p_saveg.c b/src/p_saveg.c index 3853dc7e6..f09e0163e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3160,7 +3160,8 @@ static inline void P_ArchiveMisc(void) WRITEINT16(save_p, gamemap); lastmapsaved = gamemap; - + lastmaploaded = gamemap; + WRITEUINT16(save_p, (botskin ? (emeralds|(1<<10)) : emeralds)+357); WRITESTRINGN(save_p, timeattackfolder, sizeof(timeattackfolder)); } @@ -3185,7 +3186,8 @@ static inline void P_UnArchiveSPGame(INT16 mapoverride) P_AllocMapHeader(gamemap-1); lastmapsaved = gamemap; - + lastmaploaded = gamemap; + tokenlist = 0; token = 0; diff --git a/src/p_setup.c b/src/p_setup.c index ad737f3d5..b8491d67b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2984,10 +2984,12 @@ boolean P_SetupLevel(boolean skipprecip) P_RunCachedActions(); if (!(netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking || players[consoleplayer].lives <= 0) - && (!modifiedgame || savemoddata) && cursaveslot >= 0 && !ultimatemode && !(G_IsSpecialStage(gamemap)) && !(mapheaderinfo[gamemap-1]->savemode == 2) - && ((mapheaderinfo[gamemap-1]->savemode == 1) || (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) && gamemap != lastmapsaved && (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete)))) + && (!modifiedgame || savemoddata) && cursaveslot >= 0 && !ultimatemode && !(G_IsSpecialStage(gamemap)) && (gamemap != lastmaploaded) && !(mapheaderinfo[gamemap-1]->savemode == 2) + && ((mapheaderinfo[gamemap-1]->savemode == 1) || (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) && (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete)))) G_SaveGame((UINT32)cursaveslot); + lastmaploaded = gamemap; // HAS to be set after saving!! + if (savedata.lives > 0) { players[consoleplayer].continues = savedata.continues; @@ -3014,7 +3016,7 @@ boolean P_SetupLevel(boolean skipprecip) LUAh_MapLoad(); #endif } - + return true; }