From c73b71807b53a9bfe1037fd45c1e02f0b91a0ed3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 14 Apr 2017 22:06:29 +0200 Subject: [PATCH] - fixed: During hub travel, static thinkers may not be deserialized. Since they are static, the version that got carried over from the last level will still be there and the more current version. --- src/dthinker.cpp | 56 ++++++++++++++++++++++++++---------------------- src/p_saveg.cpp | 2 +- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/dthinker.cpp b/src/dthinker.cpp index d68939665..5e5360651 100644 --- a/src/dthinker.cpp +++ b/src/dthinker.cpp @@ -179,37 +179,41 @@ void DThinker::SerializeThinkers(FSerializer &arc, bool hubLoad) { for (i = 0; i <= MAX_STATNUM; i++) { + if (arc.BeginArray(nullptr)) { - int size = arc.ArraySize(); - for (int j = 0; j < size; j++) + if (!hubLoad || i != STAT_STATIC) // do not load static thinkers in a hub transition because they'd just duplicate the active ones. { - DThinker *thinker = nullptr; - arc(nullptr, thinker); - if (thinker != nullptr) + int size = arc.ArraySize(); + for (int j = 0; j < size; j++) { - // This may be a player stored in their ancillary list. Remove - // them first before inserting them into the new list. - if (thinker->NextThinker != nullptr) + DThinker *thinker = nullptr; + arc(nullptr, thinker); + if (thinker != nullptr) { - thinker->Remove(); - } - // Thinkers with the OF_JustSpawned flag set go in the FreshThinkers - // list. Anything else goes in the regular Thinkers list. - if (thinker->ObjectFlags & OF_EuthanizeMe) - { - // This thinker was destroyed during the loading process. Do - // not link it into any list. - } - else if (thinker->ObjectFlags & OF_JustSpawned) - { - FreshThinkers[i].AddTail(thinker); - thinker->PostSerialize(); - } - else - { - Thinkers[i].AddTail(thinker); - thinker->PostSerialize(); + // This may be a player stored in their ancillary list. Remove + // them first before inserting them into the new list. + if (thinker->NextThinker != nullptr) + { + thinker->Remove(); + } + // Thinkers with the OF_JustSpawned flag set go in the FreshThinkers + // list. Anything else goes in the regular Thinkers list. + if (thinker->ObjectFlags & OF_EuthanizeMe) + { + // This thinker was destroyed during the loading process. Do + // not link it into any list. + } + else if (thinker->ObjectFlags & OF_JustSpawned) + { + FreshThinkers[i].AddTail(thinker); + thinker->PostSerialize(); + } + else + { + Thinkers[i].AddTail(thinker); + thinker->PostSerialize(); + } } } } diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index b20e9af09..6c8d29973 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -996,7 +996,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload) // [ZZ] serialize events E_SerializeEvents(arc); - DThinker::SerializeThinkers(arc, !hubload); + DThinker::SerializeThinkers(arc, hubload); arc.Array("polyobjs", polyobjs, po_NumPolyobjs); SerializeSubsectors(arc, "subsectors"); StatusBar->SerializeMessages(arc);