Saves: Make the save filename counter automatically take the highest number present so as to not fill in gaps (which would make sorting inaccurate)

git-svn-id: https://svn.eduke32.com/eduke32@6747 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2018-03-08 03:55:32 +00:00
parent d04d0128e3
commit 210df6f92d

View file

@ -232,6 +232,24 @@ void ReadSaveGameHeaders(void)
g_menusaves[y++] = msv;
}
}
for (size_t x = g_numinternalsaves-1; x < g_numinternalsaves; --x)
{
char const * const path = g_internalsaves[x].brief.path;
size_t const pathlen = strlen(path);
if (pathlen < 12)
continue;
char const * const fn = path + (pathlen-12);
if (fn[0] == 's' && fn[1] == 'a' && fn[2] == 'v' && fn[3] == 'e' &&
isdigit(fn[4]) && isdigit(fn[5]) && isdigit(fn[6]) && isdigit(fn[7]))
{
char number[5];
memcpy(number, fn+4, 4);
number[4] = '\0';
savecounter.count = atoi(number)+1;
break;
}
}
}
int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
@ -257,7 +275,7 @@ int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
{
if (kdfread((char *)waloff[TILE_LOADSHOT], 320, 200, fil) != 200)
{
OSD_Printf("G_LoadSaveHeaderNew(): failed reading screenshot \"%s\"\n", fn);
OSD_Printf("G_LoadSaveHeaderNew(): failed reading screenshot in \"%s\"\n", fn);
goto corrupt;
}
}