comparison Lists.lua @ 34:0e03db65c1fe

listBase -> lists for symmetry project-revision turned into a string so you can dev on repo
author John@Yosemite-PC
date Sun, 11 Mar 2012 23:27:02 -0400
parents d27c28e5f964
children ecd37523ae04
comparison
equal deleted inserted replaced
33:84f56de22631 34:0e03db65c1fe
80 function bsk:SelfDestruct() 80 function bsk:SelfDestruct()
81 bsk.lists = {} 81 bsk.lists = {}
82 bsk.persons = {} 82 bsk.persons = {}
83 bsk.db.profile.persons = {} 83 bsk.db.profile.persons = {}
84 bsk.db.profile.changes = {} 84 bsk.db.profile.changes = {}
85 bsk.db.profile.listBase = {} 85 bsk.db.profile.lists = {}
86 raidNameP = {} 86 raidNameP = {}
87 raidIdP = {} 87 raidIdP = {}
88 reserveIdP = {} 88 reserveIdP = {}
89 personName2id = {} 89 personName2id = {}
90 end 90 end
166 end 166 end
167 167
168 -- Change processing {{{ 168 -- Change processing {{{
169 function bsk:CreateWorkingStateFromChanges(changes) 169 function bsk:CreateWorkingStateFromChanges(changes)
170 local personsBase = self.db.profile.persons 170 local personsBase = self.db.profile.persons
171 local listBase = self.db.profile.listBase 171 local lists = self.db.profile.lists
172 172
173 -- copy the base to the working state 173 -- copy the base to the working state
174 wipe(bsk.lists) 174 wipe(bsk.lists)
175 wipe(bsk.persons) 175 wipe(bsk.persons)
176 wipe(personName2id) 176 wipe(personName2id)
177 177
178 bsk:tcopy(bsk.lists,listBase) 178 bsk:tcopy(bsk.lists,lists)
179 bsk:tcopy(bsk.persons,personsBase) 179 bsk:tcopy(bsk.persons,personsBase)
180 180
181 -- now just go through the changes list applying each 181 -- now just go through the changes list applying each
182 for i,v in ipairs(changes) do 182 for i,v in ipairs(changes) do
183 bsk:ProcessChange(v) 183 bsk:ProcessChange(v)
547 -- apply first half 547 -- apply first half
548 bsk:CreateWorkingStateFromChanges(before) 548 bsk:CreateWorkingStateFromChanges(before)
549 549
550 -- save this state permanently; trim the changes permanently 550 -- save this state permanently; trim the changes permanently
551 bsk:tcopy(bsk.db.profile.persons,bsk.persons) 551 bsk:tcopy(bsk.db.profile.persons,bsk.persons)
552 bsk:tcopy(bsk.db.profile.listBase,bsk.lists) 552 bsk:tcopy(bsk.db.profile.lists,bsk.lists)
553 while bsk.db.profile.changes ~= nil and bsk.db.profile.changes[1] ~= nil and bsk.db.profile.changes[1].time <= time do 553 while bsk.db.profile.changes ~= nil and bsk.db.profile.changes[1] ~= nil and bsk.db.profile.changes[1].time <= time do
554 table.remove(bsk.db.profile.changes,1) 554 table.remove(bsk.db.profile.changes,1)
555 end 555 end
556 556
557 -- using the trimmed list and the new bases, recreate the working state 557 -- using the trimmed list and the new bases, recreate the working state