1
0
mirror of https://github.com/LDDestroier/CC/ synced 2025-01-09 08:50:27 +00:00

Added ms ping indicator

This commit is contained in:
LDDestroier 2019-02-14 23:38:30 -05:00 committed by GitHub
parent bff55611df
commit 4598721ad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -609,13 +609,17 @@ local drawGrid = function(x, y, onlyDrawGrid, useSetVisible)
end end
end end
local render = function(useSetVisible) local render = function(useSetVisible, netTime)
local p = player[you] local p = player[you]
drawGrid(scrollX + scrollAdjX, scrollY + scrollAdjY, false, useSetVisible) drawGrid(scrollX + scrollAdjX, scrollY + scrollAdjY, false, useSetVisible)
termsetCursorPos(1,1) termsetCursorPos(1,1)
termsetTextColor(player[you].color[1]) termsetTextColor(player[you].color[1])
termsetBackgroundColor(tocolors[grid.voidcol]) termsetBackgroundColor(tocolors[grid.voidcol])
term.write("P" .. you) term.write("P" .. you)
term.setTextColor(colors.white)
if skynet and netTime then
term.write(" " .. tostring(os.epoch() - netTime) .. "ms")
end
if debugShowKeys then if debugShowKeys then
term.setCursorPos(1,2) term.setCursorPos(1,2)
term.write("dir = " .. player[you].direction .. " ") term.write("dir = " .. player[you].direction .. " ")
@ -921,6 +925,7 @@ local sendInfo = function(gameID)
name = player[you].name, name = player[you].name,
putTrail = isPuttingDown, putTrail = isPuttingDown,
gameID = gameID, gameID = gameID,
time = os.epoch(),
keysDown = isHost and nil or keysDown, keysDown = isHost and nil or keysDown,
trail = isHost and lastTrails or nil, trail = isHost and lastTrails or nil,
deadGuys = isHost and deadGuys or nil, deadGuys = isHost and deadGuys or nil,
@ -1027,8 +1032,9 @@ end
local game = function() local game = function()
local outcome local outcome
local p, np, timeoutID, tID, evt local p, np, timeoutID, tID, evt, netTime
while true do while true do
netTime = nil
if isHost then if isHost then
sleep(gameDelay) sleep(gameDelay)
else else
@ -1040,6 +1046,8 @@ local game = function()
os.queueEvent("tron_complete", "timeout", isHost, player[nou].name) os.queueEvent("tron_complete", "timeout", isHost, player[nou].name)
parallel.waitForAny(function() imageAnim(images.timeout) end, waitForKey) parallel.waitForAny(function() imageAnim(images.timeout) end, waitForKey)
return return
elseif evt == "move_tick" then
netTime = tID
end end
end end
p = player[you] p = player[you]
@ -1081,7 +1089,7 @@ local game = function()
else else
scrollX = p.x - mathfloor(scr_x / 2) scrollX = p.x - mathfloor(scr_x / 2)
scrollY = p.y - mathfloor(scr_y / 2) scrollY = p.y - mathfloor(scr_y / 2)
render(true) render(true, (not isHost) and netTime)
end end
end end
end end
@ -1130,7 +1138,7 @@ local networking = function()
end end
end end
deadGuys = msg.deadGuys deadGuys = msg.deadGuys
os.queueEvent("move_tick") os.queueEvent("move_tick", msg.time)
end end
elseif type(msg.keysDown) == "table" then elseif type(msg.keysDown) == "table" then
netKeysDown = msg.keysDown netKeysDown = msg.keysDown