Skip to content

Commit

Permalink
Game Save|Hexen: Add saveinfo_t for the "base" slot
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jun 23, 2012
1 parent b54e32f commit 0459a7b
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions doomsday/plugins/common/src/p_saveio.c
Expand Up @@ -44,6 +44,9 @@ static ddstring_t clientSavePath; // e.g., "savegame/client/"
#endif
static saveinfo_t* saveInfo;
static saveinfo_t autoSaveInfo;
#if __JHEXEN__
static saveinfo_t baseSaveInfo;
#endif

#if __JHEXEN__
static saveptr_t saveptr;
Expand Down Expand Up @@ -227,6 +230,9 @@ void SV_ShutdownIO(void)
free(saveInfo); saveInfo = NULL;

clearSaveInfo(&autoSaveInfo);
#if __JHEXEN__
clearSaveInfo(&baseSaveInfo);
#endif
}

Str_Free(&savePath);
Expand Down Expand Up @@ -423,6 +429,9 @@ static void buildSaveInfo(void)
initSaveInfo(info);
}
initSaveInfo(&autoSaveInfo);
#if __JHEXEN__
initSaveInfo(&baseSaveInfo);
#endif
}

/// Scan the save paths and populate the list.
Expand All @@ -434,6 +443,9 @@ static void buildSaveInfo(void)
updateSaveInfo(info, composeGameSavePathForSlot(i));
}
updateSaveInfo(&autoSaveInfo, composeGameSavePathForSlot(AUTO_SLOT));
#if __JHEXEN__
updateSaveInfo(&baseSaveInfo, composeGameSavePathForSlot(BASE_SLOT));
#endif
}

/// Given a logical save slot identifier retrieve the assciated game-save info.
Expand All @@ -442,23 +454,20 @@ static saveinfo_t* findSaveInfoForSlot(int slot)
static saveinfo_t invalidInfo = { { "" }, { "" } };
assert(inited);

if(slot == AUTO_SLOT)
{
// On first call - automatically build and populate game-save info.
if(!saveInfo)
buildSaveInfo();
// Retrieve the info for this slot.
return &autoSaveInfo;
}
if(slot >= 0 && slot < NUMSAVESLOTS)
if(!SV_IsValidSlot(slot)) return &invalidInfo;

// On first call - automatically build and populate game-save info.
if(!saveInfo)
{
// On first call - automatically build and populate game-save info.
if(!saveInfo)
buildSaveInfo();
// Retrieve the info for this slot.
return &saveInfo[slot];
buildSaveInfo();
}
return &invalidInfo;

// Retrieve the info for this slot.
if(slot == AUTO_SLOT) return &autoSaveInfo;
#if __JHEXEN__
if(slot == BASE_SLOT) return &baseSaveInfo;
#endif
return &saveInfo[slot];
}

const saveinfo_t* SV_SaveInfoForSlot(int slot)
Expand Down

0 comments on commit 0459a7b

Please sign in to comment.