changeset 103:d3ea0ab1428d

Bad commit, ignore. Just want a (failed) path to be on record.
author John@Doomsday
date Thu, 03 May 2012 09:05:40 -0400
parents 21567b74fcc7
children 9aa2dcbbdc87
files Admin.lua
diffstat 1 files changed, 46 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Admin.lua	Thu May 03 09:05:24 2012 -0400
+++ b/Admin.lua	Thu May 03 09:05:40 2012 -0400
@@ -33,6 +33,11 @@
         end
     end
 
+    if me == "Breuemama" then -- todo: strictly debugging ...
+        newAdminList[me] = true
+        newAdminList["Breue"] = true
+    end
+
     if _G.next(adminList) ~= nil then -- had old admins. don't want to spam on initial load
         -- diff new vs old
         for a in pairs(adminList) do
@@ -48,7 +53,7 @@
     end
     adminList = newAdminList
 
-    if adminList[_G.UnitName("player")] then -- I'm an admin!
+    if adminList[me] then -- I'm an admin!
         admin = true
         bsk.db.profile.admin = true
         RegisterAdminChannels()
@@ -63,11 +68,13 @@
     if not admin then return end
 
     local rs = remoteAdminStatusTable
+    local events = {} -- record all timestamps seen in this update
     for i,_ in pairs(adminList) do -- update each admin's entry in your own DB
 
         -- grab the db copy and the incoming copy for that admin
-        local dbs = db.profile.adminStatus[i] or {}
-        local ics = packet[i] or {}
+        if not db.profile.adminStatus then db.profile.adminStatus = {} end
+        local dbs = db.profile.adminStatus[i] or {base=0, changes={}}
+        local ics = rs[i] or {base=0, changes={}}
 
         -- figure out which is better and keep that one
         -- winning criteria:
@@ -83,12 +90,44 @@
             db.profile.adminStatus[i] = ics
         end
     end
+
+    local rss = rs[sender]
+
+    -- now figure out what I'm missing - and ask for it!
+
+    -- construct a hash table of all entries that the sender has / should have
+    local entries = {}
+    for i,v in pairs(rs) do
+        if v.changes then 
+            for j,k in pairs(v.changes) do
+                entries[k.time] = true
+            end
+        end
+    end
+    -- now go back and scrub my own keys from that list
+    for i,v in ipairs(db.profile.changes) do
+        entries[v.time] = nil
+    end
+    -- what's left is what I need to ask for
+    local request = {}
+    for i,v in pairs(entries) do
+        if v then table.insert(request,i) end
+    end
+    table.sort(request)
+    Comm:RequestSpecificChanges(request,sender)
+
+    for
+        -- specifically leaving this broken. note to self.
+        -- this still isn't good enough. it doesn't communicate an admin's
+        -- present working state. like if they had put in new changes since
+        -- loading up. or learned of some changes to fill in an old gap
 end
 
 function InitializeAdmin()
     if not event then
         _G.error("BSK: Improper order of initialization")
     end
+    me = _G.UnitName("player")
 
     if admin then -- if at last login I was an admin ...
 
@@ -100,7 +139,6 @@
         tcopy(onloadAdminStatus,db.profile.adminStatus)
 
         -- update our own entry - safe because comms shouldn't have happened yet
-        me = _G.UnitName("player")
         if not onloadAdminStatus then onloadAdminStatus = {} end
         if not onloadAdminStatus[me] then onloadAdminStatus[me] = {} end
         onloadAdminStatus[me].base = db.profile.time or 0
@@ -114,9 +152,12 @@
         db.profile.adminStatus = nil
     end
 
-    
     event:RegisterEvent("GUILD_ROSTER_UPDATE",GuildRosterUpdate)
     _G.GuildRoster() -- will eventually force the event to fire
+
+    if me == "Breuemama" then -- debugging only
+        GuildRosterUpdate()
+    end
 end