local VERSION_8_3 = 6 local POSTING_HISTORY_DB_VERSION = 1 local VENDOR_PRICE_CACHE_DB_VERSION = 1 function Auctionator.Variables.Initialize() Auctionator.Variables.InitializeSavedState() Auctionator.Config.InitializeData() Auctionator.Config.InitializeFrames() Auctionator.State.CurrentVersion = GetAddOnMetadata("Auctionator", "Version") Auctionator.Variables.InitializeDatabase() Auctionator.Variables.InitializeShoppingLists() Auctionator.Variables.InitializePostingHistory() Auctionator.Variables.InitializeVendorPriceCache() Auctionator.State.Loaded = true end function Auctionator.Variables.InitializeSavedState() if AUCTIONATOR_SAVEDVARS == nil then AUCTIONATOR_SAVEDVARS = {} end Auctionator.SavedState = AUCTIONATOR_SAVEDVARS end -- Attempt to import from other connected realms (this may happen if another -- realm was connected or the databases are not currently shared) -- -- Assumes rootRealm has no active database local function ImportFromConnectedRealm(rootRealm) local connections = GetAutoCompleteRealms() if #connections == 0 then return false end for _, altRealm in ipairs(connections) do if AUCTIONATOR_PRICE_DATABASE[altRealm] ~= nil then AUCTIONATOR_PRICE_DATABASE[rootRealm] = AUCTIONATOR_PRICE_DATABASE[altRealm] -- Remove old database (no longer needed) AUCTIONATOR_PRICE_DATABASE[altRealm] = nil return true end end return false end function Auctionator.Variables.InitializeDatabase() Auctionator.Debug.Message("Auctionator.Database.Initialize()") -- Auctionator.Utilities.TablePrint(AUCTIONATOR_PRICE_DATABASE, "AUCTIONATOR_PRICE_DATABASE") -- First time users need the price database initialized if AUCTIONATOR_PRICE_DATABASE == nil then AUCTIONATOR_PRICE_DATABASE = { ["__dbversion"] = VERSION_8_3 } end -- If we changed how we record item info we need to reset the DB if AUCTIONATOR_PRICE_DATABASE["__dbversion"] ~= VERSION_8_3 then AUCTIONATOR_PRICE_DATABASE = { ["__dbversion"] = VERSION_8_3 } end local realm = Auctionator.Variables.GetConnectedRealmRoot() -- Check for current realm and initialize if not present if AUCTIONATOR_PRICE_DATABASE[realm] == nil then if not ImportFromConnectedRealm(realm) then AUCTIONATOR_PRICE_DATABASE[realm] = {} end end Auctionator.Database = CreateAndInitFromMixin(Auctionator.DatabaseMixin, AUCTIONATOR_PRICE_DATABASE[realm]) Auctionator.Database:Prune() end function Auctionator.Variables.InitializePostingHistory() Auctionator.Debug.Message("Auctionator.Variables.InitializePostingHistory()") if AUCTIONATOR_POSTING_HISTORY == nil or AUCTIONATOR_POSTING_HISTORY["__dbversion"] ~= POSTING_HISTORY_DB_VERSION then AUCTIONATOR_POSTING_HISTORY = { ["__dbversion"] = POSTING_HISTORY_DB_VERSION } end Auctionator.PostingHistory = CreateAndInitFromMixin(Auctionator.PostingHistoryMixin, AUCTIONATOR_POSTING_HISTORY) end function Auctionator.Variables.InitializeShoppingLists() if AUCTIONATOR_SHOPPING_LISTS == nil then AUCTIONATOR_SHOPPING_LISTS = {} end Auctionator.ShoppingLists.Lists = AUCTIONATOR_SHOPPING_LISTS Auctionator.ShoppingLists.Prune() Auctionator.ShoppingLists.Sort() AUCTIONATOR_SHOPPING_LISTS = Auctionator.ShoppingLists.Lists AUCTIONATOR_RECENT_SEARCHES = AUCTIONATOR_RECENT_SEARCHES or {} end function Auctionator.Variables.InitializeVendorPriceCache() Auctionator.Debug.Message("Auctionator.Variables.InitializeVendorPriceCache()") if AUCTIONATOR_VENDOR_PRICE_CACHE == nil or AUCTIONATOR_VENDOR_PRICE_CACHE["__dbversion"] ~= VENDOR_PRICE_CACHE_DB_VERSION then AUCTIONATOR_VENDOR_PRICE_CACHE = { ["__dbversion"] = VENDOR_PRICE_CACHE_DB_VERSION } end end