From 476c98fdfa0d5be4ac703a22997181b950054877 Mon Sep 17 00:00:00 2001 From: RaveYard <29225776+MrRaveYard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:57:35 +0200 Subject: [PATCH] Fix edge case where the lightmap lump surface touches the edge of the atlas page --- src/maploader/maploader.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 2faa66b1d..325bb1a27 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -3116,7 +3116,7 @@ void MapLoader::LoadLightmap(MapData* map) fr.Read(&zdrayUvs[0], numTexCoords * 2 * sizeof(float)); // Load lightmap textures - Level->levelMesh->LMTextureData.Resize(Level->levelMesh->LMTextureCount* Level->levelMesh->LMTextureSize * Level->levelMesh->LMTextureSize * 3); + Level->levelMesh->LMTextureData.Resize(Level->levelMesh->LMTextureCount * Level->levelMesh->LMTextureSize * Level->levelMesh->LMTextureSize * 3); TArray textureData; textureData.Resize((numTexBytes + 1) / 2); @@ -3150,7 +3150,9 @@ void MapLoader::LoadLightmap(MapData* map) int dstPage = realSurface.atlasPageIndex; // Sanity checks - if (srcMinX < 0 || srcMinY < 0 || dstX < 0 || dstY < 0 || srcMaxX >= textureSize || srcMaxY >= textureSize || dstX + srcW >= textureSize || dstY + srcH >= textureSize || srcPage >= numTextures || dstPage >= Level->levelMesh->LMTextureCount) + if (srcMinX < 0 || srcMinY < 0 || srcMaxX > textureSize || srcMaxY > textureSize || + dstX < 0 || dstY < 0 || dstX + srcW > Level->levelMesh->LMTextureSize || dstY + srcH > Level->levelMesh->LMTextureSize || + srcPage >= numTextures || dstPage >= Level->levelMesh->LMTextureCount) { errors = true; if (developer >= 1)