From e085a8d58aa465cbcb91c839f4ee39b3c8a69ebf Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 27 May 2018 16:14:18 +0300 Subject: [PATCH 1/6] - garbage collect static event handlers on restart Remaining object(s) led to a potential crash on the next garbage collection cycle Assertion failure was triggered during restarting in Debug configuration --- src/d_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_main.cpp b/src/d_main.cpp index 861318c66..ed986beb7 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2730,6 +2730,7 @@ void D_DoomMain (void) ST_Clear(); D_ErrorCleanup (); DThinker::DestroyThinkersInList(STAT_STATIC); + E_Shutdown(false); P_FreeLevelData(); P_FreeExtraLevelData(); From 36779cf88caeb8d72f3a51bd616b809b647d4c22 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 27 May 2018 16:15:05 +0300 Subject: [PATCH 2/6] - restore startup game state on restart At least values of custom server CVARs were not restored because of this https://forum.zdoom.org/viewtopic.php?t=60711 --- src/d_main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/d_main.cpp b/src/d_main.cpp index ed986beb7..668dcf1ce 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2776,6 +2776,8 @@ void D_DoomMain (void) restart++; PClass::bShutdown = false; PClass::bVMOperational = false; + + gamestate = GS_STARTUP; } while (1); } From 0187b0aa5b408f51807acff055a92230f6ee9db6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 28 May 2018 11:51:43 +0300 Subject: [PATCH 3/6] - fixed mirrors and reflections in hardware renderer https://forum.zdoom.org/viewtopic.php?t=60671 --- src/gl/scene/gl_portal.cpp | 9 +++++---- src/gl/scene/gl_scenedrawer.h | 1 - src/hwrenderer/scene/hw_drawinfo.h | 2 ++ src/hwrenderer/scene/hw_renderhacks.cpp | 6 ++++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 25b2ff236..9b86cbbe8 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -606,10 +606,7 @@ void GLSkyboxPortal::DrawContents(FDrawInfo *di) di->SetViewArea(); ClearClipper(di); - int mapsection = R_PointInSubsector(r_viewpoint.Pos)->mapsection; - - di->CurrentMapSections.Zero(); - di->CurrentMapSections.Set(mapsection); + di->UpdateCurrentMapSection(); drawer->DrawScene(di, DM_SKYPORTAL); portal->mFlags &= ~PORTSF_INSKYBOX; @@ -770,6 +767,8 @@ void GLPlaneMirrorPortal::DrawContents(FDrawInfo *di) drawer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); ClearClipper(di); + di->UpdateCurrentMapSection(); + gl_RenderState.SetClipHeight(planez, PlaneMirrorMode < 0 ? -1.f : 1.f); drawer->DrawScene(di, DM_PORTAL); gl_RenderState.SetClipHeight(0.f, 0.f); @@ -944,6 +943,8 @@ void GLMirrorPortal::DrawContents(FDrawInfo *di) angle_t a1 = linedef->v2->GetClipAngle(); di->mClipper->SafeAddClipRange(a1,a2); + di->UpdateCurrentMapSection(); + gl_RenderState.SetClipLine(linedef); gl_RenderState.EnableClipLine(true); drawer->DrawScene(di, DM_PORTAL); diff --git a/src/gl/scene/gl_scenedrawer.h b/src/gl/scene/gl_scenedrawer.h index d075e1418..3396c269c 100644 --- a/src/gl/scene/gl_scenedrawer.h +++ b/src/gl/scene/gl_scenedrawer.h @@ -32,7 +32,6 @@ public: angle_t FrustumAngle(); void SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror); - void SetViewArea(); void SetupView(float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror); void SetViewAngle(DAngle viewangle); void SetProjection(VSMatrix matrix); diff --git a/src/hwrenderer/scene/hw_drawinfo.h b/src/hwrenderer/scene/hw_drawinfo.h index e9db60a09..8bec0df27 100644 --- a/src/hwrenderer/scene/hw_drawinfo.h +++ b/src/hwrenderer/scene/hw_drawinfo.h @@ -175,6 +175,8 @@ public: void PreparePlayerSprites(sector_t * viewsector, area_t in_area); void PrepareTargeterSprites(); + void UpdateCurrentMapSection(); + virtual void DrawWall(GLWall *wall, int pass) = 0; virtual void DrawFlat(GLFlat *flat, int pass, bool trans) = 0; virtual void DrawSprite(GLSprite *sprite, int pass) = 0; diff --git a/src/hwrenderer/scene/hw_renderhacks.cpp b/src/hwrenderer/scene/hw_renderhacks.cpp index 57fef57e0..74c5b3f0e 100644 --- a/src/hwrenderer/scene/hw_renderhacks.cpp +++ b/src/hwrenderer/scene/hw_renderhacks.cpp @@ -86,6 +86,12 @@ void HWDrawInfo::ClearBuffers() mClipPortal = nullptr; } +void HWDrawInfo::UpdateCurrentMapSection() +{ + const int mapsection = R_PointInSubsector(r_viewpoint.Pos)->mapsection; + CurrentMapSections.Set(mapsection); +} + //========================================================================== // // Adds a subsector plane to a sector's render list From a0695cbb488c079012f2d7d2b67473b2642165d0 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 29 May 2018 12:07:45 +0300 Subject: [PATCH 4/6] - fixed blinking frame after saving a game Viewport was not reseted after creation of saved game thumbnail, so one junk frame was rendered right after saving a game https://forum.zdoom.org/viewtopic.php?t=60412 --- src/gl/scene/gl_scene.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index f2e0301fb..91d4e4235 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -739,6 +739,8 @@ void GLSceneDrawer::WriteSavePic (player_t *player, FileWriter *file, int width, GLRenderer->CopyToBackbuffer(&bounds, false); glFlush(); + screen->SetOutputViewport(nullptr); + uint8_t * scr = (uint8_t *)M_Malloc(width * height * 3); glReadPixels(0,0,width, height,GL_RGB,GL_UNSIGNED_BYTE,scr); M_CreatePNG (file, scr + ((height-1) * width * 3), NULL, SS_RGB, width, height, -width * 3, Gamma); From f06ee1049555686f4b8fbe0dae11e2e6ca291b5b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 29 May 2018 12:16:20 +0300 Subject: [PATCH 5/6] - use proper map section for wall mirror portal https://forum.zdoom.org/viewtopic.php?t=60671 --- src/gl/scene/gl_portal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 9b86cbbe8..3f8ede410 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -874,6 +874,8 @@ void GLMirrorPortal::DrawContents(FDrawInfo *di) return; } + di->UpdateCurrentMapSection(); + di->mClipPortal = this; DAngle StartAngle = r_viewpoint.Angles.Yaw; DVector3 StartPos = r_viewpoint.Pos; @@ -943,8 +945,6 @@ void GLMirrorPortal::DrawContents(FDrawInfo *di) angle_t a1 = linedef->v2->GetClipAngle(); di->mClipper->SafeAddClipRange(a1,a2); - di->UpdateCurrentMapSection(); - gl_RenderState.SetClipLine(linedef); gl_RenderState.EnableClipLine(true); drawer->DrawScene(di, DM_PORTAL); From ad343892f318b312b3d9f931b9fbebc978ddae0c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 29 May 2018 19:00:41 +0200 Subject: [PATCH 6/6] - fixed: When deserializing the object list, the array must be nulled before using it so that a premature abort does not end up working on random data. --- src/serializer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/serializer.cpp b/src/serializer.cpp index aa1c9a49e..58d5658d4 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -989,6 +989,11 @@ void FSerializer::ReadObjects(bool hubtravel) { DThinker::bSerialOverride = true; r->mDObjects.Resize(ArraySize()); + for (auto &p : r->mDObjects) + { + p = nullptr; + } + // First iteration: create all the objects but do nothing with them yet. for (unsigned i = 0; i < r->mDObjects.Size(); i++) { @@ -1060,7 +1065,7 @@ void FSerializer::ReadObjects(bool hubtravel) // nuke all objects we created here. for (auto obj : r->mDObjects) { - if (!(obj->ObjectFlags & OF_EuthanizeMe)) obj->Destroy(); + if (obj != nullptr && !(obj->ObjectFlags & OF_EuthanizeMe)) obj->Destroy(); } r->mDObjects.Clear();