- some reshuffling of save data so that the actors won't get restored before the sectors.

Note that this required splitting P_SerializeWorld, because sector_t and FSectorPortal contain some actor pointers, for which the same rule applies: Portal linking can only be done after all sectors have been read, meaning it cannot be done along with the rest of the data in these structures.

Obviously such a change breaks savegame compatibility so the min. savegame version had to be increased again.
This commit is contained in:
Christoph Oelckers 2016-04-20 19:42:00 +02:00
parent 082042818b
commit e5dc92f998
8 changed files with 29 additions and 26 deletions

View file

@ -576,7 +576,6 @@ public:
~AActor (); ~AActor ();
void Serialize (FArchive &arc); void Serialize (FArchive &arc);
void PostSerialize();
static AActor *StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t allowreplacement, bool SpawningMapThing = false); static AActor *StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t allowreplacement, bool SpawningMapThing = false);

View file

@ -69,7 +69,6 @@ public:
virtual ~DThinker (); virtual ~DThinker ();
virtual void Tick (); virtual void Tick ();
virtual void PostBeginPlay (); // Called just before the first tick virtual void PostBeginPlay (); // Called just before the first tick
virtual void PostSerialize() {}
size_t PropagateMark(); size_t PropagateMark();
void ChangeStatNum (int statnum); void ChangeStatNum (int statnum);

View file

@ -1531,8 +1531,9 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad)
FBehavior::StaticSerializeModuleStates (arc); FBehavior::StaticSerializeModuleStates (arc);
if (arc.IsLoading()) interpolator.ClearInterpolations(); if (arc.IsLoading()) interpolator.ClearInterpolations();
P_SerializeWorld(arc);
P_SerializeThinkers (arc, hubLoad); P_SerializeThinkers (arc, hubLoad);
P_SerializeWorld (arc); P_SerializeWorldActors(arc); // serializing actor pointers in the world data must be done after SerializeWorld has restored the entire sector state, otherwise LinkToWorld may fail.
P_SerializePolyobjs (arc); P_SerializePolyobjs (arc);
P_SerializeSubsectors(arc); P_SerializeSubsectors(arc);
StatusBar->Serialize (arc); StatusBar->Serialize (arc);
@ -1579,13 +1580,6 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad)
P_SerializeSounds (arc); P_SerializeSounds (arc);
if (arc.IsLoading()) if (arc.IsLoading())
{ {
FThinkerIterator it(RUNTIME_CLASS(DThinker));
DThinker *th;
while ((th = it.Next()))
{
th->PostSerialize();
}
for (i = 0; i < numsectors; i++) for (i = 0; i < numsectors; i++)
{ {
P_Recalculate3DFloors(&sectors[i]); P_Recalculate3DFloors(&sectors[i]);

View file

@ -397,6 +397,9 @@ void AActor::Serialize(FArchive &arc)
if (arc.IsLoading ()) if (arc.IsLoading ())
{ {
touching_sectorlist = NULL;
LinkToWorld(false, Sector);
AddToHash (); AddToHash ();
SetShade (fillcolor); SetShade (fillcolor);
if (player) if (player)
@ -413,15 +416,9 @@ void AActor::Serialize(FArchive &arc)
Speed = GetDefault()->Speed; Speed = GetDefault()->Speed;
} }
} }
}
}
void AActor::PostSerialize()
{
touching_sectorlist = NULL;
LinkToWorld(false, Sector);
ClearInterpolation(); ClearInterpolation();
UpdateWaterLevel(false); UpdateWaterLevel(false);
}
} }
AActor::AActor () throw() AActor::AActor () throw()

View file

@ -363,9 +363,7 @@ void P_SerializeWorld (FArchive &arc)
arc << sec->damageamount; arc << sec->damageamount;
arc << sec->damageinterval arc << sec->damageinterval
<< sec->leakydamage << sec->leakydamage
<< sec->damagetype; << sec->damagetype
arc << sec->SoundTarget
<< sec->SecActTarget
<< sec->sky << sec->sky
<< sec->MoreFlags << sec->MoreFlags
<< sec->Flags << sec->Flags
@ -453,6 +451,22 @@ void P_SerializeWorld (FArchive &arc)
P_CollectLinkedPortals(); P_CollectLinkedPortals();
} }
void P_SerializeWorldActors(FArchive &arc)
{
int i, j;
sector_t *sec;
for (i = 0, sec = sectors; i < numsectors; i++, sec++)
{
arc << sec->SoundTarget
<< sec->SecActTarget;
}
for (auto &s : sectorPortals)
{
arc << s.mSkybox;
}
}
void extsector_t::Serialize(FArchive &arc) void extsector_t::Serialize(FArchive &arc)
{ {
arc << FakeFloor.Sectors arc << FakeFloor.Sectors

View file

@ -41,6 +41,7 @@ struct PNGHandle;
// These are the load / save game routines. // These are the load / save game routines.
// Also see farchive.(h|cpp) // Also see farchive.(h|cpp)
void P_SerializePlayers (FArchive &arc, bool fakeload); void P_SerializePlayers (FArchive &arc, bool fakeload);
void P_SerializeWorldActors(FArchive &arc);
void P_SerializeWorld (FArchive &arc); void P_SerializeWorld (FArchive &arc);
void P_SerializeThinkers (FArchive &arc, bool); void P_SerializeThinkers (FArchive &arc, bool);
void P_SerializePolyobjs (FArchive &arc); void P_SerializePolyobjs (FArchive &arc);

View file

@ -230,8 +230,7 @@ FArchive &operator<< (FArchive &arc, FSectorPortal &port)
<< port.mOrigin << port.mOrigin
<< port.mDestination << port.mDestination
<< port.mDisplacement << port.mDisplacement
<< port.mPlaneZ << port.mPlaneZ;
<< port.mSkybox;
return arc; return arc;
} }

View file

@ -72,11 +72,11 @@ const char *GetVersionString();
// SAVESIG should match SAVEVER. // SAVESIG should match SAVEVER.
// MINSAVEVER is the minimum level snapshot version that can be loaded. // MINSAVEVER is the minimum level snapshot version that can be loaded.
#define MINSAVEVER 4539 #define MINSAVEVER 4540
// Use 4500 as the base git save version, since it's higher than the // Use 4500 as the base git save version, since it's higher than the
// SVN revision ever got. // SVN revision ever got.
#define SAVEVER 4539 #define SAVEVER 4540
#define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY2(x) #x
#define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x)