Mercurial > wow > breuesk
changeset 92:a227f3b61cda
Starting to integrate differential updating
author | John@Yosemite-PC |
---|---|
date | Sun, 22 Apr 2012 00:03:13 -0400 |
parents | 5ade79caeece |
children | df94161e6d7c |
files | Comm.lua |
diffstat | 1 files changed, 43 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Comm.lua Mon Apr 16 07:06:50 2012 -0400 +++ b/Comm.lua Sun Apr 22 00:03:13 2012 -0400 @@ -87,8 +87,40 @@ -- working state -- todo: if they send a timestamp that's somewhere along our -- timeline, then just catch them up - local dbPersons = {toons=PersonList.toons,time=PersonList.time} - Send("CU",{dbPersons,LootLists.l,timestamp}) -- todo: send privately + --local dbPersons = {toons=PersonList.toons,time=PersonList.time} + --Send("CU",{dbPersons,LootLists.l,timestamp}) -- todo: send privately + + local t = packet + local remoteBase = table.remove(t,1) + + -- if their base is older than ours, this is easy - send them our + -- base and all the changes + -- if their base is equal to ours, then diff their changes vs ours + -- and send them the remainder - it's ok if they have changes we + -- don't + -- if their base is newer, then we have a problem - it means another + -- admin rebased and we aren't aware of that. but the other admin + -- wouldn't have done that if they didn't believe all the admins + -- were synced up to the release point. So do we trust that and use + -- this as a rebase opportunity? print an error? just reply that we + -- don't have anything new to share with them? only send them + -- + + if remoteBase == db.profile.time then + local j = 1 -- index in foreign list + local n = getn(t) + local o = {} + for i,v in pairs(db.profile.changes) do -- for each timestamp in our list + if t and t[j] < v.time then + table.insert(o,v) + end + while j<n and t[j] <= v.time do j = j+1 end -- advance the foreign pointer past our current entry + end -- j>=n ? add because the remote hit end of road. lt? add because it's a missing stamp + print("Received request at timebase",remoteBase,"and returning:") + PrintTable(o) + else + print("Received request at differing timebase",remoteBase,db.profile.time) + end end end, @@ -101,12 +133,19 @@ if changeListener then changeListener:DataEvent() end - end, ["RequestCatchup"] = function(self) if not admin then - Send("TS", timestamp) -- todo: send privately to loot master + --local string = _g.tostring(timestamp) + --for i,v in pairs(db.profile.changes) do -- append all change timestamps + -- string = string .. "|" .. _g.tostring(v.time) + --end + local t = {db.profile.time} + for i,v in pairs(db.profile.changes) do -- append all change timestamps + table.insert(t,v.time) + end + Send("TS", t) -- todo: send privately to loot master else -- todo: admins talking to one another end