Going mad.... [Strange AceDB-2.0 data updates] - WoWInterface
Thread Tools Display Modes
08-22-08, 04:57 AM   #1
Premium Member
Jayhawk's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 105
Going mad.... [Strange AceDB-2.0 data updates]

As I said in the title...I'm going mad. You may know I've written SkillsPlusFu, and have been happy with it, but recently (or rather for the past couple months) it's been behaving strangely. The behaviour concerns the Alchemy skill cooldowns.

I've got the following setup:

-- declare the database on account level
SkillsPlusFu:RegisterDefaults("account", {
                                  -- lists                                  
                                  cooldownSave = {},         -- cooldown info per character (middle part of list)
-- register the TRADE_SKILL_CLOSE event and intialise the toonSaveKey
function SkillsPlusFu:OnEnable()
    -- cooldown management

    -- variables
    toonSaveKey = GetCVar('realmName')..'|'..UnitName('player')
-- TRADE_SKILL_CLOSE event handler (stripped most Transmute spells)
-- loops spells and if it finds a transmute, write it and consider things done
function SkillsPlusFu:TRADE_SKILL_CLOSE()

    local cooldownItem = nil
    local cooldown = nil
	local numSkills = GetNumTradeSkills()
    local alchemyCooldown = false
	for i=1, numSkills do
		local itemName = GetTradeSkillInfo(i)		
        -- check alchemy cooldowns by spellID
        if alchemyCooldown == false  then
            if( itemName == GetSpellInfo(11479) or              -- Transmute: Iron to Gold
                ... [all other transmutes listed by spell ID]
                itemName == GetSpellInfo(53784)                 -- Transmute: Eternal Water to Fire
                ) then
                cooldownItem = L["COOLDOWN_TRANSMUTES"]
                cooldown = GetTradeSkillCooldown(i)
                if (cooldown == nil) then cooldown = 0 end      -- safety catch; should cooldown be removed (or wrong spell ID used
                -- self:Print('Found: '..itemName..format(cooldown)) 
                -- write alchemy cooldown information to the database
                alchemyCooldown = true
        -- check for tailoring and jewelcrafting cooldowns each with a specific cooldown
		if ( -- itemName == GetSpellInfo(18560) or              -- Mooncloth (cooldown removed in 2.4.3)
            itemName == GetSpellInfo(26751) or              -- Primal Mooncloth
            itemName == GetSpellInfo(31373) or              -- Spellcloth
            itemName == GetSpellInfo(36686) or              -- Shadowcloth
			itemName == GetSpellInfo(47280)) then           -- Brilliant Glass
            -- write the actual cooldown information to the database
-- the actual write to DB function, note the debugger
function SkillsPlusFu:WriteCooldownInfo(itemName,cooldown)
    -- general cooldown function
    if (cooldown == nil) then cooldown = 0 end
    if (self.db.account.cooldownSave[toonSaveKey] == nil) then
        self.db.account.cooldownSave[toonSaveKey] = {}
    if (self.db.account.cooldownSave[toonSaveKey][itemName] == nil) then
        self.db.account.cooldownSave[toonSaveKey][itemName] = {}
    self.db.account.cooldownSave[toonSaveKey][itemName].Cooldown = format(cooldown)
    self.db.account.cooldownSave[toonSaveKey][itemName].LastCheck = time()
    self.db.account.cooldownSave[toonSaveKey][itemName].IsReady = 0
    if self.db.account.cooldownSave[toonSaveKey][itemName].Hide == nil then 
      self.db.account.cooldownSave[toonSaveKey][itemName].Hide = false
    self:Print('Logged: '..toonSaveKey..' '..itemName..' '..format(self.db.account.cooldownSave[toonSaveKey][itemName].Cooldown))
So what happens that drives me crazy?
I have a transmuter and every time I do a transmute, the timer gets reset. I get the Printed debugger. I can see the timer is reset in the FuBar tooltip and from the menu (showing something like Alchemy (0/1)).

Now the strange thing happens. When I logoff and swap toons. The cooldown says it's ready in the FuBar tooltip and from the menu (showing something like Alchemy (1/1)).

Swaping again, I run a chance (doesn't always seem to happen which drives me even crazier) to see the previous character to have acquired a ready Transmute cooldown (even with Alchemy not part of their skills) This shows both in the FuBar tooltip and from the menu (showing something like Alchemy (2/2)).

If I go back to the Alchemist and open and close the Tradeskill-window the timer gets reset again. With a proper debugger messages.

Shutting down after a clean start, will show the SavedVariables file to have saved the cooldown as ready (but I still see no messages of the counter being reset to zero).

The tailor stuff in the second bit of code seems to work fine and each piece of cloth-cooldown is properly saved (although my tailor just acquired a Transmute cooldown).

Frankly, I can't see what's going on and it's driving me round the bend. Help would be much appreciated.
  Reply With Quote
08-31-08, 02:15 AM   #2
Premium Member
Jayhawk's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 105
Strangely it seems to work the first time the data is saved, but not after it's used a second time. I've also streamlined stuff a little and moved all the GetSpellInfo's to a table (thanks to Elkano for the hint), so all cooldown tradeskill spells now use the same function.

The really strange thing is that it seems to do a final update of the cooldown data after I close the the character by logging out. Debugger statements (on the save function) don't show up. When I log on to the next toon, I see that the Alchemy cooldown is reset. Again, without any debuggers showing up, and even without opening a trade window.

Last edited by Jayhawk : 08-31-08 at 02:18 AM.
  Reply With Quote
12-12-08, 02:24 AM   #3
Premium Member
Jayhawk's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 105
The problem hasn't gone away yet. Is there anyone with a suggestion why data erratically doesn't get saved to the SavedVariables file?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Going mad.... [Strange AceDB-2.0 data updates]

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off