mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-18 10:11:11 +00:00
- fixed handling of snapshot buffers.
They get copied around a bit too much, so they cannot have a destructor. They must be explicitly deleted when the snapshot gets removed.
This commit is contained in:
parent
99a3b09a68
commit
7b799be947
4 changed files with 26 additions and 17 deletions
|
@ -1926,7 +1926,11 @@ void G_DoLoadGame ()
|
|||
NextSkill = -1;
|
||||
arc("nextskill", NextSkill);
|
||||
|
||||
//currentSession->Snapshots.Remove(MapName); fixme
|
||||
// Delete all snapshots that were created for the currently active levels.
|
||||
ForAllLevels([](FLevelLocals *Level)
|
||||
{
|
||||
currentSession->RemoveSnapshot(Level->MapName);
|
||||
});
|
||||
|
||||
BackupSaveName = savename;
|
||||
|
||||
|
@ -2234,11 +2238,6 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
|
|||
|
||||
savegameManager.NotifyNewSave (filename, description, okForQuicksave);
|
||||
|
||||
// delete the JSON buffers we created just above. Everything else will
|
||||
// either still be needed or taken care of automatically.
|
||||
//savegame_content[1].Clean();
|
||||
//savegame_content[2].Clean();
|
||||
|
||||
// Check whether the file is ok by trying to open it.
|
||||
FResourceFile *test = FResourceFile::OpenResourceFile(filename, true);
|
||||
if (test != nullptr)
|
||||
|
@ -2252,9 +2251,6 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
|
|||
|
||||
BackupSaveName = filename;
|
||||
|
||||
// We don't need the snapshot any longer.
|
||||
//currentSession->Snapshots.Remove(???);
|
||||
|
||||
insave = false;
|
||||
|
||||
if (cl_waitforsave)
|
||||
|
|
|
@ -901,7 +901,7 @@ void G_DoCompleted ()
|
|||
}
|
||||
else
|
||||
{ // Make sure we don't have a snapshot lying around from before.
|
||||
currentSession->Snapshots.Remove(Level->MapName);
|
||||
currentSession->RemoveSnapshot(Level->MapName);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -929,10 +929,6 @@ void G_DoCompleted ()
|
|||
viewactive = false;
|
||||
automapactive = false;
|
||||
|
||||
// [RH] If you ever get a statistics driver operational, adapt this.
|
||||
// if (statcopy)
|
||||
// memcpy (statcopy, &wminfo, sizeof(wminfo));
|
||||
|
||||
WI_Start (&wminfo);
|
||||
}
|
||||
|
||||
|
@ -1810,7 +1806,7 @@ void G_SnapshotLevel ()
|
|||
ForAllLevels([](FLevelLocals *Level)
|
||||
{
|
||||
// first remove the old snapshot, if it exists.
|
||||
currentSession->Snapshots.Remove(Level->MapName);
|
||||
currentSession->RemoveSnapshot(Level->MapName);
|
||||
|
||||
FSerializer arc;
|
||||
if (arc.OpenWriter(save_formatted))
|
||||
|
@ -1881,7 +1877,7 @@ void G_UnSnapshotLevel (const TArray<FLevelLocals *> &levels, bool hubLoad)
|
|||
arc.Close();
|
||||
}
|
||||
// No reason to keep the snapshot around once the level's been entered.
|
||||
currentSession->Snapshots.Remove(Level->MapName);
|
||||
currentSession->RemoveSnapshot(Level->MapName);
|
||||
// Unlock ACS global strings that were locked when the snapshot was made.
|
||||
Level->Behaviors.UnlockLevelVarStrings(Level->levelnum);
|
||||
}
|
||||
|
|
|
@ -344,8 +344,24 @@ public:
|
|||
}
|
||||
void ClearSnapshots()
|
||||
{
|
||||
decltype(Snapshots)::Iterator it(Snapshots);
|
||||
decltype(Snapshots)::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
pair->Value.Clean();
|
||||
}
|
||||
|
||||
Snapshots.Clear();
|
||||
}
|
||||
void RemoveSnapshot(FName mapname)
|
||||
{
|
||||
auto snapshot = Snapshots.CheckKey(mapname);
|
||||
if (snapshot)
|
||||
{
|
||||
snapshot->Clean();
|
||||
}
|
||||
Snapshots.Remove(mapname);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ struct FCompressedBuffer
|
|||
char *mBuffer;
|
||||
|
||||
bool Decompress(char *destbuffer);
|
||||
~FCompressedBuffer()
|
||||
|
||||
void Clean()
|
||||
{
|
||||
mSize = mCompressedSize = 0;
|
||||
if (mBuffer != nullptr)
|
||||
|
|
Loading…
Reference in a new issue