1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-14 20:20:30 +00:00

Optimize peripheral calls in rednet.run (#954)

This commit is contained in:
Anavrins 2021-11-14 01:57:47 -05:00 committed by GitHub
parent 6cc2f035db
commit 4d8862c78e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -403,10 +403,11 @@ function run()
if sEvent == "modem_message" then if sEvent == "modem_message" then
-- Got a modem message, process it and add it to the rednet event queue -- Got a modem message, process it and add it to the rednet event queue
local sModem, nChannel, nReplyChannel, tMessage = p1, p2, p3, p4 local sModem, nChannel, nReplyChannel, tMessage = p1, p2, p3, p4
if isOpen(sModem) and (nChannel == id_as_channel() or nChannel == CHANNEL_BROADCAST) then if nChannel == id_as_channel() or nChannel == CHANNEL_BROADCAST then
if type(tMessage) == "table" and type(tMessage.nMessageID) == "number" if type(tMessage) == "table" and type(tMessage.nMessageID) == "number"
and tMessage.nMessageID == tMessage.nMessageID and not tReceivedMessages[tMessage.nMessageID] and tMessage.nMessageID == tMessage.nMessageID and not tReceivedMessages[tMessage.nMessageID]
and ((tMessage.nRecipient and tMessage.nRecipient == os.getComputerID()) or nChannel == CHANNEL_BROADCAST) and ((tMessage.nRecipient and tMessage.nRecipient == os.getComputerID()) or nChannel == CHANNEL_BROADCAST)
and isOpen(sModem)
then then
tReceivedMessages[tMessage.nMessageID] = os.clock() + 9.5 tReceivedMessages[tMessage.nMessageID] = os.clock() + 9.5
if not nClearTimer then nClearTimer = os.startTimer(10) end if not nClearTimer then nClearTimer = os.startTimer(10) end