Rearrange contents of GP Backups for future purposes

Also increments minor version for backups
This commit is contained in:
toaster 2023-06-25 21:48:18 +01:00
parent b1b23da51b
commit e9df563826
3 changed files with 62 additions and 44 deletions

View file

@ -5659,7 +5659,7 @@ void G_SaveGameData(void)
// Can be called by the startup code or the menu task.
//
#define SAV_VERSIONMINOR 1
#define SAV_VERSIONMINOR 2
void G_LoadGame(void)
{

View file

@ -5346,10 +5346,33 @@ static inline void P_ArchiveMisc(savebuffer_t *save)
{
WRITESTRINGN(save->p, timeattackfolder, sizeof(timeattackfolder));
// Grand Prix information
WRITEUINT8(save->p, grandprixinfo.gamespeed);
WRITEUINT8(save->p, (UINT8)grandprixinfo.encore);
WRITEUINT8(save->p, (UINT8)grandprixinfo.masterbots);
WRITESTRINGL(save->p, grandprixinfo.cup->name, MAXCUPNAME);
// Round Queue information
WRITEUINT8(save->p, roundqueue.position);
WRITEUINT8(save->p, roundqueue.size);
WRITEUINT8(save->p, roundqueue.roundnum);
UINT8 i;
for (i = 0; i < roundqueue.size; i++)
{
UINT16 mapnum = roundqueue.entries[i].mapnum;
UINT32 val = 0; // no good default, will all-but-guarantee bad save
if (mapnum < nummapheaders && mapheaderinfo[mapnum] != NULL)
val = mapheaderinfo[mapnum]->lumpnamehash;
WRITEUINT32(save->p, val);
}
// Rank information
{
WRITEUINT8(save->p, grandprixinfo.rank.players);
WRITEUINT8(save->p, grandprixinfo.rank.totalPlayers);
@ -5374,22 +5397,7 @@ static inline void P_ArchiveMisc(savebuffer_t *save)
WRITEUINT8(save->p, (UINT8)grandprixinfo.rank.specialWon);
}
WRITESTRINGL(save->p, grandprixinfo.cup->name, MAXCUPNAME);
WRITEUINT8(save->p, roundqueue.position);
WRITEUINT8(save->p, roundqueue.size);
WRITEUINT8(save->p, roundqueue.roundnum);
UINT8 i;
for (i = 0; i < roundqueue.size; i++)
{
UINT16 mapnum = roundqueue.entries[i].mapnum;
UINT32 val = 0; // no good default, will all-but-guarantee bad save
if (mapnum < nummapheaders && mapheaderinfo[mapnum] != NULL)
val = mapheaderinfo[mapnum]->lumpnamehash;
WRITEUINT32(save->p, val);
}
// Marathon information
WRITEUINT8(save->p, (marathonmode & ~MA_INIT));
@ -5420,37 +5428,14 @@ static boolean P_UnArchiveSPGame(savebuffer_t *save)
grandprixinfo.gp = true;
// Grand Prix information
grandprixinfo.gamespeed = READUINT8(save->p);
grandprixinfo.encore = (boolean)READUINT8(save->p);
grandprixinfo.masterbots = (boolean)READUINT8(save->p);
{
grandprixinfo.rank.players = READUINT8(save->p);
grandprixinfo.rank.totalPlayers = READUINT8(save->p);
grandprixinfo.rank.position = READUINT8(save->p);
grandprixinfo.rank.skin = READUINT8(save->p);
grandprixinfo.rank.winPoints = READUINT32(save->p);
grandprixinfo.rank.totalPoints = READUINT32(save->p);
grandprixinfo.rank.laps = READUINT32(save->p);
grandprixinfo.rank.totalLaps = READUINT32(save->p);
grandprixinfo.rank.continuesUsed = READUINT32(save->p);
grandprixinfo.rank.prisons = READUINT32(save->p);
grandprixinfo.rank.totalPrisons = READUINT32(save->p);
grandprixinfo.rank.rings = READUINT32(save->p);
grandprixinfo.rank.totalRings = READUINT32(save->p);
grandprixinfo.rank.specialWon = (boolean)READUINT8(save->p);
}
char cupname[MAXCUPNAME];
// Find the relevant cup.
char cupname[MAXCUPNAME];
READSTRINGL(save->p, cupname, sizeof(cupname));
UINT32 hash = quickncasehash(cupname, MAXCUPNAME);
@ -5471,6 +5456,8 @@ static boolean P_UnArchiveSPGame(savebuffer_t *save)
return false;
}
// Round Queue information
memset(&roundqueue, 0, sizeof(roundqueue));
G_GPCupIntoRoundQueue(grandprixinfo.cup, GT_RACE, grandprixinfo.encore);
@ -5507,6 +5494,34 @@ static boolean P_UnArchiveSPGame(savebuffer_t *save)
return false;
}
// Rank information
{
grandprixinfo.rank.players = READUINT8(save->p);
grandprixinfo.rank.totalPlayers = READUINT8(save->p);
grandprixinfo.rank.position = READUINT8(save->p);
grandprixinfo.rank.skin = READUINT8(save->p);
grandprixinfo.rank.winPoints = READUINT32(save->p);
grandprixinfo.rank.totalPoints = READUINT32(save->p);
grandprixinfo.rank.laps = READUINT32(save->p);
grandprixinfo.rank.totalLaps = READUINT32(save->p);
grandprixinfo.rank.continuesUsed = READUINT32(save->p);
grandprixinfo.rank.prisons = READUINT32(save->p);
grandprixinfo.rank.totalPrisons = READUINT32(save->p);
grandprixinfo.rank.rings = READUINT32(save->p);
grandprixinfo.rank.totalRings = READUINT32(save->p);
grandprixinfo.rank.specialWon = (boolean)READUINT8(save->p);
}
// Marathon information
marathonmode = READUINT8(save->p);
marathontime = READUINT32(save->p);

View file

@ -31,9 +31,12 @@ extern "C" {
// Persistent storage/archiving.
// These are the load / save game routines.
// Local Play
void P_SaveGame(savebuffer_t *save);
void P_SaveNetGame(savebuffer_t *save, boolean resending);
boolean P_LoadGame(savebuffer_t *save);
// Online
void P_SaveNetGame(savebuffer_t *save, boolean resending);
boolean P_LoadNetGame(savebuffer_t *save, boolean reloading);
mobj_t *P_FindNewPosition(UINT32 oldposition);