1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-12-25 09:58:04 +11:00

improved minification for microtel-3.lua

This commit is contained in:
Izaya 2018-03-13 12:21:59 +11:00
parent 72093c31dd
commit 04bc0bcaf8
2 changed files with 21 additions and 14 deletions

View File

@ -7,7 +7,7 @@ net.pctime=30
net.retry=30
do
local rcpe,PC,RC,pQ,M=computer.pullSignal,{},{},{},{}
local cI,cU=component.invoke,computer.uptime
local cI,cU,cPS=component.invoke,computer.uptime,computer.pushSignal
for a,t in component.list("modem") do
M[#M+1]=component.proxy(a)
M[#M].open(net.port)
@ -19,12 +19,12 @@ npID=npID .. string.char(math.random(32,126))
end
return npID
end
local function sP(packetID,packetType,dest,sender,vport,data)
if RC[dest] then
cI(RC[dest][1],"send",RC[dest][2],net.port,packetID,packetType,dest,sender,vport,data)
local function sP(pID,pT,D,S,vP,dA)
if RC[D] then
cI(RC[D][1],"send",RC[D][2],net.port,pID,pT,D,S,vP,dA)
else
for k,v in pairs(M) do
v.broadcast(net.port,packetID,packetType,dest,sender,vport,data)
v.broadcast(net.port,pID,pT,D,S,vP,dA)
end
end
end
@ -40,9 +40,9 @@ PC[k]=nil
end
end
end
local function cPC(packetID)
local function cPC(pID)
for k,v in pairs(PC) do
if k==packetID then return true end
if k==pID then return true end
end
return false
end
@ -70,10 +70,10 @@ sP(gP(),2,tev[9],net.hostname,tev[10],tev[6])
end
if tev[7]==2 then
pQ[tev[11]]=nil
computer.pushSignal("net_ack",data)
cPS("net_ack",tev[11])
end
if tev[7]~=2 then
computer.pushSignal("net_msg",tev[9],tev[10],tev[11])
cPS("net_msg",tev[9],tev[10],tev[11])
end
else
sP(tev[6],tev[7],tev[8],tev[9],tev[10],tev[11])
@ -87,13 +87,13 @@ end
end
return table.unpack(tev)
end
function net.usend(to,vport,data,npID)
function net.usend(to,vP,dA,npID)
npID=npID or gP()
pQ[npID]={0,to,vport,data,0,0}
pQ[npID]={0,to,vP,dA,0,0}
end
function net.rsend(to,vport,data,npID)
function net.rsend(to,vP,dA,npID)
npID=npID or gP()
pQ[npID]={1,to,vport,data,0,0}
pQ[npID]={1,to,vP,dA,0,0}
repeat
local te={computer.pullSignal()}
until te[1]=="net_ack" and te[2]==npID

View File

@ -5,6 +5,12 @@ sed -i -e 's/pcache/PC/g' microtel-3-mini.lua
sed -i -e 's/rcache/RC/g' microtel-3-mini.lua
sed -i -e 's/pqueue/pQ/g' microtel-3-mini.lua
sed -i -e 's/modems/M/g' microtel-3-mini.lua
sed -i -e 's/packetID/pID/g' microtel-3-mini.lua
sed -i -e 's/packetType/pT/g' microtel-3-mini.lua
sed -i -e 's/dest/D/g' microtel-3-mini.lua
sed -i -e 's/sender/S/g' microtel-3-mini.lua
sed -i -e 's/vport/vP/g' microtel-3-mini.lua
sed -i -e 's/data/dA/g' microtel-3-mini.lua
sed -i -e 's/genPacketID/gP/g' microtel-3-mini.lua
sed -i -e 's/sendPacket/sP/g' microtel-3-mini.lua
sed -i -e 's/pruneCache/pC/g' microtel-3-mini.lua
@ -12,7 +18,8 @@ sed -i -e 's/checkPCache/cPC/g' microtel-3-mini.lua
sed -i -e 's/packetPusher/pP/g' microtel-3-mini.lua
sed -i -e 's/component.invoke/cI/g' microtel-3-mini.lua
sed -i -e 's/computer.uptime/cU/g' microtel-3-mini.lua
sed -i -e 's/--subhere/local cI,cU = component.invoke,computer.uptime/g' microtel-3-mini.lua
sed -i -e 's/computer.pushSignal/cPS/g' microtel-3-mini.lua
sed -i -e 's/--subhere/local cI,cU,cPS = component.invoke,computer.uptime,computer.pushSignal/g' microtel-3-mini.lua
lua strip.lua microtel-3-mini.lua microtel-3-mini.lua
#microtel-4.lua