check for existing savegame files ignoring case (#1797)

* check for existing savegame files ignoring case

* variable naming
This commit is contained in:
Fabian Greffrath 2024-07-20 12:53:53 +02:00 committed by GitHub
parent 8649af73c4
commit d98a8476eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2159,14 +2159,39 @@ char* G_SaveGameName(int slot)
char buf[16] = {0}; char buf[16] = {0};
sprintf(buf, "%.7s%d.dsg", savegamename, 10*savepage+slot); sprintf(buf, "%.7s%d.dsg", savegamename, 10*savepage+slot);
return M_StringJoin(basesavegame, DIR_SEPARATOR_S, buf); char *filepath = M_StringJoin(basesavegame, DIR_SEPARATOR_S, buf);
char *existing = M_FileCaseExists(filepath);
if (existing)
{
free(filepath);
return existing;
}
else
{
char *filename = (char *)M_BaseName(filepath);
M_StringToLower(filename);
return filepath;
}
} }
char* G_MBFSaveGameName(int slot) char* G_MBFSaveGameName(int slot)
{ {
char buf[16] = {0}; char buf[16] = {0};
sprintf(buf, "MBFSAV%d.dsg", 10*savepage+slot); sprintf(buf, "MBFSAV%d.dsg", 10*savepage+slot);
return M_StringJoin(basesavegame, DIR_SEPARATOR_S, buf);
char *filepath = M_StringJoin(basesavegame, DIR_SEPARATOR_S, buf);
char *existing = M_FileCaseExists(filepath);
if (existing)
{
free(filepath);
return existing;
}
else
{
return filepath;
}
} }
// killough 12/98: // killough 12/98: