|
@@ -51,7 +51,7 @@ rotation = 0 |
|
|
TEXT = "Nuclear Pong" |
|
|
TEXT = "Nuclear Pong" |
|
|
currentKey = " " |
|
|
currentKey = " " |
|
|
ptw = 10 |
|
|
ptw = 10 |
|
|
|
|
|
|
|
|
|
|
|
checkrate = 0.5 |
|
|
--CHECKING IF CONTROLS ARE TAKEN |
|
|
--CHECKING IF CONTROLS ARE TAKEN |
|
|
danger = "none" |
|
|
danger = "none" |
|
|
danger2 = "none" |
|
|
danger2 = "none" |
|
@@ -751,6 +751,7 @@ function love.update(dt) |
|
|
|
|
|
|
|
|
end |
|
|
end |
|
|
serverinit = false |
|
|
serverinit = false |
|
|
|
|
|
dserverinit = false |
|
|
datawaspassedtimer = 0 |
|
|
datawaspassedtimer = 0 |
|
|
clientinit = false |
|
|
clientinit = false |
|
|
function love.textinput(t) |
|
|
function love.textinput(t) |
|
@@ -1650,32 +1651,38 @@ function split(s, delimiter) |
|
|
end |
|
|
end |
|
|
return result |
|
|
return result |
|
|
end |
|
|
end |
|
|
|
|
|
address, port = IP, 12345 |
|
|
function checkCurrentServer(dt) |
|
|
function checkCurrentServer(dt) |
|
|
|
|
|
|
|
|
|
|
|
if dserverinit == false then |
|
|
|
|
|
local socket = require "socket" |
|
|
|
|
|
local address, port = IP, 12345 |
|
|
|
|
|
print(address) |
|
|
|
|
|
udp = socket.udp() |
|
|
|
|
|
udp:setpeername(address, port) |
|
|
|
|
|
udp:settimeout(0) |
|
|
|
|
|
dserverinit = true |
|
|
|
|
|
end |
|
|
|
|
|
if IP ~= address then dserverinit = false print(IP .. " " .. address) |
|
|
|
|
|
end |
|
|
ts = ts + dt |
|
|
ts = ts + dt |
|
|
local socket = require "socket" |
|
|
|
|
|
local address, port = IP, 12345 |
|
|
|
|
|
udp = socket.udp() |
|
|
|
|
|
udp:setpeername(address, port) |
|
|
|
|
|
udp:settimeout(0) |
|
|
|
|
|
if ts > updaterate then |
|
|
|
|
|
|
|
|
--print(ts) |
|
|
|
|
|
if ts > checkrate then |
|
|
|
|
|
status = "offline" |
|
|
print("sent ping") |
|
|
print("sent ping") |
|
|
udp:send("HELLO") |
|
|
udp:send("HELLO") |
|
|
ts = 0 |
|
|
|
|
|
end |
|
|
|
|
|
status = "offline" |
|
|
|
|
|
local data |
|
|
local data |
|
|
local datanumtest = 0 |
|
|
|
|
|
local datawaspassed = false |
|
|
|
|
|
data = udp:receive() |
|
|
data = udp:receive() |
|
|
repeat |
|
|
|
|
|
datanumtest = datanumtest + 1 |
|
|
|
|
|
print("LATENCY: " .. tostring(datanumtest)) |
|
|
|
|
|
data = udp:receive() |
|
|
|
|
|
if data then |
|
|
|
|
|
datawaspassed = true |
|
|
|
|
|
print("ReceivedINFO: " .. data) |
|
|
|
|
|
|
|
|
if data then |
|
|
|
|
|
print("got answer!") |
|
|
local p = split(data, '|') |
|
|
local p = split(data, '|') |
|
|
|
|
|
status = p[1] |
|
|
|
|
|
print("answer is " .. status) |
|
|
|
|
|
else |
|
|
|
|
|
print("no response!") |
|
|
|
|
|
end |
|
|
|
|
|
ts = 0 |
|
|
end |
|
|
end |
|
|
until not data |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
end |