From 4f8df124039cf59c1263f6f6eafcb48568d1d15e Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 3 Mar 2023 15:59:25 +0000 Subject: [PATCH] M_PopulateChallengeGrid: Remove bad challengegrid when I_Erroring to prevent corrupted save --- src/m_cond.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/m_cond.c b/src/m_cond.c index e1e7f8432..ce67bfe99 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -214,7 +214,11 @@ quickcheckagain: if (nummajorunlocks > 0) { - I_Error("M_PopulateChallengeGrid: was not able to populate %d large tiles (width %d)", nummajorunlocks, gamedata->challengegridwidth); + UINT16 widthtoprint = gamedata->challengegridwidth; + Z_Free(gamedata->challengegrid); + gamedata->challengegrid = NULL; + + I_Error("M_PopulateChallengeGrid: was not able to populate %d large tiles (width %d)", nummajorunlocks, widthtoprint); } } @@ -232,6 +236,10 @@ quickcheckagain: if (numunlocks > numempty) { + gamedata->challengegridwidth = 0; + Z_Free(gamedata->challengegrid); + gamedata->challengegrid = NULL; + I_Error("M_PopulateChallengeGrid: %d small unlocks vs %d empty spaces (%d gap)", numunlocks, numempty, (numunlocks-numempty)); }