fix: replace custom event wake-up with polling, remove craftItem double-capture
Two robustness improvements to the Network capture/processor split:
1. Processor wake-up: replaced os.queueEvent('network_queued') /
os.pullEvent('network_queued') with sleep(0) polling. Custom events
can be consumed by other coroutines (e.g. craftItem's unfiltered
os.pullEvent()) or swallowed by the OS event layer. Polling the
shared queue every tick is simpler and guaranteed reliable.
2. craftItem: removed ORDER_CHANNEL message buffering and re-queuing.
With the dedicated Network-capture task, ORDER_CHANNEL messages are
already safely captured into networkQueue. The old buffering caused
double-capture: capture task adds to queue, craftItem also buffers,
then re-queues via os.queueEvent -> capture captures again -> dup.
The commandId dedup caught these, but removing the source is cleaner.
This commit is contained in:
@@ -646,7 +646,6 @@ local function main()
|
||||
local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
|
||||
if channel == cfg.ORDER_CHANNEL and type(message) == "table" then
|
||||
table.insert(networkQueue, { replyChannel = replyChannel, message = message })
|
||||
os.queueEvent("network_queued")
|
||||
end
|
||||
end
|
||||
end),
|
||||
@@ -658,7 +657,7 @@ local function main()
|
||||
end
|
||||
while true do
|
||||
if #networkQueue == 0 then
|
||||
os.pullEvent("network_queued")
|
||||
sleep(0)
|
||||
end
|
||||
while #networkQueue > 0 do
|
||||
local entry = table.remove(networkQueue, 1)
|
||||
|
||||
Reference in New Issue
Block a user