Merge pull request #899 from khutchins/master
Adds option to use a quicksave rotation
This commit is contained in:
commit
c577f1d743
6 changed files with 58 additions and 9 deletions
|
|
@ -94,8 +94,9 @@ void G_DoPlayDemo (void);
|
|||
void G_DoCompleted (void);
|
||||
void G_DoVictory (void);
|
||||
void G_DoWorldDone (void);
|
||||
void G_DoSaveGame (bool okForQuicksave, FString filename, const char *description);
|
||||
void G_DoSaveGame (bool okForQuicksave, bool forceQuicksave, FString filename, const char *description);
|
||||
void G_DoAutoSave ();
|
||||
void G_DoQuickSave ();
|
||||
|
||||
void STAT_Serialize(FSerializer &file);
|
||||
bool WriteZip(const char *filename, TArray<FString> &filenames, TArray<FCompressedBuffer> &content);
|
||||
|
|
@ -1058,7 +1059,7 @@ void G_Ticker ()
|
|||
G_DoLoadGame ();
|
||||
break;
|
||||
case ga_savegame:
|
||||
G_DoSaveGame (true, savegamefile, savedescription);
|
||||
G_DoSaveGame (true, false, savegamefile, savedescription);
|
||||
gameaction = ga_nothing;
|
||||
savegamefile = "";
|
||||
savedescription = "";
|
||||
|
|
@ -2027,6 +2028,14 @@ CUSTOM_CVAR (Int, autosavecount, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
if (self < 0)
|
||||
self = 0;
|
||||
}
|
||||
CVAR (Int, quicksavenum, -1, CVAR_NOSET|CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
static int lastquicksave = -1;
|
||||
CVAR (Bool, quicksaverotation, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CUSTOM_CVAR (Int, quicksaverotationcount, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 1)
|
||||
self = 1;
|
||||
}
|
||||
|
||||
void G_DoAutoSave ()
|
||||
{
|
||||
|
|
@ -2060,7 +2069,35 @@ void G_DoAutoSave ()
|
|||
|
||||
readableTime = myasctime ();
|
||||
description.Format("Autosave %s", readableTime);
|
||||
G_DoSaveGame (false, file, description);
|
||||
G_DoSaveGame (false, false, file, description);
|
||||
}
|
||||
|
||||
void G_DoQuickSave ()
|
||||
{
|
||||
FString description;
|
||||
FString file;
|
||||
// Keeps a rotating set of quicksaves
|
||||
UCVarValue num;
|
||||
const char *readableTime;
|
||||
int count = quicksaverotationcount != 0 ? quicksaverotationcount : 1;
|
||||
|
||||
if (quicksavenum < 0)
|
||||
{
|
||||
lastquicksave = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastquicksave = (quicksavenum + 1) % count;
|
||||
}
|
||||
|
||||
num.Int = lastquicksave;
|
||||
quicksavenum.ForceSet (num, CVAR_Int);
|
||||
|
||||
file = G_BuildSaveName ("quick", lastquicksave);
|
||||
|
||||
readableTime = myasctime ();
|
||||
description.Format("Quicksave %s", readableTime);
|
||||
G_DoSaveGame (true, true, file, description);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2165,7 +2202,7 @@ static void PutSavePic (FileWriter *file, int width, int height)
|
|||
}
|
||||
}
|
||||
|
||||
void G_DoSaveGame (bool okForQuicksave, FString filename, const char *description)
|
||||
void G_DoSaveGame (bool okForQuicksave, bool forceQuicksave, FString filename, const char *description)
|
||||
{
|
||||
TArray<FCompressedBuffer> savegame_content;
|
||||
TArray<FString> savegame_filenames;
|
||||
|
|
@ -2281,7 +2318,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
|
|||
|
||||
WriteZip(filename, savegame_filenames, savegame_content);
|
||||
|
||||
savegameManager.NotifyNewSave (filename, description, okForQuicksave);
|
||||
savegameManager.NotifyNewSave (filename, description, okForQuicksave, forceQuicksave);
|
||||
|
||||
// delete the JSON buffers we created just above. Everything else will
|
||||
// either still be needed or taken care of automatically.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue