From 04c29dcf4b3bf0d05a4c9827e9744f30b98d877e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Thu, 7 Aug 2025 17:41:22 -0300 Subject: [PATCH] make sure lights are unlinked, and clear light lists even when loading saves as saves may be from different levels --- src/g_level.cpp | 6 +++--- src/playsim/a_dynlight.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index 80a385422..cdecfdc5a 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -572,6 +572,9 @@ void G_InitNew (const char *mapname, bool bTitleLevel) bool wantFast; unsigned int i; + primaryLevel->lightlists.wall_dlist.Clear(); + primaryLevel->lightlists.flat_dlist.Clear(); + // did we have any level before? if (primaryLevel->info != nullptr) staticEventManager.WorldUnloaded(FString()); // [MK] don't pass the new map, as it's not a level transition @@ -636,9 +639,6 @@ void G_InitNew (const char *mapname, bool bTitleLevel) primaryLevel->totaltime = 0; primaryLevel->spawnindex = 0; - primaryLevel->lightlists.wall_dlist.Clear(); - primaryLevel->lightlists.flat_dlist.Clear(); - if (!multiplayer || !deathmatch) { InitPlayerClasses (); diff --git a/src/playsim/a_dynlight.cpp b/src/playsim/a_dynlight.cpp index e37c14baa..d80a09c96 100644 --- a/src/playsim/a_dynlight.cpp +++ b/src/playsim/a_dynlight.cpp @@ -646,6 +646,7 @@ void FDynamicLight::CollectWithinRadius(const DVector3 &opos, FSection *section, void FDynamicLight::LinkLight() { + UnlinkLight(); if (radius>0) { // passing in radius*radius allows us to do a distance check without any calls to sqrt @@ -664,7 +665,7 @@ void FDynamicLight::LinkLight() // Deletes the link lists // //========================================================================== -void FDynamicLight::UnlinkLight () +void FDynamicLight::UnlinkLight() { for(int i = 0; i < touchlists.wall_tlist.SSize(); i++)