diff --git a/src/playsim/dthinker.cpp b/src/playsim/dthinker.cpp index 013ea0829..32722f91c 100644 --- a/src/playsim/dthinker.cpp +++ b/src/playsim/dthinker.cpp @@ -43,7 +43,8 @@ #include "g_levellocals.h" #include "a_dynlight.h" #include "v_video.h" - +#include "g_cvars.h" +#include "d_main.h" static int ThinkCount; static cycle_t ThinkCycles; @@ -107,6 +108,18 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) ThinkCycles.Clock(); + bool dolights; + if ((gl_lights && vid_rendermode == 4) || (r_dynlights && vid_rendermode != 4)) + { + dolights = Level->lights || (Level->flags3 & LEVEL3_LIGHTCREATED); + } + else + { + dolights = false; + } + Level->flags3 &= ~LEVEL3_LIGHTCREATED; + + auto recreateLights = [=]() { auto it = Level->GetThinkerIterator(); @@ -144,9 +157,8 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) } } while (count != 0); - if (Level->lights || (Level->flags3 & LEVEL3_LIGHTCREATED)) + if (dolights) { - Level->flags3 &= ~LEVEL3_LIGHTCREATED; recreateLights(); for (auto light = Level->lights; light;) { @@ -175,9 +187,8 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) } } while (count != 0); - if (Level->lights || (Level->flags3 & LEVEL3_LIGHTCREATED)) + if (dolights) { - Level->flags3 &= ~LEVEL3_LIGHTCREATED; recreateLights(); // Also profile the internal dynamic lights, even though they are not implemented as thinkers. auto &prof = Profiles[NAME_InternalDynamicLight];