mirror of
https://github.com/t-affeldt/climate_api.git
synced 2024-11-15 23:20:23 +01:00
Merge pull request #8 from mazes-80/mazes-tweaks
Performance optimizations
This commit is contained in:
commit
4d0b080dd5
|
@ -1,9 +1,12 @@
|
|||
local GSCYCLE = 0.03 * climate_mod.settings.tick_speed -- only process event loop after this amount of time
|
||||
local GSCYCLE = 0.3 * 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 gs_timer = 0
|
||||
local world_timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
local player_list = minetest.get_connected_players()
|
||||
if #player_list == 0 then return end
|
||||
|
||||
gs_timer = gs_timer + dtime
|
||||
world_timer = world_timer + dtime
|
||||
|
||||
|
@ -26,7 +29,7 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
end
|
||||
|
||||
local current_effects = climate_mod.trigger.get_active_effects()
|
||||
local current_effects = climate_mod.trigger.get_active_effects(player_list)
|
||||
|
||||
for name, effect in pairs(climate_mod.effects) do
|
||||
local cycle = climate_mod.cycles[name].timespan * climate_mod.settings.tick_speed
|
||||
|
|
|
@ -83,20 +83,18 @@ local function get_weather_effects(player, weather_config, env)
|
|||
return effects
|
||||
end
|
||||
|
||||
function trigger.get_active_effects()
|
||||
function trigger.get_active_effects(players)
|
||||
local environments = {}
|
||||
local effects = {}
|
||||
climate_mod.current_weather = {}
|
||||
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
for _, player in ipairs(players) do
|
||||
local pname = player:get_player_name()
|
||||
local hp = player:get_hp()
|
||||
-- skip weather presets for dead players
|
||||
if hp ~= nil and hp > 0 then
|
||||
environments[pname] = trigger.get_player_environment(player)
|
||||
end
|
||||
local env = environments[pname]
|
||||
if env ~= nil then
|
||||
local env = trigger.get_player_environment(player)
|
||||
environments[pname] = env
|
||||
for wname, wconfig in pairs(climate_mod.weathers) do
|
||||
if is_weather_active(player, wname, env) then
|
||||
if climate_mod.current_weather[pname] == nil then
|
||||
|
|
Loading…
Reference in New Issue
Block a user