# HG changeset patch # User John@Yosemite-PC # Date 1335150823 14400 # Node ID 2058d86778b4009bd125cea1a4e1218bbfb496da # Parent df94161e6d7cc234cdd757909b1c7cc59fb9e19f Corrections on the receiver end of an incremental update. diff -r df94161e6d7c -r 2058d86778b4 Comm.lua --- a/Comm.lua Sun Apr 22 17:12:39 2012 -0400 +++ b/Comm.lua Sun Apr 22 23:13:43 2012 -0400 @@ -85,10 +85,6 @@ if masterLooterIsMe and admin then -- only non-admins will send this message, send them the present -- 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 t = packet local remoteBase = table.remove(t,1) @@ -145,18 +141,24 @@ if no == 0 then db.profile.changes = c else - while op <= no and cp <= nc do - if c[cp].time == old[op].time then + while op <= no or cp <= nc do -- lists are pre-sorted. insertion merge them + if cp > nc then -- inelegant + table.insert(new,old[op]) + op = op + 1 + elseif op > no then + table.insert(new,c[cp]) + cp = cp + 1 + elseif c[cp].time < old[op].time then + table.insert(new,c[cp]) + cp = cp + 1 + elseif c[cp].time > old[op].time then + table.insert(new,old[op]) + op = op + 1 + else error("Bad update received from ",sender) end - if c[cp].time < old[op].time then - table.insert(new,c[cp]) - cp = cp + 1 - else - table.inert(new,old[cp]) - op = op + 1 - end end + print("Updating changes - ",getn(new), "entries") db.profile.changes = new end