- overhaul of savegame path management.

* use a different subfolder for each IWAD's saves.
* do not allow load and save CCMDs to escape the save folder. Absolute paths and '..' are being blocked now.
* unified savegame path and filename generation in one single function. All ad-hoc file name generation was replaced.
* -loadgame will also use the designated savegame folder now.
This commit is contained in:
Christoph Oelckers 2022-10-20 01:11:47 +02:00
commit ff37d710e2
8 changed files with 87 additions and 88 deletions

View file

@ -3021,6 +3021,7 @@ static FILE* D_GetHashFile()
static int D_InitGame(const FIWADInfo* iwad_info, TArray<FString>& allwads, TArray<FString>& pwads)
{
SavegameFolder = iwad_info->Autoname;
gameinfo.gametype = iwad_info->gametype;
gameinfo.flags = iwad_info->flags;
gameinfo.nokeyboardcheats = iwad_info->nokeyboardcheats;
@ -3428,10 +3429,8 @@ static int D_InitGame(const FIWADInfo* iwad_info, TArray<FString>& allwads, TArr
v = Args->CheckValue ("-loadgame");
if (v)
{
FString file(v);
FixPathSeperator (file);
DefaultExtension (file, "." SAVEGAME_EXT);
G_LoadGame (file);
FString file = G_BuildSaveName(v);
G_LoadGame(file);
}
v = Args->CheckValue("-playdemo");
@ -3612,9 +3611,7 @@ static int D_DoomMain_Internal (void)
v = Args->CheckValue("-loadgame");
if (v)
{
FString file(v);
FixPathSeperator(file);
DefaultExtension(file, "." SAVEGAME_EXT);
FString file = G_BuildSaveName(v);
if (!FileExists(file))
{
I_FatalError("Cannot find savegame %s", file.GetChars());