From 26a15d0ccc907516fdb65a68dae7590fd77cb243 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 1 Jun 2016 11:43:56 +0200 Subject: [PATCH] - delete thinkers before starting to restore the savegame data to avoid interference of the old thinkers' Destroy() method with the newly loaded data. Note that even with this change it is still not possible to unarchive any thinker pointers before the thinker list has been loaded as it would create broken lists. --- src/dthinker.cpp | 5 ----- src/g_level.cpp | 1 + src/p_saveg.cpp | 8 ++++++++ src/p_saveg.h | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/dthinker.cpp b/src/dthinker.cpp index 230d0dd41..176df6c18 100644 --- a/src/dthinker.cpp +++ b/src/dthinker.cpp @@ -152,11 +152,6 @@ void DThinker::SerializeAll(FArchive &arc, bool hubLoad) } else { - if (hubLoad) - DestroyMostThinkers(); - else - DestroyAllThinkers(); - // Prevent the constructor from inserting thinkers into a list. bSerialOverride = true; diff --git a/src/g_level.cpp b/src/g_level.cpp index 141932c22..66d4ad422 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1479,6 +1479,7 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad) int i = level.totaltime; Renderer->StartSerialize(arc); + if (arc.IsLoading()) P_DestroyThinkers(hubLoad); arc << level.flags << level.flags2 diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index b6e3b28ca..e64a97fca 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -519,6 +519,14 @@ void P_SerializeThinkers (FArchive &arc, bool hubLoad) DThinker::SerializeAll (arc, hubLoad); } +void P_DestroyThinkers(bool hubLoad) +{ + if (hubLoad) + DThinker::DestroyMostThinkers(); + else + DThinker::DestroyAllThinkers(); +} + //========================================================================== // // ArchiveSounds diff --git a/src/p_saveg.h b/src/p_saveg.h index c6c056004..eb3e4de2b 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -43,6 +43,7 @@ struct PNGHandle; void P_SerializePlayers (FArchive &arc, bool fakeload); void P_SerializeWorldActors(FArchive &arc); void P_SerializeWorld (FArchive &arc); +void P_DestroyThinkers(bool hubLoad); void P_SerializeThinkers (FArchive &arc, bool); void P_SerializePolyobjs (FArchive &arc); void P_SerializeSubsectors(FArchive &arc);