소스 검색

removed the whole mod-service thing

master
XeonSquared 5 달 전
부모
커밋
0928241895
4개의 변경된 파일1개의 추가작업 그리고 184개의 파일을 삭제
  1. 1
    0
      .gitignore
  2. 0
    8
      mkmods.sh
  3. 0
    88
      mod-service/microtel-3.lua
  4. 0
    88
      module/microtel-3.lua

+ 1
- 0
.gitignore 파일 보기

@@ -0,0 +1 @@
1
+/build

+ 0
- 8
mkmods.sh 파일 보기

@@ -1,8 +0,0 @@
1
-#!/bin/bash
2
-for f in service/*; do
3
- nf=$(echo $f | cut -d '/' -f 2)
4
- echo $nf
5
- echo os.spawn\(function\(\) >mod-service/$nf
6
- cat $f >> mod-service/$nf
7
- echo end,\"$nf\"\) >> mod-service/$nf
8
-done

+ 0
- 88
mod-service/microtel-3.lua 파일 보기

@@ -1,88 +0,0 @@
1
-os.spawn(function()
2
-_G.net={}
3
-
4
-do
5
-local modems,packetQueue,packetCache,routeCache,C,Y = {},{},{},{},COMPUTER,UNPACK
6
-net.port,net.hostname,net.route,net.hook,U=4096,computer.address():sub(1,8),true,{},UPTIME
7
-
8
-for a in component.list("modem") do
9
- modems[a] = component.proxy(a)
10
- modems[a].open(net.port)
11
-end
12
-
13
-local function genPacketID()
14
- local packetID = ""
15
- for i = 1, 16 do
16
-  packetID = packetID .. string.char(math.random(32,126))
17
- end
18
- return packetID
19
-end
20
-
21
-local function rawSendPacket(packetID,packetType,to,from,vport,data)
22
- if routeCache[to] then
23
-  modems[routeCache[to][1]].send(routeCache[to][2],net.port,packetID,packetType,to,from,vport,data)
24
- else
25
-  for k,v in pairs(modems) do
26
-   v.broadcast(net.port,packetID,packetType,to,from,vport,data)
27
-  end
28
- end
29
-end
30
-
31
-local function sendPacket(packetID,packetType,to,vport,data)
32
- packetCache[packetID] = computer.uptime()
33
- rawSendPacket(packetID,packetType,to,net.hostname,vport,data)
34
-end
35
-
36
-function net.send(to,vport,data,packetType,packetID)
37
- packetType,packetID = packetType or 1, packetID or genPacketID()
38
- packetQueue[packetID] = {packetType,to,vport,data,0}
39
- sendPacket(packetID,packetType,to,vport,data)
40
-end
41
-
42
-local function checkCache(packetID)
43
- for k,v in pairs(packetCache) do
44
-  if k == packetID then
45
-   return false
46
-  end
47
- end
48
- return true
49
-end
50
-
51
-while true do
52
- local eventTab = {coroutine.yield()}
53
- if eventTab[1] == "modem_message" and (eventTab[4] == net.port or eventTab[4] == 0) and checkCache(eventTab[6]) then
54
-  for k,v in pairs(packetCache) do
55
-   if computer.uptime() > v+30 then
56
-    packetCache[k] = nil
57
-   end
58
-  end
59
-  for k,v in pairs(routeCache) do
60
-   if computer.uptime() > v[3]+30 then
61
-    routeCache[k] = nil
62
-   end
63
-  end
64
-  routeCache[eventTab[9]] = {eventTab[2],eventTab[3],computer.uptime()}
65
-  if eventTab[8] == net.hostname then
66
-   if eventTab[7] ~= 2 then
67
-    computer.pushSignal("net_msg",eventTab[9],eventTab[10],eventTab[11])
68
-    if eventTab[7] == 1 then
69
-     sendPacket(genPacketID(),2,eventTab[9],eventTab[10],eventTab[6])
70
-    end
71
-   else
72
-    packetQueue[eventTab[11]] = nil
73
-   end
74
-  elseif net.route and checkCache(eventTab[6]) then
75
-   rawSendPacket(eventTab[6],eventTab[7],eventTab[8],eventTab[9],eventTab[10],eventTab[11])
76
-  end
77
-  packetCache[eventTab[6]] = computer.uptime()
78
- end
79
- for k,v in pairs(packetQueue) do
80
-  if computer.uptime() > v[5] then
81
-   sendPacket(k,table.unpack(v))
82
-   v[5]=computer.uptime()+30
83
-  end
84
- end
85
-end
86
-
87
-end
88
-end,"microtel-3.lua")

+ 0
- 88
module/microtel-3.lua 파일 보기

@@ -1,88 +0,0 @@
1
-_G.net={}
2
-
3
-do
4
-local modems,packetQueue,packetCache,routeCache,C,Y = {},{},{},{},COMPUTER,UNPACK
5
-net.port,net.hostname,net.route,net.hook,U=4096,computer.address():sub(1,8),true,{},UPTIME
6
-
7
-for a in component.list("modem") do
8
- modems[a] = component.proxy(a)
9
- modems[a].open(net.port)
10
-end
11
-
12
-local function genPacketID()
13
- local packetID = ""
14
- for i = 1, 16 do
15
-  packetID = packetID .. string.char(math.random(32,126))
16
- end
17
- return packetID
18
-end
19
-
20
-local function rawSendPacket(packetID,packetType,to,from,vport,data)
21
- if routeCache[to] then
22
-  modems[routeCache[to][1]].send(routeCache[to][2],net.port,packetID,packetType,to,from,vport,data)
23
- else
24
-  for k,v in pairs(modems) do
25
-   v.broadcast(net.port,packetID,packetType,to,from,vport,data)
26
-  end
27
- end
28
-end
29
-
30
-local function sendPacket(packetID,packetType,to,vport,data)
31
- packetCache[packetID] = computer.uptime()
32
- rawSendPacket(packetID,packetType,to,net.hostname,vport,data)
33
-end
34
-
35
-function net.send(to,vport,data,packetType,packetID)
36
- packetType,packetID = packetType or 1, packetID or genPacketID()
37
- packetQueue[packetID] = {packetType,to,vport,data,0}
38
- sendPacket(packetID,packetType,to,vport,data)
39
-end
40
-
41
-local function checkCache(packetID)
42
- for k,v in pairs(packetCache) do
43
-  if k == packetID then
44
-   return false
45
-  end
46
- end
47
- return true
48
-end
49
-
50
-os.spawn(function()
51
- while true do
52
-  local eventTab = {coroutine.yield()}
53
-  if eventTab[1] == "modem_message" and (eventTab[4] == net.port or eventTab[4] == 0) and checkCache(eventTab[6]) then
54
-   for k,v in pairs(packetCache) do
55
-    if computer.uptime() > v+30 then
56
-     packetCache[k] = nil
57
-    end
58
-   end
59
-   for k,v in pairs(routeCache) do
60
-    if computer.uptime() > v[3]+30 then
61
-     routeCache[k] = nil
62
-    end
63
-   end
64
-   routeCache[eventTab[9]] = {eventTab[2],eventTab[3],computer.uptime()}
65
-   if eventTab[8] == net.hostname then
66
-    if eventTab[7] ~= 2 then
67
-     computer.pushSignal("net_msg",eventTab[9],eventTab[10],eventTab[11])
68
-     if eventTab[7] == 1 then
69
-      sendPacket(genPacketID(),2,eventTab[9],eventTab[10],eventTab[6])
70
-     end
71
-    else
72
-     packetQueue[eventTab[11]] = nil
73
-    end
74
-   elseif net.route and checkCache(eventTab[6]) then
75
-    rawSendPacket(eventTab[6],eventTab[7],eventTab[8],eventTab[9],eventTab[10],eventTab[11])
76
-   end
77
-   packetCache[eventTab[6]] = computer.uptime()
78
-  end
79
-  for k,v in pairs(packetQueue) do
80
-   if computer.uptime() > v[5] then
81
-    sendPacket(k,table.unpack(v))
82
-    v[5]=computer.uptime()+30
83
-   end
84
-  end
85
- end
86
-end,"minitel.3")
87
-
88
-end

Loading…
취소
저장