From 3027d254fe9c6501c69a0d37852c8d85d3787e54 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 24 May 2023 18:24:58 +0100 Subject: [PATCH] Rollover protection for unloaded mapheader record tracking system You will run into memory limits before this happens, but... if you have major quantities of unloaded mapheader record data, avoid a rollover in the counter of records to write. --- src/g_game.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 0a91da2ed..a458d78e4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -5141,7 +5141,12 @@ void G_SaveGameData(void) continue; } - numgamedatamapheaders++; + // It's far off on the horizon, beyond many memory limits, but prevent a potential misery moment of losing ALL your data. + if (++numgamedatamapheaders == UINT32_MAX) + { + CONS_Alert(CONS_WARNING, "Some unloaded map record data has been dropped due to datatype limitations.\n"); + break; + } } length += 4 + (numgamedatamapheaders * (MAXMAPLUMPNAME+1+4+4));