Commit 7d38c5d6 authored by Richard Gobeille's avatar Richard Gobeille

Duke3d: more work on updated savegame format

parent 15ef402c
......@@ -57,7 +57,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#endif
// increase by 3, because atomic GRP adds 1, and Shareware adds 2
#define BYTEVERSION_EDUKE32 345
#define BYTEVERSION_EDUKE32 348
//#define BYTEVERSION_13 27
//#define BYTEVERSION_14 116
......
......@@ -6575,13 +6575,15 @@ void G_SaveMapState(void)
for (native_t i=g_gameArrayCount-1; i>=0; i--)
{
if (aGameArrays[i].flags & SAVEGAMEMAPSTATEARRAYSKIPMASK)
auto &array = aGameArrays[i];
if (((array.flags & GAMEARRAY_RESTORE) != GAMEARRAY_RESTORE) || array.flags & SAVEGAMEARRAYSKIPMASK)
continue;
save->arraysiz[i] = aGameArrays[i].size;
save->arraysiz[i] = array.size;
Xaligned_free(save->arrays[i]);
save->arrays[i] = (intptr_t *)Xaligned_alloc(ARRAY_ALIGNMENT, Gv_GetArrayAllocSize(i));
Bmemcpy(&save->arrays[i][0], aGameArrays[i].pValues, Gv_GetArrayAllocSize(i));
Bmemcpy(&save->arrays[i][0], array.pValues, Gv_GetArrayAllocSize(i));
}
ototalclock = totalclock;
}
......@@ -6690,14 +6692,16 @@ void G_RestoreMapState(void)
for (native_t i=g_gameArrayCount-1; i>=0; i--)
{
if (aGameArrays[i].flags & SAVEGAMEMAPSTATEARRAYSKIPMASK)
auto &array = aGameArrays[i];
if (((array.flags & GAMEARRAY_RESTORE) != GAMEARRAY_RESTORE) || array.flags & SAVEGAMEARRAYSKIPMASK)
continue;
aGameArrays[i].size = pSavedState->arraysiz[i];
Xaligned_free(aGameArrays[i].pValues);
aGameArrays[i].pValues = (intptr_t *) Xaligned_alloc(ARRAY_ALIGNMENT, Gv_GetArrayAllocSize(i));
array.size = pSavedState->arraysiz[i];
Xaligned_free(array.pValues);
array.pValues = (intptr_t *) Xaligned_alloc(ARRAY_ALIGNMENT, Gv_GetArrayAllocSize(i));
Bmemcpy(aGameArrays[i].pValues, pSavedState->arrays[i], Gv_GetArrayAllocSize(i));
Bmemcpy(array.pValues, pSavedState->arrays[i], Gv_GetArrayAllocSize(i));
}
Gv_RefreshPointers();
......
This diff is collapsed.
......@@ -39,7 +39,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define SAVEGAMEARRAYSKIPMASK (GAMEARRAY_READONLY|GAMEARRAY_SYSTEM)
#define SAVEGAMEMAPSTATEVARSKIPMASK (GAMEVAR_NORESET|SAVEGAMEVARSKIPMASK)
#define SAVEGAMEMAPSTATEARRAYSKIPMASK (SAVEGAMEARRAYSKIPMASK|~GAMEARRAY_RESTORE)
// store global game definitions
enum GamevarFlags_t
......
......@@ -2074,7 +2074,7 @@ void G_FreeMapState(int levelNum)
for (int j=0; j<g_gameVarCount; j++)
{
if (aGameVars[j].flags & GAMEVAR_NORESET)
if (aGameVars[j].flags & SAVEGAMEMAPSTATEVARSKIPMASK)
continue;
if (aGameVars[j].flags & (GAMEVAR_PERPLAYER|GAMEVAR_PERACTOR))
......@@ -2083,6 +2083,9 @@ void G_FreeMapState(int levelNum)
for (int j=0; j<g_gameArrayCount; j++)
{
if (aGameArrays[j].flags & SAVEGAMEARRAYSKIPMASK)
continue;
if (aGameArrays[j].flags & GAMEARRAY_RESTORE)
ALIGNED_FREE_AND_NULL(board.savedstate->arrays[j]);
}
......
......@@ -1492,7 +1492,6 @@ static const dataspec_t svgm_script[] =
};
static char svgm_anmisc_string [] = "blK:anms";
static char svgm_end_string [] = "savegame_end";
static const dataspec_t svgm_anmisc[] =
{
......@@ -1521,7 +1520,6 @@ static const dataspec_t svgm_anmisc[] =
{ 0, savegame_restdata, 1, sizeof(savegame_restdata) }, // sz/cnt swapped for kdfread
{ DS_LOADFN, (void *)&sv_restload, 0, 1 },
{ DS_STRING, (void *)svgm_end_string, 0, 1 },
{ DS_END, 0, 0, 0 }
};
......
......@@ -56,8 +56,8 @@ typedef struct _savehead
uint8_t numplayers, volnum, levnum, skill;
// this is kind of shitty, but changing the size of savehead_t would break the checkpoint saves in Fury
char boardfn[BMAX_PATH-16];
char scriptname[16];
char boardfn[BMAX_PATH-32];
char scriptname[32];
// 286 bytes
#ifdef __ANDROID__
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment