mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
Better bad save checking
- Move invalid save condition checks from save CCMD into G_SaveGame(). - Add a gamestate != GS_LEVEL check to G_DoSaveGame().
This commit is contained in:
parent
c7842a8de8
commit
5d65b10aec
2 changed files with 20 additions and 20 deletions
|
@ -813,21 +813,6 @@ CCMD (save)
|
|||
Printf ("usage: save <filename> [description]\n");
|
||||
return;
|
||||
}
|
||||
if (!usergame)
|
||||
{
|
||||
Printf ("not in a saveable game\n");
|
||||
return;
|
||||
}
|
||||
if (gamestate != GS_LEVEL)
|
||||
{
|
||||
Printf ("not in a level\n");
|
||||
return;
|
||||
}
|
||||
if(players[consoleplayer].health <= 0 && !multiplayer)
|
||||
{
|
||||
Printf ("player is dead in a single-player game\n");
|
||||
return;
|
||||
}
|
||||
FString fname = argv[1];
|
||||
DefaultExtension (fname, ".zds");
|
||||
G_SaveGame (fname, argv.argc() > 2 ? argv[2] : argv[1]);
|
||||
|
|
|
@ -1983,10 +1983,25 @@ void G_SaveGame (const char *filename, const char *description)
|
|||
Printf ("A game save is still pending.\n");
|
||||
return;
|
||||
}
|
||||
savegamefile = filename;
|
||||
strncpy (savedescription, description, sizeof(savedescription)-1);
|
||||
savedescription[sizeof(savedescription)-1] = '\0';
|
||||
sendsave = true;
|
||||
else if (!usergame)
|
||||
{
|
||||
Printf ("not in a saveable game\n");
|
||||
}
|
||||
else if (gamestate != GS_LEVEL)
|
||||
{
|
||||
Printf ("not in a level\n");
|
||||
}
|
||||
else if (players[consoleplayer].health <= 0 && !multiplayer)
|
||||
{
|
||||
Printf ("player is dead in a single-player game\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
savegamefile = filename;
|
||||
strncpy (savedescription, description, sizeof(savedescription)-1);
|
||||
savedescription[sizeof(savedescription)-1] = '\0';
|
||||
sendsave = true;
|
||||
}
|
||||
}
|
||||
|
||||
FString G_BuildSaveName (const char *prefix, int slot)
|
||||
|
@ -2138,7 +2153,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
|
|||
|
||||
// Do not even try, if we're not in a level. (Can happen after
|
||||
// a demo finishes playback.)
|
||||
if (lines == NULL || sectors == NULL)
|
||||
if (lines == NULL || sectors == NULL || gamestate != GS_LEVEL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue