Remove is_connected() and use minetest counterpart

This commit is contained in:
mazes 80 2022-09-16 04:26:26 +02:00
parent a56116e8ab
commit 31462ab08e
2 changed files with 3 additions and 12 deletions

View File

@ -1,15 +1,6 @@
local GSCYCLE = 0.03 * climate_mod.settings.tick_speed -- only process event loop after this amount of time local GSCYCLE = 0.03 * climate_mod.settings.tick_speed -- only process event loop after this amount of time
local WORLD_CYCLE = 30.00 * climate_mod.settings.tick_speed -- only update global environment influences after this amount of time local WORLD_CYCLE = 30.00 * climate_mod.settings.tick_speed -- only update global environment influences after this amount of time
local function is_connected(playername)
local connected = minetest.get_connected_players()
for _, player in ipairs(connected) do
local name = player:get_player_name()
if playername == name then return true end
end
return false
end
local gs_timer = 0 local gs_timer = 0
local world_timer = 0 local world_timer = 0
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
@ -29,7 +20,7 @@ minetest.register_globalstep(function(dtime)
-- skip weather changes for offline players -- skip weather changes for offline players
for effect, data in pairs(previous_effects) do for effect, data in pairs(previous_effects) do
for playername, _ in pairs(data) do for playername, _ in pairs(data) do
if not is_connected(playername) then if not minetest.get_player_by_name(playername) then
previous_effects[effect][playername] = nil previous_effects[effect][playername] = nil
end end
end end