# HG changeset patch # User Nenue # Date 1471778341 14400 # Node ID 2a95f4010c5a1c04a26298100de57f49f8d90ac3 # Parent c416c9e6d2124eb921dc84625a831b3624cabff0 - initialize pet cache internally, reconcile later diff -r c416c9e6d212 -r 2a95f4010c5a SkeletonKey/ActionTemplates.lua --- a/SkeletonKey/ActionTemplates.lua Sun Aug 21 03:33:39 2016 -0400 +++ b/SkeletonKey/ActionTemplates.lua Sun Aug 21 07:19:01 2016 -0400 @@ -315,14 +315,33 @@ kb.UpdatePetInfo = function() local hasPetSpells, petType = HasPetSpells() - --kb.PetCache.specNum = GetSpecialization(nil, true) - --kb.PetCache.specID, kb.PetCache.specName = GetSpecializationInfo(petSpec, nil, true) - - kb.db.petSpellsDB = kb.db.petSpellsDB or {} - kb.db.petSpellsDB.subtext = kb.db.petSpellsDB.subtext or {} - kb.db.petSpellsDB.spell = kb.db.petSpellsDB.spell or {} - petSpellCache = kb.db.petSpellsDB.spell - petSubtextCache = kb.db.petSpellsDB.subtext + -- reconcile saved data if it becomes available + if kb.db then + kb.db.petSpellsDB = kb.db.petSpellsDB or {} + kb.db.petSpellsDB.subtext = kb.db.petSpellsDB.subtext or {} + kb.db.petSpellsDB.spell = kb.db.petSpellsDB.spell or {} + local spellCache = kb.db.petSpellsDB.spell + local subtextCache = kb.db.petSpellsDB.subtext + if petSpellCache then + for k,v in pairs(petSpellCache) do + if not spellCache[k] then + spellCache[k] = v + end + end + petSpellCache = spellCache + end + if petSubtextCache then + for k,v in pairs(petSubtextCache) do + if not subtextCache[k] then + subtextCache[k] = v + end + end + petSubtextCache = subtextCache + end + else + petSpellCache = {} + petSubtextCache = {} + end