|
@@ -744,7 +744,7 @@ function love.update(dt) |
|
|
if ts > updaterate then |
|
|
if ts > updaterate then |
|
|
clienttest(dt) |
|
|
clienttest(dt) |
|
|
ts = ts - updaterate |
|
|
ts = ts - updaterate |
|
|
end |
|
|
|
|
|
|
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -783,14 +783,20 @@ function nettest(dt) |
|
|
"|HOST") |
|
|
"|HOST") |
|
|
print("SENT: " .. lastSentKey) |
|
|
print("SENT: " .. lastSentKey) |
|
|
end |
|
|
end |
|
|
data = udp:receive() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local data |
|
|
|
|
|
local datanumtest = 0 |
|
|
|
|
|
repeat |
|
|
|
|
|
datanumtest = datanumtest + 1 |
|
|
|
|
|
print("LATENCY: " .. tostring(datanumtest)) |
|
|
|
|
|
data = udp:receive() |
|
|
if data then |
|
|
if data then |
|
|
confirmation = "N" |
|
|
confirmation = "N" |
|
|
local p = split(data, '|') |
|
|
local p = split(data, '|') |
|
|
if p[3] ~= "CLIENT" then |
|
|
if p[3] ~= "CLIENT" then |
|
|
confirmation = "U" |
|
|
confirmation = "U" |
|
|
end |
|
|
end |
|
|
if tonumber(p[4]) > 5 then |
|
|
|
|
|
|
|
|
if tonumber(p[4]) > 90 then |
|
|
confirmation = "L" |
|
|
confirmation = "L" |
|
|
end |
|
|
end |
|
|
lastSentKeyClient = p[1] |
|
|
lastSentKeyClient = p[1] |
|
@@ -801,6 +807,7 @@ function nettest(dt) |
|
|
confirmation = "D" |
|
|
confirmation = "D" |
|
|
print("NO PLAYER 2!!") |
|
|
print("NO PLAYER 2!!") |
|
|
end |
|
|
end |
|
|
|
|
|
until not data |
|
|
end |
|
|
end |
|
|
function clienttest(dt) |
|
|
function clienttest(dt) |
|
|
if clientinit == false then |
|
|
if clientinit == false then |
|
@@ -810,14 +817,20 @@ function clienttest(dt) |
|
|
udp = socket.udp() |
|
|
udp = socket.udp() |
|
|
udp:setpeername(address, port) |
|
|
udp:setpeername(address, port) |
|
|
udp:settimeout(0) |
|
|
udp:settimeout(0) |
|
|
|
|
|
udp:send(tostring(lastSentKey) .. '|' .. tostring(player2.y) .. "|CLIENT") |
|
|
clientinit = true |
|
|
clientinit = true |
|
|
end |
|
|
end |
|
|
udp:send(tostring(lastSentKey) .. '|' .. tostring(player2.y) .. "|CLIENT") |
|
|
|
|
|
print("SENT TO SERVER:" .. lastSentKey) |
|
|
|
|
|
|
|
|
local data |
|
|
|
|
|
local datanumtest = 0 |
|
|
|
|
|
repeat |
|
|
|
|
|
datanumtest = datanumtest + 1 |
|
|
|
|
|
print("LATENCY: " .. tostring(datanumtest)) |
|
|
data = udp:receive() |
|
|
data = udp:receive() |
|
|
|
|
|
|
|
|
if data then |
|
|
if data then |
|
|
print(data) |
|
|
print(data) |
|
|
|
|
|
udp:send(tostring(lastSentKey) .. '|' .. tostring(player2.y) .. "|CLIENT") |
|
|
|
|
|
print("SENT TO SERVER:" .. lastSentKey) |
|
|
confirmation = "N" |
|
|
confirmation = "N" |
|
|
local p = split(data, '|') |
|
|
local p = split(data, '|') |
|
|
if p[13] then |
|
|
if p[13] then |
|
@@ -836,7 +849,7 @@ function clienttest(dt) |
|
|
confirmation = "D" |
|
|
confirmation = "D" |
|
|
end |
|
|
end |
|
|
print("GOT: " .. lastSentKeyClient) |
|
|
print("GOT: " .. lastSentKeyClient) |
|
|
|
|
|
|
|
|
|
|
|
until not data |
|
|
end |
|
|
end |
|
|
function wallbreaker(x, y) |
|
|
function wallbreaker(x, y) |
|
|
if (gameState == "editor") then |
|
|
if (gameState == "editor") then |
|
|