diff --git a/src/common/rendering/hwrenderer/data/hw_lightmaptile.h b/src/common/rendering/hwrenderer/data/hw_lightmaptile.h index 7f803f5a8..627b13c51 100644 --- a/src/common/rendering/hwrenderer/data/hw_lightmaptile.h +++ b/src/common/rendering/hwrenderer/data/hw_lightmaptile.h @@ -5,6 +5,9 @@ #include "vectors.h" #include "bounds.h" +#define LIGHTMAP_GLOBAL_SAMPLE_DISTANCE_MIN (int)4 +#define LIGHTMAP_GLOBAL_SAMPLE_DISTANCE_MAX (int)64 + struct LevelMeshSurface; struct LightmapTileBinding diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index eb4e19c0d..3ea84000c 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -2967,7 +2967,7 @@ void MapLoader::InitLevelMesh(MapData* map) if (map->Size(ML_LIGHTMAP)) { // Arbitrary ZDRay limit. This will break lightmap lump loading if not enforced. - Level->LightmapSampleDistance = Level->LightmapSampleDistance < 8 ? 8 : Level->LightmapSampleDistance; + Level->LightmapSampleDistance = std::clamp((int)Level->LightmapSampleDistance, LIGHTMAP_GLOBAL_SAMPLE_DISTANCE_MIN, LIGHTMAP_GLOBAL_SAMPLE_DISTANCE_MAX); if (!Level->lightmaps) // We are unfortunately missing ZDRayInfo { diff --git a/src/maploader/udmf.cpp b/src/maploader/udmf.cpp index f71f60fa6..c813cc4a4 100644 --- a/src/maploader/udmf.cpp +++ b/src/maploader/udmf.cpp @@ -810,14 +810,12 @@ public: break; case NAME_lm_sampledist: CHECK_N(Zd | Zdt) - if (CheckInt(key) >= 0 && CheckInt(key) <= 0xFFFF) + if (CheckInt(key) < LIGHTMAP_GLOBAL_SAMPLE_DISTANCE_MIN || CheckInt(key) > LIGHTMAP_GLOBAL_SAMPLE_DISTANCE_MAX) { - Level->LightmapSampleDistance = CheckInt(key); - } - else - { - DPrintf(DMSG_WARNING, "Can't set the global lm_sampledist to %s\n", key.GetChars()); + DPrintf(DMSG_WARNING, "Current lm_sampledist value, %x, on the ZDRayInfo thing is out of range (min: %i, max: %i)\n", + CheckInt(key), LIGHTMAP_GLOBAL_SAMPLE_DISTANCE_MIN, LIGHTMAP_GLOBAL_SAMPLE_DISTANCE_MAX); } + Level->LightmapSampleDistance = CheckInt(key); break; default: