Attemps to fix a strange server freeze, probably due to the wireless

No debug log...
This commit is contained in:
upsilon 2017-04-27 15:59:19 +02:00
parent 1d651b3811
commit 9b61effa60
No known key found for this signature in database
GPG Key ID: A80DAE1F266E1C3C
1 changed files with 15 additions and 17 deletions

View File

@ -19,10 +19,8 @@ local set = vector.set_data_to_pos
local remove = vector.remove_data_from_pos local remove = vector.remove_data_from_pos
local function remove_wireless(pos) local function remove_wireless(pos)
local meta = minetest.get_meta(pos) local owner = get(wireless_meta.owners, pos.z,pos.y,pos.x)
if not owner or owner == "" then
local owner = meta:get_string("owner")
if not owner then
return return
end end
if not wireless[owner] or not next(wireless[owner]) then if not wireless[owner] or not next(wireless[owner]) then
@ -30,12 +28,12 @@ local function remove_wireless(pos)
return return
end end
local channel = meta:get_string("channel") local channel = get(wireless_meta.channels, pos.z,pos.y,pos.x)
if channel == "" or not wireless[owner][channel] then if not channel or channel == "" or not wireless[owner][channel] then
return return
end end
table.remove(wireless[owner][channel], meta:get_int("id")) table.remove(wireless[owner][channel], get(wireless_meta.ids, pos.z,pos.y,pos.x))
if #wireless[owner][channel] == 0 then if #wireless[owner][channel] == 0 then
wireless[owner][channel] = nil wireless[owner][channel] = nil
if not next(wireless[owner]) then if not next(wireless[owner]) then
@ -60,7 +58,7 @@ local function set_owner(pos, owner)
wireless[owner] = {} wireless[owner] = {}
end end
local channel = meta:get_string("channel") local channel = get(wireless_meta.channels, pos.z,pos.y,pos.x)
if channel and channel ~= "" then if channel and channel ~= "" then
if not wireless[owner][channel] then if not wireless[owner][channel] then
wireless[owner][channel] = {} wireless[owner][channel] = {}
@ -77,13 +75,13 @@ function set_channel(pos, channel)
end end
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner") local owner = get(wireless_meta.owners, pos.z,pos.y,pos.x)
if owner == "" then if owner or owner == "" then
return return
end end
local old_channel = meta:get_string("channel") local old_channel = get(wireless_meta.channels, pos.z,pos.y,pos.x)
if old_channel and old_channel ~= channel then if old_channel and old_channel ~= "" and old_channel ~= channel then
remove_wireless(pos) remove_wireless(pos)
set_owner(pos, owner) set_owner(pos, owner)
end end
@ -104,16 +102,15 @@ function set_channel(pos, channel)
end end
local function register_wireless(pos) local function register_wireless(pos)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner") local owner = get(wireless_meta.owners, pos.z,pos.y,pos.x)
if owner == "" then if not owner or owner == "" then
return return
end end
set_owner(pos, owner) set_owner(pos, owner)
local channel = meta:get_string("channel") local channel = get(wireless_meta.channels, pos.z,pos.y,pos.x)
if channel ~= "" then if channel and channel ~= "" then
set_channel(pos, channel) set_channel(pos, channel)
end end
@ -206,6 +203,7 @@ minetest.register_node("moremesecons_wireless:wireless", {
end, end,
on_destruct = function(pos) on_destruct = function(pos)
remove_wireless(pos) remove_wireless(pos)
update_mod_storage()
mesecon.receptor_off(pos) mesecon.receptor_off(pos)
end, end,
after_place_node = function(pos, placer) after_place_node = function(pos, placer)