download ghosts if they differ

This commit is contained in:
Not 2023-10-12 18:04:44 +02:00
parent 85e49ecd73
commit 12ca9aca54

View File

@ -75,6 +75,15 @@ local function Columns(line, sep)
} }
end end
local function compareTables(a, b, ...)
for _, key in ipairs({...}) do
if a[key] != b[key] then
return false
end
end
return true
end
Ghosts = { Ghosts = {
map, map,
players = {}, players = {},
@ -449,7 +458,7 @@ Client = {
end, end,
callback = function(data, this) callback = function(data, this)
local header local header, storedHeader
local cmd = 1 local cmd = 1
for str in data:gmatch("(.-)\n") do for str in data:gmatch("(.-)\n") do
if Client.data:busy(cmd) then if Client.data:busy(cmd) then
@ -457,7 +466,18 @@ Client = {
end end
header = Index.parseHeader(str) header = Index.parseHeader(str)
if not Index:find(header) then storedHeader = Index:find(header)
if not (
storedHeader
and compareTables(
header,
storedHeader,
"time",
"flags",
"skin",
"color"
)
) then
local tr = Transmitter("GC", {stream = true}) local tr = Transmitter("GC", {stream = true})
tr:transmit(cmd) tr:transmit(cmd)
Client.data:listen(header, cmd) Client.data:listen(header, cmd)