X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flight.cpp;h=d5389b45060a098df3964b228e5d26ffaedbdc40;hb=707c8c1e95d8db2d84909e7957b4dc9138e05599;hp=8196fedffcc820fa58d317f10b364dd2e29da27e;hpb=1f142ec06fc146464822a322fdf39bddb680bfe6;p=minetest.git diff --git a/src/light.cpp b/src/light.cpp index 8196fedff..d5389b450 100644 --- a/src/light.cpp +++ b/src/light.cpp @@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "light.h" +#include #include #include "util/numeric.h" #include "settings.h" @@ -81,9 +82,11 @@ void set_light_table(float gamma) // Strictly speaking, rangelim is not necessary here—if the implementation // is conforming. But we don’t want problems in any case. light_LUT[i] = rangelim((s32)(255.0f * brightness), 0, 255); + // Ensure light brightens with each level - if (i > 1 && light_LUT[i] <= light_LUT[i - 1]) - light_LUT[i] = light_LUT[i - 1] + 1; + if (i > 0 && light_LUT[i] <= light_LUT[i - 1]) { + light_LUT[i] = std::min((u8)254, light_LUT[i - 1]) + 1; + } } }