updated to comply with some of the more recent minitel changes

This commit is contained in:
Izaya 2019-07-23 14:10:45 +10:00
parent 2aca6df1b4
commit 8ca414e312

View File

@ -78,7 +78,6 @@ end
local function loadconfig() local function loadconfig()
hostname = os.getenv("HOSTNAME") or computer.address():sub(1,8) hostname = os.getenv("HOSTNAME") or computer.address():sub(1,8)
if OPENOS or PSYCHOS then if OPENOS or PSYCHOS then
print("Opening hostname file.",hnpath)
local f,g=io.open(hnpath,"rb") local f,g=io.open(hnpath,"rb")
if f then if f then
hostname = f:read("*a"):match("(.-)\n") hostname = f:read("*a"):match("(.-)\n")
@ -166,7 +165,7 @@ function start()
return npID return npID
end end
local function sendPacket(packetID,packetType,dest,sender,vPort,data) local function sendPacket(packetID,packetType,dest,sender,vPort,data,repeatingFrom)
if rcache[dest] then if rcache[dest] then
dprint("Cached", rcache[dest][1],"send",rcache[dest][2],cfg.port,packetID,packetType,dest,sender,vPort,data) dprint("Cached", rcache[dest][1],"send",rcache[dest][2],cfg.port,packetID,packetType,dest,sender,vPort,data)
if component.type(rcache[dest][1]) == "modem" then if component.type(rcache[dest][1]) == "modem" then
@ -176,11 +175,13 @@ function start()
end end
else else
dprint("Not cached", cfg.port,packetID,packetType,dest,sender,vPort,data) dprint("Not cached", cfg.port,packetID,packetType,dest,sender,vPort,data)
for k,v in pairs(modems) do if v.address ~= repeatingFrom or (v.type ~= "tunnel" and v.isWireless()) then
if v.type == "modem" then for k,v in pairs(modems) do
v.broadcast(cfg.port,packetID,packetType,dest,sender,vPort,data) if v.type == "modem" then
elseif v.type == "tunnel" then v.broadcast(cfg.port,packetID,packetType,dest,sender,vPort,data)
v.send(packetID,packetType,dest,sender,vPort,data) elseif v.type == "tunnel" then
v.send(packetID,packetType,dest,sender,vPort,data)
end
end end
end end
end end
@ -231,7 +232,7 @@ function start()
elseif dest:sub(1,1) == "~" then -- broadcasts start with ~ elseif dest:sub(1,1) == "~" then -- broadcasts start with ~
computer.pushSignal("net_broadcast",sender,vPort,data) computer.pushSignal("net_broadcast",sender,vPort,data)
elseif cfg.route then -- repeat packets if route is enabled elseif cfg.route then -- repeat packets if route is enabled
sendPacket(packetID,packetType,dest,sender,vPort,data) sendPacket(packetID,packetType,dest,sender,vPort,data,localModem)
end end
if not rcache[sender] then -- add the sender to the rcache if not rcache[sender] then -- add the sender to the rcache
dprint("rcache: "..sender..":", localModem,from,computer.uptime()) dprint("rcache: "..sender..":", localModem,from,computer.uptime())