Challenge Grid: set height to 4

- In anticipation of next steps of menu redesign
- g_game.c: Increment GD_VERSIONMINOR and burn old challenge grid data
This commit is contained in:
toaster 2023-02-23 17:57:01 +00:00
parent d17525fac7
commit 97612ba26e
2 changed files with 31 additions and 13 deletions

View file

@ -4354,7 +4354,7 @@ void G_LoadGameSettings(void)
}
#define GD_VERSIONCHECK 0xBA5ED123 // Change every major version, as usual
#define GD_VERSIONMINOR 0 // Change every format update
#define GD_VERSIONMINOR 1 // Change every format update
// G_LoadGameData
// Loads the main data file, which stores information such as emblems found, etc.
@ -4364,6 +4364,7 @@ void G_LoadGameData(void)
UINT32 versionID;
UINT8 versionMinor;
UINT8 rtemp;
boolean gridunusable = false;
savebuffer_t save = {0};
//For records
@ -4418,6 +4419,10 @@ void G_LoadGameData(void)
P_SaveBufferFree(&save);
I_Error("Game data is from the future! (expected %d, got %d)", GD_VERSIONMINOR, versionMinor);
}
if (versionMinor == 0)
{
gridunusable = true;
}
gamedata->totalplaytime = READUINT32(save.p);
gamedata->matchesplayed = READUINT32(save.p);
@ -4464,21 +4469,34 @@ void G_LoadGameData(void)
i += j;
}
gamedata->challengegridwidth = READUINT16(save.p);
Z_Free(gamedata->challengegrid);
if (gamedata->challengegridwidth)
if (gridunusable)
{
gamedata->challengegrid = Z_Malloc(
(gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT * sizeof(UINT8)),
PU_STATIC, NULL);
for (i = 0; i < (gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT); i++)
{
gamedata->challengegrid[i] = READUINT8(save.p);
}
UINT16 burn = READUINT16(save.p); // Previous challengegridwidth
UINT8 height = (versionMinor > 0) ? CHALLENGEGRIDHEIGHT : 5;
save.p += (burn * height * sizeof(UINT8)); // Step over previous grid data
gamedata->challengegridwidth = 0;
Z_Free(gamedata->challengegrid);
gamedata->challengegrid = NULL;
}
else
{
gamedata->challengegrid = NULL;
gamedata->challengegridwidth = READUINT16(save.p);
Z_Free(gamedata->challengegrid);
if (gamedata->challengegridwidth)
{
gamedata->challengegrid = Z_Malloc(
(gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT * sizeof(UINT8)),
PU_STATIC, NULL);
for (i = 0; i < (gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT); i++)
{
gamedata->challengegrid[i] = READUINT8(save.p);
}
}
else
{
gamedata->challengegrid = NULL;
}
}
gamedata->timesBeaten = READUINT32(save.p);

View file

@ -139,7 +139,7 @@ typedef enum
#define MAXEMBLEMS 512
#define MAXUNLOCKABLES MAXCONDITIONSETS
#define CHALLENGEGRIDHEIGHT 5
#define CHALLENGEGRIDHEIGHT 4
#ifdef DEVELOP
#define CHALLENGEGRIDLOOPWIDTH 3
#else