mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- savegame code cleanup.
This commit is contained in:
parent
b85da221d7
commit
97d8aee2e8
4 changed files with 15 additions and 41 deletions
|
@ -1380,20 +1380,24 @@ public:
|
|||
{
|
||||
Ptr = nullptr;
|
||||
}
|
||||
TPointer(const T& other)
|
||||
TPointer(const T& other) = delete;
|
||||
/*
|
||||
{
|
||||
Alloc();
|
||||
*Ptr = other;
|
||||
}
|
||||
*/
|
||||
TPointer(T&& other)
|
||||
{
|
||||
Alloc();
|
||||
*Ptr = other;
|
||||
}
|
||||
TPointer(const TPointer<T>& other)
|
||||
TPointer(const TPointer<T>& other) = delete;
|
||||
/*
|
||||
{
|
||||
DoCopy(other);
|
||||
}
|
||||
*/
|
||||
TPointer(TPointer<T>&& other)
|
||||
{
|
||||
Ptr = other.Ptr;
|
||||
|
|
|
@ -67,8 +67,6 @@ struct GameInterface
|
|||
virtual bool StartGame(FNewGameStartup& gs) { return false; }
|
||||
virtual FSavegameInfo GetSaveSig() { return { "", 0, 0}; }
|
||||
virtual double SmallFontScale() { return 1; }
|
||||
virtual bool SaveGame() { return true; }
|
||||
virtual bool LoadGame() { return true; }
|
||||
virtual void SerializeGameState(FSerializer& arc) {}
|
||||
virtual void DrawPlayerSprite(const DVector2& origin, bool onteam) {}
|
||||
virtual void QuitToTitle() {}
|
||||
|
|
|
@ -107,19 +107,11 @@ static void SerializeSession(FSerializer& arc)
|
|||
|
||||
//=============================================================================
|
||||
//
|
||||
// This is for keeping my sanity while working with the horrible mess
|
||||
// that is the savegame code in Duke Nukem.
|
||||
// Without handling this in global variables it is a losing proposition
|
||||
// to save custom data along with the regular snapshot. :(
|
||||
// With this the savegame code can mostly pretend to load from and write
|
||||
// to files while really using a composite archive.
|
||||
//
|
||||
// All global non-game dependent state is also saved right here for convenience.
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
bool OpenSaveGameForRead(const char *name)
|
||||
bool ReadSavegame(const char *name)
|
||||
{
|
||||
if (savereader) delete savereader;
|
||||
savereader = FResourceFile::OpenResourceFile(name, true, true);
|
||||
|
@ -180,11 +172,6 @@ FileReader ReadSavegameChunk(const char *name)
|
|||
return lump->NewReader();
|
||||
}
|
||||
|
||||
bool FinishSavegameWrite()
|
||||
{
|
||||
return savewriter.WriteToFile();
|
||||
}
|
||||
|
||||
void FinishSavegameRead()
|
||||
{
|
||||
delete savereader;
|
||||
|
@ -199,7 +186,7 @@ CVAR(Bool, save_formatted, false, 0) // should be set to false once the conversi
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
bool OpenSaveGameForWrite(const char* filename, const char *name)
|
||||
bool WriteSavegame(const char* filename, const char *name)
|
||||
{
|
||||
savewriter.Clear();
|
||||
savewriter.SetFileName(filename);
|
||||
|
@ -262,8 +249,7 @@ bool OpenSaveGameForWrite(const char* filename, const char *name)
|
|||
M_AppendPNGText(picfile, "Title", name);
|
||||
M_AppendPNGText(picfile, "Current Map", lev->labelName);
|
||||
M_FinishPNG(picfile);
|
||||
|
||||
return true;
|
||||
return savewriter.WriteToFile();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -699,16 +685,9 @@ static int nextquicksave = -1;
|
|||
|
||||
void DoLoadGame(const char* name)
|
||||
{
|
||||
if (OpenSaveGameForRead(name))
|
||||
if (ReadSavegame(name))
|
||||
{
|
||||
if (gi->LoadGame())
|
||||
{
|
||||
gameaction = ga_level;
|
||||
}
|
||||
else
|
||||
{
|
||||
I_Error("%s: Failed to load savegame", name);
|
||||
}
|
||||
gameaction = ga_level;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -727,14 +706,11 @@ static int nextquicksave = -1;
|
|||
|
||||
void G_SaveGame(const char *fn, const char *desc, bool ok4q, bool forceq)
|
||||
{
|
||||
if (OpenSaveGameForWrite(fn, desc))
|
||||
if (WriteSavegame(fn, desc))
|
||||
{
|
||||
if (gi->SaveGame() && FinishSavegameWrite())
|
||||
{
|
||||
savegameManager.NotifyNewSave(fn, desc, ok4q, forceq);
|
||||
Printf(PRINT_NOTIFY, "%s\n", GStrings("GAME SAVED"));
|
||||
BackupSaveGame = fn;
|
||||
}
|
||||
savegameManager.NotifyNewSave(fn, desc, ok4q, forceq);
|
||||
Printf(PRINT_NOTIFY, "%s\n", GStrings("GAME SAVED"));
|
||||
BackupSaveGame = fn;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,13 +5,9 @@
|
|||
|
||||
extern FixedBitArray<MAXSPRITES> activeSprites;
|
||||
|
||||
bool OpenSaveGameForWrite(const char *fname, const char *name);
|
||||
bool OpenSaveGameForRead(const char *name);
|
||||
|
||||
FileWriter *WriteSavegameChunk(const char *name);
|
||||
FileReader ReadSavegameChunk(const char *name);
|
||||
|
||||
bool FinishSavegameWrite();
|
||||
void FinishSavegameRead();
|
||||
|
||||
// Savegame utilities
|
||||
|
|
Loading…
Reference in a new issue