diff --git a/src/d_main.c b/src/d_main.c index 65d199912..d9eee1b0d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -977,7 +977,7 @@ void D_ClearState(void) cursongcredit.def = NULL; - if (gamedata->deferredsave) + if (gamedata && gamedata->deferredsave) G_SaveGameData(true); G_SetGamestate(GS_NULL); diff --git a/src/g_game.c b/src/g_game.c index 42d2ddd92..d63de1937 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4558,11 +4558,11 @@ void G_SaveGameData(boolean dirty) UINT8 btemp; savebuffer_t save = {0}; - gamedata->deferredsave = false; - - if (!gamedata->loaded) + if (gamedata == NULL || !gamedata->loaded) return; // If never loaded (-nodata), don't save + gamedata->deferredsave = false; + if (usedCheats) { #ifdef DEVELOP diff --git a/src/m_cond.c b/src/m_cond.c index cfaee1e73..df84c7783 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -1090,6 +1090,12 @@ boolean M_UpdateUnlockablesAndExtraEmblems(boolean loud) INT32 i; UINT8 response = 0; + if (!gamedata) + { + // Don't attempt to write/check anything. + return false; + } + if (!loud) { // Just in case they aren't to sync diff --git a/src/p_tick.c b/src/p_tick.c index 8433b4ac3..bf44ca38a 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -633,7 +633,7 @@ void P_Ticker(boolean run) // TODO would this be laggy with more conditions in play... if ((!demo.playback && M_UpdateUnlockablesAndExtraEmblems(true)) - || gamedata->deferredsave) + || (gamedata && gamedata->deferredsave)) G_SaveGameData(true); }