fix spamming request item

This commit is contained in:
bgkillas 2024-11-19 23:34:03 -05:00
parent a744a935db
commit cbec17c142

View file

@ -184,6 +184,8 @@ function item_sync.host_localize_item(gid, peer_id)
rpc.item_localize(peer_id, gid) rpc.item_localize(peer_id, gid)
end end
local wait_for_gid = {}
function item_sync.make_item_global(item, instant, give_authority_to) function item_sync.make_item_global(item, instant, give_authority_to)
EntityAddTag(item, "ew_global_item") EntityAddTag(item, "ew_global_item")
async(function() async(function()
@ -484,6 +486,7 @@ end
rpc.opts_reliable() rpc.opts_reliable()
function rpc.item_globalize(item_data) function rpc.item_globalize(item_data)
wait_for_gid[item_data.gid] = nil
if is_safe_to_remove() then if is_safe_to_remove() then
item_sync.remove_item_with_id_now(item_data.gid) item_sync.remove_item_with_id_now(item_data.gid)
end end
@ -559,7 +562,10 @@ function rpc.update_positions(position_data)
end end
else else
util.log("Requesting again "..gid) util.log("Requesting again "..gid)
rpc.request_send_again(gid) if wait_for_gid[gid] == nil then
rpc.request_send_again(gid)
wait_for_gid[gid] = true
end
end end
end end
end end