From 8b721c04e0cacefe7bd6402f1c00406b303a1d70 Mon Sep 17 00:00:00 2001 From: cheapie Date: Sun, 27 Apr 2025 00:41:25 -0500 Subject: Minor controller/dispatcher performance improvements --- controller.lua | 6 ++++++ dispatcher.lua | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/controller.lua b/controller.lua index 0a43eff..2921f81 100644 --- a/controller.lua +++ b/controller.lua @@ -645,7 +645,9 @@ end function celevator.controller.checkiqueue(dtime) for hash,iqueue in pairs(celevator.controller.iqueue) do local pos = minetest.get_position_from_hash(hash) + local noneleft = true for iid,time in pairs(iqueue) do + noneleft = false iqueue[iid] = time-dtime if iqueue[iid] < 0 then iqueue[iid] = nil @@ -655,6 +657,10 @@ function celevator.controller.checkiqueue(dtime) celevator.controller.run(pos,event) end end + if noneleft then + celevator.controller.iqueue[hash] = nil + celevator.storage:set_string("controller_iqueue",minetest.serialize(celevator.controller.iqueue)) + end end end diff --git a/dispatcher.lua b/dispatcher.lua index a8bcf1c..02533ff 100644 --- a/dispatcher.lua +++ b/dispatcher.lua @@ -422,7 +422,9 @@ end function celevator.dispatcher.checkiqueue(dtime) for hash,iqueue in pairs(celevator.dispatcher.iqueue) do local pos = minetest.get_position_from_hash(hash) + local noneleft = true for iid,time in pairs(iqueue) do + noneleft = false iqueue[iid] = time-dtime if iqueue[iid] < 0 then iqueue[iid] = nil @@ -432,6 +434,10 @@ function celevator.dispatcher.checkiqueue(dtime) celevator.dispatcher.run(pos,event) end end + if noneleft then + celevator.dispatcher.iqueue[hash] = nil + celevator.storage:set_string("dispatcher_iqueue",minetest.serialize(celevator.dispatcher.iqueue)) + end end end -- cgit v1.2.3