Mercurial > wow > breuesk
changeset 86:22b37c800bc4
Database and comm versioning
author | John@Yosemite-PC |
---|---|
date | Sun, 15 Apr 2012 14:42:14 -0400 |
parents | f938ec08d5a6 |
children | 6035541e47dd |
files | Comm.lua Core.lua |
diffstat | 2 files changed, 40 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Comm.lua Sat Apr 14 10:12:06 2012 -0400 +++ b/Comm.lua Sun Apr 15 14:42:14 2012 -0400 @@ -25,7 +25,7 @@ local function SendMessage(str) --commlib:SendCommMessage("BSKADDON",str,"GUILD") - commlib:SendCommMessage("BSKADDON",str,"RAID") + commlib:SendCommMessage("BSKADDON"..commversion,str,"RAID") end local function Send(handler,message) @@ -90,8 +90,29 @@ Comm[packet[1]](Comm,packet[2],sender,isloop) end +alertlist = {} +local function OnOlderCommReceived(prefix, message, distribution, sender) + if not alertlist[sender] then + printf("Received communication from %s, who is using an older version of the addon; ignoring",sender) + alertlist[sender]=true + end +end + +local function OnNewerCommReceived(prefix, message, distribution, sender) + if not alertlist[sender] then + printf("Received communication from %s, who is using a newer version of the addon; ignoring",sender) + alertlist[sender]=true + end +end + function InitializeComm() - commlib:RegisterComm("BSKADDON",OnCommReceived) + for i = 0,commversion-1 do + commlib:RegisterComm("BSKADDON"..i,OnOlderCommReceived) + end + commlib:RegisterComm("BSKADDON"..commversion,OnCommReceived) + for i = commversion+1,commversion+5 do -- some sensible number + commlib:RegisterComm("BSKADDON"..i,OnNewerCommReceived) + end end function DeinitializeComm()
--- a/Core.lua Sat Apr 14 10:12:06 2012 -0400 +++ b/Core.lua Sun Apr 15 14:42:14 2012 -0400 @@ -6,7 +6,7 @@ -- (*) all actions should reference the player list rather than player names -- (?) player entries should persist as long as any list or change references -- (*) lists store number slots rather than flat indexing --- ( ) database and comm versioning +-- (*) database and comm versioning -- (_) limited communication - everyone trusts the loot master -- (*) single user + admin gui (manual suicides) -- (*) single user + admin gui (master loot) @@ -38,6 +38,9 @@ -- 4) table.remove() works ok if reverse iterating, terrible at anything else -- 5) pairs() does not have a guaranteed iteration order +dbversion = 1 +commversion = 1 + function OnInitialize() debug = true @@ -49,6 +52,9 @@ --optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("bsk", "bsk") admin = db.profile.admin + if not db.profile.dbversion or db.profile.dbversion < dbversion then + UpgradeDB() + end local HandlePassThrough = function(...) HandleCommand(...) end bsk:RegisterChatCommand("bsk", HandlePassThrough) @@ -209,3 +215,13 @@ } } +function UpgradeDB() + local mydbver = db.profile.dbversion or 0 + + if mydbver == 0 then -- difference between 0 and 1 is whether this field is present + db.profile.dbversion = 1 + mydbver = 1 + end + + +end