Mercurial > wow > breuesk
changeset 94:2058d86778b4
Corrections on the receiver end of an incremental update.
author | John@Yosemite-PC |
---|---|
date | Sun, 22 Apr 2012 23:13:43 -0400 |
parents | df94161e6d7c |
children | 5df2c9cdb8c8 |
files | Comm.lua |
diffstat | 1 files changed, 15 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- 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