From 3474fd6e83c265099f4565721d0bb41aa36e8465 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 25 Jun 2023 20:13:15 +0100 Subject: [PATCH] Grand Prix Backup: Store lumpnamehashes of all maps in queue for extra confirmation that the cup's contents are the same between gameboots. --- src/p_saveg.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 6474e5ed9..124285bd1 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -5379,6 +5379,17 @@ static inline void P_ArchiveMisc(savebuffer_t *save) WRITEUINT8(save->p, roundqueue.size); WRITEUINT8(save->p, roundqueue.roundnum); + UINT8 i; + for (i = 0; i < roundqueue.size; i++) + { + UINT16 mapnum = roundqueue.entries[i].mapnum; + UINT32 val = 0; // no good default, will all-but-guarantee bad save + if (mapnum < nummapheaders && mapheaderinfo[mapnum] != NULL) + val = mapheaderinfo[mapnum]->lumpnamehash; + + WRITEUINT32(save->p, val); + } + WRITEUINT8(save->p, (marathonmode & ~MA_INIT)); UINT32 writetime = marathontime; @@ -5469,7 +5480,7 @@ static boolean P_UnArchiveSPGame(savebuffer_t *save) if (roundqueue.size != size) { - CONS_Alert(CONS_ERROR, "P_UnArchiveSPGame: Cup \"%s\"'s level composition has changed between game launches.\n", cupname); + CONS_Alert(CONS_ERROR, "P_UnArchiveSPGame: Cup \"%s\"'s level composition has changed between game launches (differs in level count).\n", cupname); return false; } @@ -5479,6 +5490,22 @@ static boolean P_UnArchiveSPGame(savebuffer_t *save) return false; } + UINT8 i; + for (i = 0; i < roundqueue.size; i++) + { + UINT32 val = READUINT32(save->p); + UINT16 mapnum = roundqueue.entries[i].mapnum; + + if (mapnum < nummapheaders && mapheaderinfo[mapnum] != NULL) + { + if (mapheaderinfo[mapnum]->lumpnamehash == val) + continue; + } + + CONS_Alert(CONS_ERROR, "P_UnArchiveSPGame: Cup \"%s\"'s level composition has changed between game launches (differs at level %u).\n", cupname, i); + return false; + } + marathonmode = READUINT8(save->p); marathontime = READUINT32(save->p);