Don't add rain skycolor layer if the current layer is already the rain skycolor (#4648)

Fixes #4647 Rain makes the sky black until restart. This also fixes a memory leak caused by rain adding a color layer every time step.

Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4648
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: teknomunk <teknomunk@protonmail.com>
Co-committed-by: teknomunk <teknomunk@protonmail.com>
This commit is contained in:
teknomunk 2024-09-18 10:10:53 +02:00 committed by the-real-herowl
parent cd2ee49591
commit eea96867c4

View file

@ -60,13 +60,15 @@ end
-- set skybox based on time (uses skycolor api) -- set skybox based on time (uses skycolor api)
function mcl_weather.rain.set_sky_box() function mcl_weather.rain.set_sky_box()
if mcl_weather.state == "rain" then if mcl_weather.state == "rain" then
mcl_weather.skycolor.add_layer( if mcl_weather.skycolor.current_layer_name() ~= "weather-pack-rain-sky" then
"weather-pack-rain-sky", mcl_weather.skycolor.add_layer(
{{r=0, g=0, b=0}, "weather-pack-rain-sky",
{r=85, g=86, b=98}, {{r=0, g=0, b=0},
{r=135, g=135, b=151}, {r=85, g=86, b=98},
{r=85, g=86, b=98}, {r=135, g=135, b=151},
{r=0, g=0, b=0}}) {r=85, g=86, b=98},
{r=0, g=0, b=0}})
end
mcl_weather.skycolor.active = true mcl_weather.skycolor.active = true
for _, player in pairs(get_connected_players()) do for _, player in pairs(get_connected_players()) do
player:set_clouds({color="#5D5D5FE8"}) player:set_clouds({color="#5D5D5FE8"})