From 12ca9aca540adf0a53610a24daa9d94284bd0e20 Mon Sep 17 00:00:00 2001 From: Not Date: Thu, 12 Oct 2023 18:04:44 +0200 Subject: [PATCH] download ghosts if they differ --- ghost.lua | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ghost.lua b/ghost.lua index d41fc3f..eb39b0b 100644 --- a/ghost.lua +++ b/ghost.lua @@ -75,6 +75,15 @@ local function Columns(line, sep) } 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 = { map, players = {}, @@ -449,7 +458,7 @@ Client = { end, callback = function(data, this) - local header + local header, storedHeader local cmd = 1 for str in data:gmatch("(.-)\n") do if Client.data:busy(cmd) then @@ -457,7 +466,18 @@ Client = { end 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}) tr:transmit(cmd) Client.data:listen(header, cmd)