[mcl_weather] Fix crash on saving uninitialized data, https://git.minetest.land/MineClone2/MineClone2/issues/1361

This commit is contained in:
kay27 2021-03-22 17:31:24 +04:00
parent 7fe3217cd0
commit 66a64439c6

View File

@ -38,6 +38,7 @@ mcl_weather.reg_weathers["none"] = {
local storage = minetest.get_mod_storage() local storage = minetest.get_mod_storage()
-- Save weather into mod storage, so it can be loaded after restarting the server -- Save weather into mod storage, so it can be loaded after restarting the server
local save_weather = function() local save_weather = function()
if not mcl_weather.end_time then return end
storage:set_string("mcl_weather_state", mcl_weather.state) storage:set_string("mcl_weather_state", mcl_weather.state)
storage:set_int("mcl_weather_end_time", mcl_weather.end_time) storage:set_int("mcl_weather_end_time", mcl_weather.end_time)
minetest.log("verbose", "[mcl_weather] Weather data saved: state="..mcl_weather.state.." end_time="..mcl_weather.end_time) minetest.log("verbose", "[mcl_weather] Weather data saved: state="..mcl_weather.state.." end_time="..mcl_weather.end_time)