diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 16b97e5e2..fb553d984 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -57,11 +57,12 @@ #include "doom_aabbtree.h" #include "doom_levelmesh.h" #include "p_visualthinker.h" +#include struct FGlobalDLightLists { - TMap> flat_dlist; - TMap> wall_dlist; + TMap>> flat_dlist; + TMap>> wall_dlist; }; //============================================================================ diff --git a/src/playsim/a_dynlight.cpp b/src/playsim/a_dynlight.cpp index cd374e334..37cc4cb22 100644 --- a/src/playsim/a_dynlight.cpp +++ b/src/playsim/a_dynlight.cpp @@ -458,9 +458,9 @@ void FDynamicLight::AddLightNode(FSection *section, side_t *sidedef) node->lightsource = this; node->targ = section; - TMap u; + TMap> u; u.TryEmplace(this, node); - Level->lightlists.flat_dlist.TryEmplace(section, u); + Level->lightlists.flat_dlist.TryEmplace(section, std::move(u)); updateFlatTList(section); } } @@ -485,9 +485,9 @@ void FDynamicLight::AddLightNode(FSection *section, side_t *sidedef) node->lightsource = this; node->targ = sidedef; - TMap u; + TMap> u; u.TryEmplace(this, node); - Level->lightlists.wall_dlist.TryEmplace(sidedef, u); + Level->lightlists.wall_dlist.TryEmplace(sidedef, std::move(u)); updateWallTList(sidedef); } } @@ -696,12 +696,7 @@ void FDynamicLight::UnlinkLight () auto wallLightList = Level->lightlists.wall_dlist.CheckKey(sidedef); if (wallLightList) { - auto light = *wallLightList->CheckKey(this); - if (light) - { - delete light; - wallLightList->Remove(this); - } + wallLightList->Remove(this); } } @@ -715,12 +710,7 @@ void FDynamicLight::UnlinkLight () auto flatLightList = Level->lightlists.flat_dlist.CheckKey(sec); if (flatLightList) { - auto light = *flatLightList->CheckKey(this); - if (light) - { - delete light; - flatLightList->Remove(this); - } + flatLightList->Remove(this); } } diff --git a/src/rendering/hwrenderer/scene/hw_flats.cpp b/src/rendering/hwrenderer/scene/hw_flats.cpp index 2e5cf86ae..3d1839c85 100644 --- a/src/rendering/hwrenderer/scene/hw_flats.cpp +++ b/src/rendering/hwrenderer/scene/hw_flats.cpp @@ -163,11 +163,11 @@ void HWFlat::SetupLights(HWDrawInfo *di, FDynLightData &lightdata, int portalgro if (flatLightList) { - TMap::Iterator it(*flatLightList); - TMap::Pair *pair; + TMap>::Iterator it(*flatLightList); + TMap>::Pair *pair; while (it.NextPair(pair)) { - auto node = pair->Value; + auto node = pair->Value.get(); if (!node) continue; FDynamicLight * light = node->lightsource; diff --git a/src/rendering/hwrenderer/scene/hw_renderhacks.cpp b/src/rendering/hwrenderer/scene/hw_renderhacks.cpp index 540923721..8aa077294 100644 --- a/src/rendering/hwrenderer/scene/hw_renderhacks.cpp +++ b/src/rendering/hwrenderer/scene/hw_renderhacks.cpp @@ -121,11 +121,11 @@ int HWDrawInfo::SetupLightsForOtherPlane(subsector_t * sub, FDynLightData &light if (flatLightList) { - TMap::Iterator it(*flatLightList); - TMap::Pair *pair; + TMap>::Iterator it(*flatLightList); + TMap>::Pair *pair; while (it.NextPair(pair)) { - auto node = pair->Value; + auto node = pair->Value.get(); if (!node) continue; FDynamicLight * light = node->lightsource; diff --git a/src/rendering/hwrenderer/scene/hw_spritelight.cpp b/src/rendering/hwrenderer/scene/hw_spritelight.cpp index 63bbf6268..0310d1008 100644 --- a/src/rendering/hwrenderer/scene/hw_spritelight.cpp +++ b/src/rendering/hwrenderer/scene/hw_spritelight.cpp @@ -128,11 +128,11 @@ void HWDrawInfo::GetDynSpriteLight(AActor *self, float x, float y, float z, FSec if (flatLightList) { - TMap::Iterator it(*flatLightList); - TMap::Pair *pair; + TMap>::Iterator it(*flatLightList); + TMap>::Pair *pair; while (it.NextPair(pair)) { - auto node = pair->Value; + auto node = pair->Value.get(); if (!node) continue; light=node->lightsource; @@ -253,11 +253,11 @@ void hw_GetDynModelLight(AActor *self, FDynLightData &modellightdata) auto flatLightList = self->Level->lightlists.flat_dlist.CheckKey(subsector->section); if (flatLightList) { - TMap::Iterator it(*flatLightList); - TMap::Pair *pair; + TMap>::Iterator it(*flatLightList); + TMap>::Pair *pair; while (it.NextPair(pair)) { // check all lights touching a subsector - auto node = pair->Value; + auto node = pair->Value.get(); if (!node) continue; FDynamicLight *light = node->lightsource; if (light->ShouldLightActor(self)) diff --git a/src/rendering/hwrenderer/scene/hw_walls.cpp b/src/rendering/hwrenderer/scene/hw_walls.cpp index 3c0d3e861..557004f53 100644 --- a/src/rendering/hwrenderer/scene/hw_walls.cpp +++ b/src/rendering/hwrenderer/scene/hw_walls.cpp @@ -431,11 +431,11 @@ void HWWall::SetupLights(HWDrawInfo*di, FDynLightData &lightdata) if (flatLightList) { - TMap::Iterator it(*flatLightList); - TMap::Pair *pair; + TMap>::Iterator it(*flatLightList); + TMap>::Pair *pair; while (it.NextPair(pair)) { - auto node = pair->Value; + auto node = pair->Value.get(); if (!node) continue; if (node->lightsource->IsActive() && !node->lightsource->DontLightMap()) @@ -496,11 +496,11 @@ void HWWall::SetupLights(HWDrawInfo*di, FDynLightData &lightdata) if (wallLightList) { - TMap::Iterator it(*wallLightList); - TMap::Pair *pair; + TMap>::Iterator it(*wallLightList); + TMap>::Pair *pair; while (it.NextPair(pair)) { - auto node = pair->Value; + auto node = pair->Value.get(); if (!node) continue; if (node->lightsource->IsActive() && !node->lightsource->DontLightMap()) diff --git a/src/rendering/swrenderer/line/r_walldraw.cpp b/src/rendering/swrenderer/line/r_walldraw.cpp index f49bc8e7b..6f12b13fb 100644 --- a/src/rendering/swrenderer/line/r_walldraw.cpp +++ b/src/rendering/swrenderer/line/r_walldraw.cpp @@ -227,11 +227,11 @@ namespace swrenderer auto wallLightList = Level->lightlists.wall_dlist.CheckKey(curline->sidedef); if (wallLightList) { - TMap::Iterator it(*wallLightList); - TMap::Pair *pair; + TMap>::Iterator it(*wallLightList); + TMap>::Pair *pair; while (it.NextPair(pair)) { - auto node = pair->Value; + auto node = pair->Value.get(); if (!node) continue; if (node->lightsource->IsActive()) diff --git a/src/rendering/swrenderer/plane/r_visibleplane.cpp b/src/rendering/swrenderer/plane/r_visibleplane.cpp index 282fc25ee..c7d327191 100644 --- a/src/rendering/swrenderer/plane/r_visibleplane.cpp +++ b/src/rendering/swrenderer/plane/r_visibleplane.cpp @@ -79,11 +79,11 @@ namespace swrenderer auto flatLightList = Level->lightlists.flat_dlist.CheckKey(sec); if (flatLightList) { - TMap::Iterator it(*flatLightList); - TMap::Pair *pair; + TMap>::Iterator it(*flatLightList); + TMap>::Pair *pair; while (it.NextPair(pair)) { - auto node = pair->Value; + auto node = pair->Value.get(); if (!node) continue; if (node->lightsource->IsActive() && (height.PointOnSide(node->lightsource->Pos) > 0)) diff --git a/src/rendering/swrenderer/things/r_sprite.cpp b/src/rendering/swrenderer/things/r_sprite.cpp index ff1d81bea..102dc429e 100644 --- a/src/rendering/swrenderer/things/r_sprite.cpp +++ b/src/rendering/swrenderer/things/r_sprite.cpp @@ -212,11 +212,11 @@ namespace swrenderer auto flatLightList = Level->lightlists.flat_dlist.CheckKey(vis->section); if (flatLightList) { - TMap::Iterator it(*flatLightList); - TMap::Pair *pair; + TMap>::Iterator it(*flatLightList); + TMap>::Pair *pair; while (it.NextPair(pair)) { - auto node = pair->Value; + auto node = pair->Value.get(); if (!node) continue; FDynamicLight *light = node->lightsource;