From bb7b78403170d978b6d7946aaff4ec4f4d1bffb0 Mon Sep 17 00:00:00 2001
From: madiwka3 <madi.turgunov.03@gmail.com>
Date: Tue, 18 Aug 2020 13:25:04 +0600
Subject: [PATCH] fix??

---
 main.lua         | 25 +++++++++++++++++++------
 src/baseGame.lua |  2 +-
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/main.lua b/main.lua
index bae3e69..498affc 100644
--- a/main.lua
+++ b/main.lua
@@ -744,7 +744,7 @@ function love.update(dt)
         if ts > updaterate then 
         clienttest(dt)
         ts = ts - updaterate
-    end 
+        end 
     end
    
 
@@ -783,14 +783,20 @@ function nettest(dt)
     "|HOST")
     print("SENT: " .. lastSentKey)
     end 
-    data = udp:receive() 
+
+    local data
+    local datanumtest = 0
+    repeat 
+        datanumtest = datanumtest + 1
+        print("LATENCY: " .. tostring(datanumtest))
+    data = udp:receive()
     if data then
         confirmation = "N"
         local p = split(data, '|')
         if p[3] ~= "CLIENT" then 
             confirmation = "U"
         end
-        if tonumber(p[4]) > 5 then 
+        if tonumber(p[4]) > 90 then 
             confirmation = "L"
         end
         lastSentKeyClient = p[1]
@@ -801,6 +807,7 @@ function nettest(dt)
         confirmation = "D"
         print("NO PLAYER 2!!")
     end 
+until not data 
 end
 function clienttest(dt) 
     if clientinit == false then 
@@ -810,14 +817,20 @@ function clienttest(dt)
         udp = socket.udp()
         udp:setpeername(address, port)
         udp:settimeout(0)
+        udp:send(tostring(lastSentKey) .. '|' .. tostring(player2.y) .. "|CLIENT")
         clientinit = true 
     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()
     
     if data then
         print(data)
+        udp:send(tostring(lastSentKey) .. '|' .. tostring(player2.y) .. "|CLIENT")
+        print("SENT TO SERVER:" ..  lastSentKey)
         confirmation = "N"
         local p = split(data, '|')
         if p[13] then 
@@ -836,7 +849,7 @@ function clienttest(dt)
         confirmation = "D"
     end
     print("GOT: " .. lastSentKeyClient)
-
+    until not data 
 end
 function wallbreaker(x, y)
     if (gameState == "editor") then
diff --git a/src/baseGame.lua b/src/baseGame.lua
index 453c668..4007819 100644
--- a/src/baseGame.lua
+++ b/src/baseGame.lua
@@ -995,7 +995,7 @@ function clientsBaseGame(dt)
         print("moving player1 down")
     else
         player1.dy = 0
-        print("stopping player")
+       -- print("stopping player")
     end
     if ((love.keyboard.isDown(p2control.up))) then
         player2.dy = (paddle_SPEED + p2bonus) * -1