mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
Saves: Sort saves Z-A by filename and internally preserve the names of ones deemed unfit to display
git-svn-id: https://svn.eduke32.com/eduke32@6744 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b437636528
commit
8019d8f6f0
3 changed files with 44 additions and 23 deletions
|
@ -3806,11 +3806,11 @@ static void Menu_ReadSaveGameHeaders()
|
||||||
ReadSaveGameHeaders();
|
ReadSaveGameHeaders();
|
||||||
|
|
||||||
size_t const numloaditems = max(g_nummenusaves, 1), numsaveitems = g_nummenusaves+1;
|
size_t const numloaditems = max(g_nummenusaves, 1), numsaveitems = g_nummenusaves+1;
|
||||||
ME_LOAD = (MenuEntry_t *)realloc(ME_LOAD, g_nummenusaves * sizeof(MenuEntry_t));
|
ME_LOAD = (MenuEntry_t *)Xrealloc(ME_LOAD, g_nummenusaves * sizeof(MenuEntry_t));
|
||||||
MEL_LOAD = (MenuEntry_t **)realloc(MEL_LOAD, numloaditems * sizeof(MenuEntry_t *));
|
MEL_LOAD = (MenuEntry_t **)Xrealloc(MEL_LOAD, numloaditems * sizeof(MenuEntry_t *));
|
||||||
MEO_SAVE = (MenuString_t *)realloc(MEO_SAVE, g_nummenusaves * sizeof(MenuString_t));
|
MEO_SAVE = (MenuString_t *)Xrealloc(MEO_SAVE, g_nummenusaves * sizeof(MenuString_t));
|
||||||
ME_SAVE = (MenuEntry_t *)realloc(ME_SAVE, g_nummenusaves * sizeof(MenuEntry_t));
|
ME_SAVE = (MenuEntry_t *)Xrealloc(ME_SAVE, g_nummenusaves * sizeof(MenuEntry_t));
|
||||||
MEL_SAVE = (MenuEntry_t **)realloc(MEL_SAVE, numsaveitems * sizeof(MenuEntry_t *));
|
MEL_SAVE = (MenuEntry_t **)Xrealloc(MEL_SAVE, numsaveitems * sizeof(MenuEntry_t *));
|
||||||
|
|
||||||
MEL_SAVE[0] = &ME_SAVE_NEW;
|
MEL_SAVE[0] = &ME_SAVE_NEW;
|
||||||
ME_SAVE_NEW.name = s_NewSaveGame;
|
ME_SAVE_NEW.name = s_NewSaveGame;
|
||||||
|
|
|
@ -146,6 +146,9 @@ savebrief_t * g_quickload;
|
||||||
menusave_t * g_menusaves;
|
menusave_t * g_menusaves;
|
||||||
size_t g_nummenusaves;
|
size_t g_nummenusaves;
|
||||||
|
|
||||||
|
static menusave_t * g_internalsaves;
|
||||||
|
static size_t g_numinternalsaves;
|
||||||
|
|
||||||
static void ReadSaveGameHeaders_CACHE1D(CACHE1D_FIND_REC *f)
|
static void ReadSaveGameHeaders_CACHE1D(CACHE1D_FIND_REC *f)
|
||||||
{
|
{
|
||||||
savehead_t h;
|
savehead_t h;
|
||||||
|
@ -157,34 +160,29 @@ static void ReadSaveGameHeaders_CACHE1D(CACHE1D_FIND_REC *f)
|
||||||
if (fil == -1)
|
if (fil == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
menusave_t & msv = g_menusaves[g_nummenusaves];
|
menusave_t & msv = g_internalsaves[g_numinternalsaves];
|
||||||
|
|
||||||
int32_t k = sv_loadheader(fil, 0, &h);
|
int32_t k = sv_loadheader(fil, 0, &h);
|
||||||
if (k)
|
if (k)
|
||||||
{
|
{
|
||||||
// old version, signal to menu code
|
if (k < 0)
|
||||||
if (k > 0)
|
msv.isUnreadable = 1;
|
||||||
msv.isOldVer = 1;
|
msv.isOldVer = 1;
|
||||||
else
|
|
||||||
{
|
|
||||||
kclose(fil);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// else h.savename is all zeros (fatal failure, like wrong header
|
|
||||||
// magic or too short header)
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
msv.isOldVer = 0;
|
msv.isOldVer = 0;
|
||||||
|
|
||||||
msv.isAutoSave = h.isAutoSave();
|
msv.isAutoSave = h.isAutoSave();
|
||||||
|
|
||||||
|
strncpy(msv.brief.path, fn, ARRAY_SIZE(msv.brief.path));
|
||||||
|
++g_numinternalsaves;
|
||||||
|
|
||||||
if (k >= 0 && h.savename[0] != '\0')
|
if (k >= 0 && h.savename[0] != '\0')
|
||||||
{
|
{
|
||||||
memcpy(msv.brief.name, h.savename, ARRAY_SIZE(msv.brief.name));
|
memcpy(msv.brief.name, h.savename, ARRAY_SIZE(msv.brief.name));
|
||||||
strncpy(msv.brief.path, fn, ARRAY_SIZE(msv.brief.path));
|
|
||||||
|
|
||||||
++g_nummenusaves;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
msv.isUnreadable = 1;
|
||||||
|
|
||||||
kclose(fil);
|
kclose(fil);
|
||||||
}
|
}
|
||||||
|
@ -206,12 +204,34 @@ void ReadSaveGameHeaders(void)
|
||||||
|
|
||||||
// potentially overallocating but programmatically simple
|
// potentially overallocating but programmatically simple
|
||||||
size_t const numfiles = countcache1dfind(findfiles_default);
|
size_t const numfiles = countcache1dfind(findfiles_default);
|
||||||
g_menusaves = (menusave_t *)Xrealloc(g_menusaves, sizeof(menusave_t) * numfiles);
|
size_t const internalsavesize = sizeof(menusave_t) * numfiles;
|
||||||
|
g_internalsaves = (menusave_t *)Xrealloc(g_internalsaves, internalsavesize);
|
||||||
|
memset(g_internalsaves, 0, internalsavesize);
|
||||||
|
|
||||||
|
g_numinternalsaves = 0;
|
||||||
|
ReadSaveGameHeaders_CACHE1D(findfiles_default);
|
||||||
|
klistfree(findfiles_default);
|
||||||
|
|
||||||
g_nummenusaves = 0;
|
g_nummenusaves = 0;
|
||||||
ReadSaveGameHeaders_CACHE1D(findfiles_default);
|
for (size_t x = g_numinternalsaves-1; x < g_numinternalsaves; --x)
|
||||||
|
{
|
||||||
klistfree(findfiles_default);
|
menusave_t & msv = g_internalsaves[x];
|
||||||
|
if (!msv.isUnreadable)
|
||||||
|
{
|
||||||
|
++g_nummenusaves;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size_t const menusavesize = sizeof(menusave_t) * g_nummenusaves;
|
||||||
|
g_menusaves = (menusave_t *)Xrealloc(g_menusaves, menusavesize);
|
||||||
|
memset(g_menusaves, 0, menusavesize);
|
||||||
|
for (size_t x = g_numinternalsaves-1, y = 0; x < g_numinternalsaves; --x)
|
||||||
|
{
|
||||||
|
menusave_t & msv = g_internalsaves[x];
|
||||||
|
if (!msv.isUnreadable)
|
||||||
|
{
|
||||||
|
g_menusaves[y++] = msv;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
|
int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
|
||||||
|
|
|
@ -96,6 +96,7 @@ struct menusave_t
|
||||||
{
|
{
|
||||||
savebrief_t brief;
|
savebrief_t brief;
|
||||||
uint8_t isOldVer = 0;
|
uint8_t isOldVer = 0;
|
||||||
|
uint8_t isUnreadable = 0;
|
||||||
uint8_t isAutoSave = 0;
|
uint8_t isAutoSave = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue