mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-02-05 06:30:19 +01:00
[pipeworks] Remove one call to register_globalstep
for #179
This commit is contained in:
parent
9d7ea82280
commit
e538a7a152
@ -29,7 +29,7 @@ local function read_entities()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function write_entities()
|
local function write_entities()
|
||||||
for _, entity in pairs(luaentity.entities or {}) do
|
for _, entity in pairs(luaentity.entities or {}) do
|
||||||
setmetatable(entity, nil)
|
setmetatable(entity, nil)
|
||||||
for _, attached in pairs(entity._attached_entities) do
|
for _, attached in pairs(entity._attached_entities) do
|
||||||
if attached.entity then
|
if attached.entity then
|
||||||
@ -54,30 +54,29 @@ end
|
|||||||
local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
|
local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
|
||||||
local handle_active_blocks_step = 2
|
local handle_active_blocks_step = 2
|
||||||
local handle_active_blocks_timer = 0
|
local handle_active_blocks_timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
local function active_blocks_step()
|
||||||
handle_active_blocks_timer = handle_active_blocks_timer + dtime
|
local active_block_range = tonumber(minetest.setting_get("active_block_range")) or 2
|
||||||
if handle_active_blocks_timer >= handle_active_blocks_step then
|
local new_active_blocks = {}
|
||||||
handle_active_blocks_timer = handle_active_blocks_timer - handle_active_blocks_step
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
local active_block_range = tonumber(minetest.setting_get("active_block_range")) or 2
|
local blockpos = get_blockpos(player:getpos())
|
||||||
local new_active_blocks = {}
|
local minp = vector.subtract(blockpos, active_block_range)
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
local maxp = vector.add(blockpos, active_block_range)
|
||||||
local blockpos = get_blockpos(player:getpos())
|
|
||||||
local minp = vector.subtract(blockpos, active_block_range)
|
|
||||||
local maxp = vector.add(blockpos, active_block_range)
|
|
||||||
|
|
||||||
for x = minp.x, maxp.x do
|
for x = minp.x, maxp.x do
|
||||||
for y = minp.y, maxp.y do
|
for y = minp.y, maxp.y do
|
||||||
for z = minp.z, maxp.z do
|
for z = minp.z, maxp.z do
|
||||||
local pos = {x = x, y = y, z = z}
|
local pos = {x = x, y = y, z = z}
|
||||||
new_active_blocks[minetest.hash_node_position(pos)] = pos
|
new_active_blocks[minetest.hash_node_position(pos)] = pos
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
active_blocks = new_active_blocks
|
|
||||||
-- todo: callbacks on block load/unload
|
|
||||||
end
|
end
|
||||||
end)
|
active_blocks = new_active_blocks
|
||||||
|
-- todo: callbacks on block load/unload
|
||||||
|
|
||||||
|
minetest.after(handle_active_blocks_step, active_blocks_step)
|
||||||
|
end
|
||||||
|
minetest.after(0, active_blocks_step)
|
||||||
|
|
||||||
local function is_active(pos)
|
local function is_active(pos)
|
||||||
return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
|
return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
|
||||||
|
Loading…
Reference in New Issue
Block a user