diff options
author | BuckarooBanzay <BuckarooBanzay@users.noreply.github.com> | 2020-10-28 15:41:10 +0100 |
---|---|---|
committer | BuckarooBanzay <BuckarooBanzay@users.noreply.github.com> | 2020-10-28 15:41:10 +0100 |
commit | fbf6777c299b665884875e2afe76f791c8f7ab74 (patch) | |
tree | 1885423887c4d74c05903b674151f9096d402eaa /context.lua | |
parent | 6c6068f38ba9e3f96867d2598938f381bbab7eac (diff) | |
download | mesecons_debug-fbf6777c299b665884875e2afe76f791c8f7ab74.tar.gz mesecons_debug-fbf6777c299b665884875e2afe76f791c8f7ab74.zip |
globalize context data
Diffstat (limited to 'context.lua')
-rw-r--r-- | context.lua | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/context.lua b/context.lua index 5c08ae5..7e70c1c 100644 --- a/context.lua +++ b/context.lua @@ -7,15 +7,11 @@ if has_monitoring then penalized_mapblock_count = monitoring.gauge("mesecons_debug_penalized_mapblock_count", "count of penalized mapblocks") end - --- blockpos-hash => context -local context_store = {} - mesecons_debug.get_context = function(pos) local blockpos = mesecons_debug.get_blockpos(pos) local hash = minetest.hash_node_position(blockpos) - local ctx = context_store[hash] + local ctx = mesecons_debug.context_store[hash] if not ctx then -- create a new context ctx = { @@ -29,7 +25,7 @@ mesecons_debug.get_context = function(pos) -- mtime mtime = minetest.get_us_time(), } - context_store[hash] = ctx + mesecons_debug.context_store[hash] = ctx end -- update context @@ -51,11 +47,11 @@ minetest.register_globalstep(function(dtime) local cleanup_time_micros = 300 * 1000 * 1000 mesecons_debug.context_store_size = 0 - for hash, ctx in pairs(context_store) do + for hash, ctx in pairs(mesecons_debug.context_store) do local time_diff = now - ctx.mtime if time_diff > cleanup_time_micros then -- remove item - context_store[hash] = nil + mesecons_debug.context_store[hash] = nil else -- calculate stuff |