From f8480d00f9887a758e9c5bcf1a0a9288ba456a24 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Wed, 3 Oct 2012 15:29:12 +0000 Subject: [PATCH] In savegames, store dummy constant-length block instead of a _prlight array. sizeof(_prlight) differs across compilers, and besides, Polymer lights were not loaded anyway (they're restored live in-game later). The savegame version was not bumped, but only savegames made with builds where sizeof(_prlight)==261 (like synthesis) will stay compatible! Report and helpful debugging information by LeoD. git-svn-id: https://svn.eduke32.com/eduke32@3052 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/menus.c | 2 +- polymer/eduke32/source/savegame.c | 30 +++++++++++------------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 6717543f1..d24468e7c 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -672,7 +672,7 @@ static void Menus_LoadSave_DisplayCommon1(void) mgametext(31,104,tempbuf,0,2+8+16); Bsprintf(tempbuf,"Our: %d.%d.%d %d-bit", SV_MAJOR_VER, SV_MINOR_VER, BYTEVERSION, (int32_t)(8*sizeof(intptr_t))); - mgametext(31+16,114,tempbuf,0,2+8+16); + mgametext(31+16,QUOTE_SAVE_BAD_VERSION,tempbuf,0,2+8+16); } } diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index 1d4a269a7..039c639af 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -844,9 +844,17 @@ static void sv_postquoteredef(); static void sv_restsave(); static void sv_restload(); +// This used to be sizeof(_prlight)*PR_MAXLIGHTS + sizeof(lightcount), but +// 1) we haven't been loading Polymer lights since a while now since they're +// restored by polymer_loadboard() and +// 2) sizeof(_prlight) differs across compilers, see +// http://forums.duke4.net/topic/5686-synchronize-game-save-data-across-multiple-eduke32-installations +// Can be removed with the next savegame version bump. +#define TRAILINGBYTES (261*1024 + 4) + #define SVARDATALEN \ ((sizeof(g_player[0].user_name)+sizeof(g_player[0].pcolor)+sizeof(g_player[0].pteam) \ - +sizeof(g_player[0].frags)+sizeof(DukePlayer_t))*MAXPLAYERS + sizeof(_prlight)*PR_MAXLIGHTS + sizeof(lightcount)) + +sizeof(g_player[0].frags)+sizeof(DukePlayer_t))*MAXPLAYERS + TRAILINGBYTES) static uint32_t savegame_bitptrsize; static uint8_t savegame_quotedef[MAXQUOTES>>3]; @@ -1600,20 +1608,9 @@ static void sv_restsave() else CPDAT(&dummy_ps, sizeof(DukePlayer_t)); } -#ifdef POLYMER - // what's the point of doing this when we polymer_resetlights() through polymer_loadboard() - // later on anyway? - CPDAT(&lightcount, sizeof(lightcount)); - for (i=0; iplanelist = NULL; - } -#endif - Bassert((savegame_restdata+SVARDATALEN)-mem >= 0); - - Bmemset(mem, 0, (savegame_restdata+SVARDATALEN)-mem); + Bassert((savegame_restdata+SVARDATALEN)-mem == TRAILINGBYTES); + Bmemset(mem, 0, TRAILINGBYTES); #undef CPDAT } static void sv_restload() @@ -1634,11 +1631,6 @@ static void sv_restload() else CPDAT(&dummy_ps, sizeof(DukePlayer_t)); } -#ifdef POLYMER -// CPDAT(&lightcount, sizeof(lightcount)); -// for (i=0; i