mirror of
https://github.com/LDDestroier/CC/
synced 2025-01-19 13:42:54 +00:00
Reduced amount of new fs.open()'s
This commit is contained in:
parent
714da7ee03
commit
4e0369e7d2
14
disknet.lua
14
disknet.lua
@ -157,18 +157,21 @@ disknet.receive = function(channel)
|
||||
local output, contents
|
||||
local doRewrite = false
|
||||
|
||||
while true do
|
||||
loadFList()
|
||||
|
||||
while true do
|
||||
for i = 1, #fList do
|
||||
contents = fList[i].readAll()
|
||||
if contents ~= "" then
|
||||
contents = textutils.unserialize(contents)
|
||||
fList[i].close()
|
||||
fList[i] = fs.open(pList[i], "r")
|
||||
contents = textutils.unserialize(fList[i].readAll())
|
||||
if type(contents) == "table" then
|
||||
if contents[1] then
|
||||
if not output then
|
||||
for look = 1, #contents do
|
||||
if (contents[look].uniqueID ~= uniqueID) and (not msgCheckList[contents[look].messageID]) then
|
||||
if getTime() - (contents[look].time or 0) <= 0.01 then
|
||||
if getTime() - (contents[look].time or 0) <= 0.001 then
|
||||
msgCheckList[contents[look].messageID] = true
|
||||
output = {}
|
||||
for k,v in pairs(contents[look]) do
|
||||
@ -183,7 +186,7 @@ disknet.receive = function(channel)
|
||||
-- delete old msesages
|
||||
doRewrite = false
|
||||
for t = #contents, 1, -1 do
|
||||
if getTime() - (contents[t].time or 0) > 0.01 then
|
||||
if getTime() - (contents[t].time or 0) > 0.001 then
|
||||
msgCheckList[contents[t].messageID] = nil
|
||||
table.remove(contents, t)
|
||||
doRewrite = true
|
||||
@ -205,9 +208,6 @@ disknet.receive = function(channel)
|
||||
if output then
|
||||
break
|
||||
else
|
||||
for i = 1, #fList do
|
||||
fList[i].close()
|
||||
end
|
||||
os.queueEvent("")
|
||||
os.pullEvent("")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user