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
This commit is contained in:
helixhorned 2012-10-03 15:29:12 +00:00
parent 30856c3949
commit f8480d00f9
2 changed files with 12 additions and 20 deletions

View file

@ -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);
}
}

View file

@ -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; i<lightcount; i++)
{
CPDAT(&prlights[i], sizeof(_prlight));
((_prlight *)(mem-sizeof(_prlight)))->planelist = 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<lightcount; i++)
// CPDAT(&prlights[i], sizeof(_prlight));
#endif
#undef CPDAT
}