From eea96867c4c1322fc40ae8a066206e2da3920901 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Wed, 18 Sep 2024 10:10:53 +0200 Subject: [PATCH] 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 Co-authored-by: teknomunk Co-committed-by: teknomunk --- mods/ENVIRONMENT/mcl_weather/rain.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_weather/rain.lua b/mods/ENVIRONMENT/mcl_weather/rain.lua index 00dc2f6eb..ed6c2c5fb 100644 --- a/mods/ENVIRONMENT/mcl_weather/rain.lua +++ b/mods/ENVIRONMENT/mcl_weather/rain.lua @@ -60,13 +60,15 @@ end -- set skybox based on time (uses skycolor api) function mcl_weather.rain.set_sky_box() if mcl_weather.state == "rain" then - mcl_weather.skycolor.add_layer( - "weather-pack-rain-sky", - {{r=0, g=0, b=0}, - {r=85, g=86, b=98}, - {r=135, g=135, b=151}, - {r=85, g=86, b=98}, - {r=0, g=0, b=0}}) + if mcl_weather.skycolor.current_layer_name() ~= "weather-pack-rain-sky" then + mcl_weather.skycolor.add_layer( + "weather-pack-rain-sky", + {{r=0, g=0, b=0}, + {r=85, g=86, b=98}, + {r=135, g=135, b=151}, + {r=85, g=86, b=98}, + {r=0, g=0, b=0}}) + end mcl_weather.skycolor.active = true for _, player in pairs(get_connected_players()) do player:set_clouds({color="#5D5D5FE8"})