Reduced network load further

Now, clients will not send their playerdata -- only their inputs. Likewise, hosts don't send their inputs.
This is to prepare for the eventual usage of Skynet, but also just to optimize a bit.
This commit is contained in:
LDDestroier 2018-11-16 10:17:58 -05:00 committed by GitHub
parent d55cd40dd1
commit f4bd0470bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 10 deletions

22
tron
View File

@ -659,11 +659,11 @@ end
local sendInfo = function(gameID)
modem.transmit(port, port, {
player = player,
player = isHost and player or nil,
gameID = gameID,
keysDown = keysDown,
trail = isHost and lastTrails or {},
deadGuys = isHost and deadGuys or {},
keysDown = isHost and nil or keysDown,
trail = isHost and lastTrails or nil,
deadGuys = isHost and deadGuys or nil,
})
end
@ -813,7 +813,7 @@ local networking = function()
while true do
evt, side, channel, repchannel, msg, distance = os.pullEvent("modem_message")
if channel == port and repchannel == port and type(msg) == "table" then
if type(msg.player) == "table" and type(msg.gameID) == "string" then
if type(msg.gameID) == "string" then
if waitingForGame and (type(msg.new) == "number") then
if msg.new < os.time() then
@ -838,12 +838,14 @@ local networking = function()
elseif msg.gameID == gamename then
if not isHost then
player = msg.player
for i = 1, #msg.trail do
putTrailXY(unpack(msg.trail[i]))
if type(msg.player) == "table" then
player = msg.player
for i = 1, #msg.trail do
putTrailXY(unpack(msg.trail[i]))
end
deadGuys = msg.deadGuys
os.queueEvent("move_tick")
end
deadGuys = msg.deadGuys
os.queueEvent("move_tick")
elseif type(msg.keysDown) == "table" then
netKeysDown = msg.keysDown
end