diff --git a/source/common/utility/tarray.h b/source/common/utility/tarray.h index d10c3224f..635f1cc75 100644 --- a/source/common/utility/tarray.h +++ b/source/common/utility/tarray.h @@ -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& other) + TPointer(const TPointer& other) = delete; + /* { DoCopy(other); } + */ TPointer(TPointer&& other) { Ptr = other.Ptr; diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index c32603825..4b8b95e28 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -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() {} diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index 32440c6dc..a7f5017b7 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -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; } } diff --git a/source/core/savegamehelp.h b/source/core/savegamehelp.h index d283a181c..b605f4835 100644 --- a/source/core/savegamehelp.h +++ b/source/core/savegamehelp.h @@ -5,13 +5,9 @@ extern FixedBitArray 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