| @@ -765,27 +765,21 @@ function nettest(dt) | |||||
| for i = 1, maxBalls do | for i = 1, maxBalls do | ||||
| ts = ts + dt | ts = ts + dt | ||||
| if ts > updaterate then | if ts > updaterate then | ||||
| if ball[1].dx <= 0 then | |||||
| --print (tostring(ball[i].dy)) | |||||
| udp:send(tostring(lastSentKey) .. | |||||
| '|' .. tostring(ball[i].dy) .. | |||||
| '|' .. tostring(player2.y) .. | |||||
| '|' .. tostring(player1.y) .. | |||||
| '|' .. tostring(player1score) .. | |||||
| '|' .. tostring(player2score) .. | |||||
| '|' .. tostring(player1nukescore) .. | |||||
| '|' .. tostring(player2nukescore) .. | |||||
| '|' .. tostring(ball[i].x) .. | |||||
| '|' .. tostring(ball[i].y) .. | |||||
| '|' .. gameState .. | |||||
| '|' .. tostring(ball[i].dx) .. | |||||
| '|' .. tostring(ballSpeed) .. | |||||
| '|' .. tostring(paddle_SPEED) .. | |||||
| "|HOST") | |||||
| print("PRIVILEGE SENT: " .. lastSentKey) | |||||
| else | |||||
| udp:send(tostring(lastSentKey) ..'|' .. player1.y .. "|HOST") | |||||
| end | |||||
| udp:send(tostring(lastSentKey) .. | |||||
| '|' .. tostring(ball[1].dy) .. | |||||
| '|' .. tostring(player2.y) .. | |||||
| '|' .. tostring(player1.y) .. | |||||
| '|' .. tostring(player1score) .. | |||||
| '|' .. tostring(player2score) .. | |||||
| '|' .. tostring(player1nukescore) .. | |||||
| '|' .. tostring(player2nukescore) .. | |||||
| '|' .. tostring(ball[1].x) .. | |||||
| '|' .. tostring(ball[1].y) .. | |||||
| '|' .. gameState .. | |||||
| '|' .. tostring(ball[1].dx) .. | |||||
| '|' .. tostring(ballSpeed) .. | |||||
| '|' .. tostring(paddle_SPEED) .. | |||||
| "|HOST") | |||||
| ts = 0 | ts = 0 | ||||
| end | end | ||||
| end | end | ||||
| @@ -802,22 +796,36 @@ function nettest(dt) | |||||
| print("ReceivedINFO: " .. data) | print("ReceivedINFO: " .. data) | ||||
| confirmation = "N" | confirmation = "N" | ||||
| local p = split(data, '|') | local p = split(data, '|') | ||||
| if p[3] ~= "CLIENT" and not p[15] then | |||||
| confirmation = "U" | |||||
| end | |||||
| if p[15] then | if p[15] then | ||||
| if p[15] ~= "CLIENT" then | if p[15] ~= "CLIENT" then | ||||
| confirmation = "U" | confirmation = "U" | ||||
| end | end | ||||
| end | |||||
| if tonumber(p[4]) > 90 then | |||||
| else | |||||
| confirmation = "U" | |||||
| end | |||||
| if tonumber(p[16]) > 90 then | |||||
| confirmation = "L" | confirmation = "L" | ||||
| end | end | ||||
| if ball[1].dx <= 0 then | |||||
| lastSentKeyClient = p[1] | |||||
| player2.y = tonumber(p[2]) | |||||
| elseif ball[1].dx > 0 then | |||||
| lastSentKeyClient, ball[i].dy, player2.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]) | |||||
| if (ball[1].dx > 0 and ball[1].x >= 40) or (ball[i].dx <= 0 and ball.x > VIRTUAL_WIDTH - 40) then | |||||
| die = tonumber(p[2]) | |||||
| lastSentKeyClient, | |||||
| ball[1].dy, | |||||
| player2.y, | |||||
| player1score, | |||||
| player2score, | |||||
| player1nukescore, | |||||
| player2nukescore, | |||||
| ball[1].x, | |||||
| ball[1].y, | |||||
| gameState, | |||||
| ball[1].dx, | |||||
| ballSpeed, | |||||
| paddle_SPEED = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]) | |||||
| else | |||||
| lastSentKeyClient = p[1] | |||||
| player2.y = tonumber(p[4]) | |||||
| end | end | ||||
| end | end | ||||
| @@ -845,27 +853,21 @@ function clienttest(dt) | |||||
| end | end | ||||
| ts = ts + dt | ts = ts + dt | ||||
| if ts > updaterate then | if ts > updaterate then | ||||
| if ball[1].dx <= 0 then | |||||
| print("MINOR SENDING") | |||||
| udp:send(tostring(lastSentKey) ..'|' .. player2.y .. "|CLIENT") | |||||
| elseif ball[1].dx > 0 then | |||||
| print("PRIVILEGED SENDING") | |||||
| udp:send(tostring(lastSentKey) .. | |||||
| '|' .. tostring(ball[1].dy) .. | |||||
| '|' .. tostring(player1.y) .. | |||||
| '|' .. tostring(player2.y) .. | |||||
| '|' .. tostring(player1score) .. | |||||
| '|' .. tostring(player2score) .. | |||||
| '|' .. tostring(player1nukescore) .. | |||||
| '|' .. tostring(player2nukescore) .. | |||||
| '|' .. tostring(ball[1].x) .. | |||||
| '|' .. tostring(ball[1].y) .. | |||||
| '|' .. gameState .. | |||||
| '|' .. tostring(ball[1].dx) .. | |||||
| '|' .. tostring(ballSpeed) .. | |||||
| '|' .. tostring(paddle_SPEED) .. | |||||
| "|CLIENT") | |||||
| end | |||||
| udp:send(tostring(lastSentKey) .. | |||||
| '|' .. tostring(ball[1].dy) .. | |||||
| '|' .. tostring(player1.y) .. | |||||
| '|' .. tostring(player2.y) .. | |||||
| '|' .. tostring(player1score) .. | |||||
| '|' .. tostring(player2score) .. | |||||
| '|' .. tostring(player1nukescore) .. | |||||
| '|' .. tostring(player2nukescore) .. | |||||
| '|' .. tostring(ball[1].x) .. | |||||
| '|' .. tostring(ball[1].y) .. | |||||
| '|' .. gameState .. | |||||
| '|' .. tostring(ball[1].dx) .. | |||||
| '|' .. tostring(ballSpeed) .. | |||||
| '|' .. tostring(paddle_SPEED) .. | |||||
| "|CLIENT") | |||||
| ts = 0 | ts = 0 | ||||
| end | end | ||||
| local data | local data | ||||
| @@ -891,16 +893,16 @@ function clienttest(dt) | |||||
| end | end | ||||
| for i = 1, maxBalls do | for i = 1, maxBalls do | ||||
| local die = tonumber(p[2]) | local die = tonumber(p[2]) | ||||
| if ball[i].dx <= 0 then | |||||
| if (ball[i].dx <= 0 and ball.x < VIRTUAL_WIDTH - 40) or (ball[i].dx > 0 and ball.x < 40) then | |||||
| lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]) | lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]) | ||||
| elseif ball[i].dx > 0 then | |||||
| else | |||||
| lastSentKeyClient = p[1] | lastSentKeyClient = p[1] | ||||
| player1.y = tonumber(p[4]) | player1.y = tonumber(p[4]) | ||||
| end | end | ||||
| end | end | ||||
| elseif p[3] ~= "HOST" then | |||||
| else | |||||
| confirmation = "U" | confirmation = "U" | ||||
| end | |||||
| end | |||||
| end | end | ||||
| print("GOT: " .. lastSentKeyClient) | print("GOT: " .. lastSentKeyClient) | ||||
| until not data | until not data | ||||