From cd8213f067a9564af377791903eab17c2cc41036 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 13 May 2016 10:07:01 +0200 Subject: [PATCH] - fixed: The skybox pointer in FSectorPortal must at least be initialized to nullptr when the struct is deserialized, to avoid an access violation if the partially initialized data is used. This can happen when P_SerializeThinkers destroys the original thinkers that were created on map load. - removed the sector loop for deleting skybox references in ASkyViewpoint::Destroy. Since this only refers to the sectorPortals array it is completely redundant as the following code will clear them just as well. --- src/g_shared/a_skies.cpp | 7 ------- src/portal.cpp | 4 ++++ src/portal.h | 2 -- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/g_shared/a_skies.cpp b/src/g_shared/a_skies.cpp index 57fce23fd..6e85bd886 100644 --- a/src/g_shared/a_skies.cpp +++ b/src/g_shared/a_skies.cpp @@ -59,13 +59,6 @@ void ASkyViewpoint::BeginPlay () void ASkyViewpoint::Destroy () { // remove all sector references to ourselves. - for (int i = 0; i < numsectors; i++) - { - if (sectors[i].GetPortal(sector_t::floor)->mSkybox == this) - sectors[i].ClearPortal(sector_t::floor); - if (sectors[i].GetPortal(sector_t::ceiling)->mSkybox == this) - sectors[i].ClearPortal(sector_t::ceiling); - } for (auto &s : sectorPortals) { if (s.mSkybox == this) s.mSkybox = 0; diff --git a/src/portal.cpp b/src/portal.cpp index af98718bf..64a4dd97d 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -231,6 +231,10 @@ FArchive &operator<< (FArchive &arc, FSectorPortal &port) << port.mDestination << port.mDisplacement << port.mPlaneZ; + if (arc.IsLoading()) + { + port.mSkybox = nullptr; + } return arc; } diff --git a/src/portal.h b/src/portal.h index bba674def..a87ae207f 100644 --- a/src/portal.h +++ b/src/portal.h @@ -191,7 +191,6 @@ struct FLinePortal double mSinRot; double mCosRot; portnode_t *render_thinglist; - void *mRenderData; }; extern TArray linePortals; @@ -229,7 +228,6 @@ struct FSectorPortal DVector2 mDisplacement; double mPlaneZ; TObjPtr mSkybox; - void *mRenderData; bool MergeAllowed() const {