From 2327107f32a388c90f15614a96955bbc580f7f44 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Apr 2016 15:27:19 +0200 Subject: [PATCH] - fixed: Actors cannot be linked into the world until after all actors and sectors have been deserialized. Two issues: Portal linking requires all skyboxes in the sectors to be present, without them some info is not there when needed. UpdateWaterLevel was called in AActor::Serialize, which operated on the freshly loaded level where lots of things haven't been set up yet and plane heights may be wrong. --- src/actor.h | 1 + src/dthinker.h | 1 + src/g_level.cpp | 7 +++++++ src/p_mobj.cpp | 11 +++++++---- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/actor.h b/src/actor.h index d369e5fa9..9e96ab2c2 100644 --- a/src/actor.h +++ b/src/actor.h @@ -576,6 +576,7 @@ public: ~AActor (); void Serialize (FArchive &arc); + void PostSerialize(); static AActor *StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t allowreplacement, bool SpawningMapThing = false); diff --git a/src/dthinker.h b/src/dthinker.h index 10a53309d..c08ea9d83 100644 --- a/src/dthinker.h +++ b/src/dthinker.h @@ -69,6 +69,7 @@ public: virtual ~DThinker (); virtual void Tick (); virtual void PostBeginPlay (); // Called just before the first tick + virtual void PostSerialize() {} size_t PropagateMark(); void ChangeStatNum (int statnum); diff --git a/src/g_level.cpp b/src/g_level.cpp index 9d4069a9a..fcecb6a85 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1580,6 +1580,13 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad) P_SerializeSounds (arc); if (arc.IsLoading()) { + FThinkerIterator it(RUNTIME_CLASS(DThinker)); + DThinker *th; + while ((th = it.Next())) + { + th->PostSerialize(); + } + for (i = 0; i < numsectors; i++) { P_Recalculate3DFloors(§ors[i]); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 18caa2f3c..81311e777 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -397,8 +397,6 @@ void AActor::Serialize(FArchive &arc) if (arc.IsLoading ()) { - touching_sectorlist = NULL; - LinkToWorld (false, Sector); AddToHash (); SetShade (fillcolor); if (player) @@ -415,11 +413,16 @@ void AActor::Serialize(FArchive &arc) Speed = GetDefault()->Speed; } } - ClearInterpolation(); - UpdateWaterLevel(false); } } +void AActor::PostSerialize() +{ + touching_sectorlist = NULL; + LinkToWorld(false, Sector); + ClearInterpolation(); + UpdateWaterLevel(false); +} AActor::AActor () throw() {