Skip to content

Commit

Permalink
hexen: Fix wrong save being deleted (#1227)
Browse files Browse the repository at this point in the history
* hexen: Fix wrong save being deleted

If a save occurs on pages 1, 2 or 3, it has the potential to delete the
save in the corresponding slot on pages 2, 4 or 6.

* hexen: Refactor savefile page handling
  • Loading branch information
mikeday0 authored Sep 16, 2024
1 parent af1bd52 commit 5a3e8ef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
6 changes: 4 additions & 2 deletions src/hexen/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,8 @@ void G_LoadGame(int slot)
void G_DoLoadGame(void)
{
gameaction = ga_nothing;
SV_LoadGame(GameLoadSlot);
// [crispy] support multiple pages of saves
SV_LoadGame(GameLoadSlot + savepage * 10);
if (!netgame)
{ // Copy the base slot to the reborn slot
SV_UpdateRebornSlot();
Expand Down Expand Up @@ -2127,7 +2128,8 @@ void G_SaveGame(int slot, char *description)

void G_DoSaveGame(void)
{
SV_SaveGame(savegameslot, savedescription);
// [crispy] support multiple pages of saves
SV_SaveGame(savegameslot + savepage * 10, savedescription);
gameaction = ga_nothing;
savedescription[0] = 0;
P_SetMessage(&players[consoleplayer], TXT_GAMESAVED, true);
Expand Down
4 changes: 3 additions & 1 deletion src/hexen/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ int InfoType;
int messageson = true;
boolean mn_SuicideConsole;

int savepage; // [crispy] support 8 pages of savegames

// PRIVATE DATA DEFINITIONS ------------------------------------------------

static int FontABaseLump;
Expand Down Expand Up @@ -1263,7 +1265,7 @@ static void SCDeleteGame(int option)
return;
}

SV_ClearSaveSlot(option);
SV_ClearSaveSlot(option + savepage * 10);
CurrentMenu->oldItPos = CurrentItPos;
MN_LoadSlotText();
BorderNeedRefresh = true;
Expand Down
20 changes: 0 additions & 20 deletions src/hexen/sv_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ char *SavePath = DEFAULT_SAVEPATH;

int vanilla_savegame_limit = 1;

int savepage; // [crispy] support 8 pages of savegames

// PRIVATE DATA DEFINITIONS ------------------------------------------------

static int MobjCount;
Expand Down Expand Up @@ -1980,12 +1978,6 @@ void SV_SaveGame(int slot, const char *description)
char versionText[HXS_VERSION_TEXT_LENGTH];
unsigned int i;

// [crispy] get expanded save slot number
if (slot != BASE_SLOT && slot != REBORN_SLOT)
{
slot += savepage * 10;
}

// Open the output file
M_snprintf(fileName, sizeof(fileName), "%shex%d.hxs", SavePath, BASE_SLOT);
SV_OpenWrite(fileName);
Expand Down Expand Up @@ -2092,12 +2084,6 @@ void SV_LoadGame(int slot)

p = &players[consoleplayer]; // [crispy]

// [crispy] get expanded save slot number
if (slot != BASE_SLOT && slot != REBORN_SLOT)
{
slot += savepage * 10;
}

// Copy all needed save files to the base slot
if (slot != BASE_SLOT)
{
Expand Down Expand Up @@ -3284,12 +3270,6 @@ void SV_ClearSaveSlot(int slot)
int i;
char fileName[100];

// [crispy] get expanded save slot number
if (slot != BASE_SLOT && slot != REBORN_SLOT)
{
slot += savepage * 10;
}

for (i = 0; i < MAX_MAPS; i++)
{
M_snprintf(fileName, sizeof(fileName),
Expand Down

0 comments on commit 5a3e8ef

Please sign in to comment.