Files
DuvelCorp 060fc555fe Unify SavedVariables into two clean roots with one-time migration
Collapse all legacy/scattered SavedVariables from absorbed standalone
addons (FeedOMatic, ZHunter/zButtons, SmartAmmo, AutoQuest, AntiDaze,
AutoStrip, MinimapButton) into two persisted globals with clean per-module
nesting under .modules.<id>.

Migration engine (api/savedvariables.lua):
- MTH_SV_EnsureSchema() with schemaVersion gate, idempotent + non-destructive
- Per-module migrators map old locations -> canonical nested stores
- Driven by an ADDON_LOADED("MetaHunt") handler so it runs only AFTER WoW
  loads the real SavedVariables (fixes announce-every-session bug that ran
  the migration on empty pre-load defaults)
- One-time player-facing chat announce, gated on real legacy data present

Framework/config:
- core-framework InitSavedVariables no longer runs migration at file-load;
  unconditionally strips account-root module aliases
- config.lua stops re-creating root[module] aliases (was duplicating data
  onto disk); canonical store stays under .modules.<id>

Modules:
- feedomatic: bind FOM_* globals as runtime aliases into nested store,
  drop persisted duplicates and .legacy blob
- zhunter: ZHunterMod_Saved re-pointed at .modules.zhunter
- smartammo/autoquest/antidaze/autostrip/minimapbutton read nested store

TOC trimmed to MTH_SavedVariables + MTH_CharSavedVariables only.
Profiles unchanged (already snapshot/apply the nested .modules structure).

Also includes pet-scan refinements: canonical pet key derivation and
level-independent pet signature (schema v3).
2026-09-09 22:52:48 +02:00

62 lines
1.6 KiB
Lua

------------------------------------------------------
-- MetaHunt Configuration System
------------------------------------------------------
-- Global config management for modules
MTH.config = {}
local function MTH_ConfigEnsureStore(module_name)
if type(module_name) ~= "string" or module_name == "" then
module_name = "core"
end
local root = _G and _G.MTH_SavedVariables or MTH_SavedVariables
if type(root) ~= "table" then
if MTH and MTH.InitSavedVariables then
MTH:InitSavedVariables()
end
root = _G and _G.MTH_SavedVariables or MTH_SavedVariables
end
if type(root) ~= "table" then
root = { modules = {} }
if _G then
_G.MTH_SavedVariables = root
end
MTH_SavedVariables = root
end
if type(root.modules) ~= "table" then
root.modules = {}
end
if type(root.modules[module_name]) ~= "table" then
local legacy = root[module_name]
if type(legacy) ~= "table" then
legacy = {}
end
root.modules[module_name] = legacy
end
-- NOTE: we intentionally do NOT mirror root[module_name] = root.modules[module_name].
-- That old alias made WoW serialize a full DUPLICATE of every module store at the
-- account root on disk. The canonical store is root.modules[module_name] only.
root[module_name] = nil
MTH_SavedVariables = root
return root.modules[module_name]
end
function MTH:GetConfig(module_name, key, default)
local store = MTH_ConfigEnsureStore(module_name)
local value = store[key]
if value == nil then
return default
end
return value
end
function MTH:SetConfig(module_name, key, value)
local store = MTH_ConfigEnsureStore(module_name)
store[key] = value
end