G_LoadGamedata: Add a sanity check when imbibing pendingkeyroundoffset

Should solve Laz's infinite key increment hell
This commit is contained in:
toaster 2023-12-26 15:52:22 +00:00
parent 798e016aa1
commit 43880b4a4b

View file

@ -4691,6 +4691,16 @@ void G_LoadGameData(void)
gamedata->keyspending = READUINT16(save.p);
}
// Sanity check.
if (gamedata->pendingkeyroundoffset >= GDCONVERT_ROUNDSTOKEY)
{
gamedata->pendingkeyrounds +=
(gamedata->pendingkeyroundoffset
- (GDCONVERT_ROUNDSTOKEY-1));
gamedata->pendingkeyroundoffset = (GDCONVERT_ROUNDSTOKEY-1);
gamedata->keyspending = 0; // safe to nuke - will be recalc'd if the offset still permits
}
gamedata->chaokeys = READUINT16(save.p);
if (versionMinor >= 4)