mirror of
https://codeberg.org/Duvelcorp/MetaHunt.git
synced 2026-09-28 10:36:04 +00:00
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).
This commit is contained in:
@@ -650,58 +650,6 @@ function MTH_GetMerchantFoodsByDiet()
|
||||
return result;
|
||||
end
|
||||
|
||||
local function FOM_ItemQuality(itemIdOrLink)
|
||||
if (type(GetItemInfo) ~= "function" or itemIdOrLink == nil) then
|
||||
return nil;
|
||||
end
|
||||
local _, _, quality = GetItemInfo(itemIdOrLink);
|
||||
return quality;
|
||||
end
|
||||
|
||||
local function FOM_DebugLog(message)
|
||||
if (not (FOM_Config and FOM_Config.Debug)) then
|
||||
return;
|
||||
end
|
||||
local text = "[FOM] " .. tostring(message);
|
||||
if (MTH and MTH.Print) then
|
||||
MTH:Print(text, "debug");
|
||||
elseif (DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.AddMessage) then
|
||||
DEFAULT_CHAT_FRAME:AddMessage(text);
|
||||
end
|
||||
return;
|
||||
end
|
||||
|
||||
local function FOM_DebugLogMerchantFoods(sourceEvent)
|
||||
local merchantFoods = MTH_GetMerchantFoodsByDiet();
|
||||
local eventLabel = tostring(sourceEvent or "MERCHANT");
|
||||
if (merchantFoods == nil) then
|
||||
FOM_DebugLog(eventLabel .. ": no merchant data available.");
|
||||
return;
|
||||
end
|
||||
|
||||
local knownCount = table.getn(merchantFoods.items or {});
|
||||
local unknownCount = table.getn(merchantFoods.unknown or {});
|
||||
local merchantName = UnitName("npc") or UnitName("target") or "unknown";
|
||||
|
||||
FOM_DebugLog(eventLabel .. ": " .. tostring(merchantName) .. " | known foods=" .. tostring(knownCount) .. " | unknown items=" .. tostring(unknownCount));
|
||||
|
||||
if (type(merchantFoods.byDiet) == "table") then
|
||||
for dietName, foodRows in merchantFoods.byDiet do
|
||||
local dietCount = table.getn(foodRows or {});
|
||||
FOM_DebugLog("diet " .. tostring(dietName) .. ": " .. tostring(dietCount) .. " item(s)");
|
||||
for _, row in foodRows do
|
||||
FOM_DebugLog(" - [" .. tostring(row.id) .. "] " .. tostring(row.name) .. " (merchantIndex=" .. tostring(row.index) .. ")");
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (unknownCount > 0) then
|
||||
for _, row in merchantFoods.unknown do
|
||||
FOM_DebugLog("unknown food map: [" .. tostring(row.id) .. "] " .. tostring(row.name) .. " (merchantIndex=" .. tostring(row.index) .. ")");
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function MTH_FOM_FeedButton_OnClick()
|
||||
if (arg1 == "RightButton") then
|
||||
if (MTH_OpenOptions) then
|
||||
@@ -920,10 +868,6 @@ function FOM_OnEvent(event, arg1)
|
||||
end
|
||||
return;
|
||||
|
||||
elseif ( event == "MERCHANT_SHOW" or event == "MERCHANT_UPDATE" ) then
|
||||
FOM_DebugLogMerchantFoods(event);
|
||||
return;
|
||||
|
||||
elseif ( event == "PET_ATTACK_START" ) then
|
||||
|
||||
-- Set Flag
|
||||
@@ -950,7 +894,6 @@ function FOM_OnEvent(event, arg1)
|
||||
end
|
||||
if (foodID) then
|
||||
FOM_LastFood = GFWUtils.ItemLink(foodID);
|
||||
FOM_DebugLog("Manually fed "..FOM_LastFood);
|
||||
end
|
||||
end
|
||||
return;
|
||||
@@ -1269,31 +1212,24 @@ end
|
||||
function FOM_CanFeed()
|
||||
local petInfo = MTH_FOM_GetCorePetInfo();
|
||||
if ( not (petInfo and petInfo.liveExists) ) then
|
||||
FOM_DebugLog("Can't feed; pet doesn't exist.");
|
||||
return false;
|
||||
end
|
||||
if ( tonumber(petInfo.health) and tonumber(petInfo.health) <= 0 ) then
|
||||
FOM_DebugLog("Can't feed; pet is dead.");
|
||||
return false;
|
||||
end
|
||||
if ( UnitHealth("player") <= 0 ) then
|
||||
FOM_DebugLog("Can't feed; I'm dead.");
|
||||
return false;
|
||||
end
|
||||
if ( CastingBarFrameStatusBar:IsVisible() ) then
|
||||
FOM_DebugLog("Can't feed; casting a spell / tradeksill.");
|
||||
return false;
|
||||
end
|
||||
if ( UnitOnTaxi("player") ) then
|
||||
FOM_DebugLog("Can't feed; flying.");
|
||||
return false;
|
||||
end
|
||||
if ( FOM_State.InCombat ) or ( PlayerFrame.inCombat ) then
|
||||
FOM_DebugLog("Can't feed; in combat.");
|
||||
return false;
|
||||
end
|
||||
if ( LootFrame:IsVisible() ) then
|
||||
FOM_DebugLog("Shouldn't feed; loot window is open.");
|
||||
return false;
|
||||
end
|
||||
|
||||
@@ -1315,14 +1251,12 @@ function FOM_CanFeed()
|
||||
local name = GetSpellRecField(sid, "name")
|
||||
if name then
|
||||
if dontFeedNames[name] then
|
||||
FOM_DebugLog("Can't feed; buff detected: " .. name)
|
||||
return false
|
||||
end
|
||||
if UnitLevel("player") >= 40 then
|
||||
local lname = string.lower(name)
|
||||
for _, mountSub in FOM_MOUNT_NAME_SUBSTRINGS do
|
||||
if string.find(lname, mountSub) then
|
||||
FOM_DebugLog("Can't feed; mounted (" .. name .. ").")
|
||||
return false
|
||||
end
|
||||
end
|
||||
@@ -1351,7 +1285,6 @@ function FOM_CanFeed()
|
||||
if ( buff ~= nil) then
|
||||
for _, buffTexture in dontFeedBuffTextures do
|
||||
if ( buff == buffTexture ) then
|
||||
FOM_DebugLog("Can't feed; currently, eating, drinking, or feigning death.");
|
||||
return false;
|
||||
end
|
||||
end
|
||||
@@ -1364,7 +1297,6 @@ function FOM_CanFeed()
|
||||
msg = string.lower(msg);
|
||||
for _, mountName in FOM_MOUNT_NAME_SUBSTRINGS do
|
||||
if (string.find(msg, mountName)) then
|
||||
FOM_DebugLog("Can't feed; mounted.");
|
||||
return false;
|
||||
end
|
||||
end
|
||||
@@ -2387,17 +2319,6 @@ function FOM_Feed(aFood, options)
|
||||
foodLevel = selectedFoodLevel,
|
||||
})
|
||||
|
||||
FOM_DebugLog("Picked "..tostring(FOM_LastFood)
|
||||
.." id="..tostring(selectedId)
|
||||
.." foodLevel="..tostring(selectedFoodLevel)
|
||||
.." itemQuality="..tostring(FOM_ItemQuality(selectedId))
|
||||
.." (bag "..tostring(foodBag)..", slot "..tostring(foodItem)..")"
|
||||
.." reason="..tostring(FOM_LastChoiceReason));
|
||||
if (FOM_Config.Debug) then
|
||||
-- don't actually feed anything, just show what we would choose
|
||||
return false;
|
||||
end
|
||||
|
||||
-- Actually feed the item to the pet
|
||||
PickupContainerItem(foodBag, foodItem);
|
||||
if ( CursorHasItem() ) then
|
||||
@@ -2610,19 +2531,6 @@ function FOM_FlatFoodList()
|
||||
if (table.getn(foodList) == 0 and table.getn(overflowFoodList) > 0) then
|
||||
foodList = overflowFoodList;
|
||||
end
|
||||
if (FOM_Config and FOM_Config.Debug) then
|
||||
FOM_DebugLog("Candidate foods for pet level "..tostring(petLevel).." ("..tostring(table.getn(foodList)).." in diet):");
|
||||
for i = 1, table.getn(foodList) do
|
||||
local c = foodList[i];
|
||||
FOM_DebugLog(" ["..tostring(i).."] "..tostring(c.link)
|
||||
.." id="..tostring(c.itemId)
|
||||
.." qty="..tostring(c.count)
|
||||
.." foodLevel="..tostring(c.quality)
|
||||
.." itemQuality="..tostring(FOM_ItemQuality(c.itemId))
|
||||
.." known="..tostring(c.knownLevel)
|
||||
.." useful="..tostring(c.useful));
|
||||
end
|
||||
end
|
||||
return foodList;
|
||||
end
|
||||
|
||||
@@ -2786,12 +2694,10 @@ end
|
||||
function FOM_IsUsefulFood(itemID, quantity)
|
||||
local foodName = GetItemInfo(itemID);
|
||||
if (foodName == nil) then
|
||||
FOM_DebugLog("Can't get info for item ID "..itemID..", assuming it's OK to eat.");
|
||||
return false;
|
||||
end
|
||||
if (FOM_Cooking and FOM_Cooking[FOM_RealmPlayer] and FOM_Cooking[FOM_RealmPlayer][itemID]) then
|
||||
if (FOM_Cooking[FOM_RealmPlayer][itemID] >= FOM_Config.SaveForCookingLevel) then
|
||||
FOM_DebugLog("Skipping "..quantity.."x "..foodName.."; is good for cooking.");
|
||||
return true;
|
||||
end
|
||||
end
|
||||
@@ -2803,19 +2709,15 @@ function FOM_IsUsefulFood(itemID, quantity)
|
||||
FOM_Quantity[foodName] = FOM_Quantity[foodName] + quantity;
|
||||
end
|
||||
if (FOM_Quantity[foodName] > FOM_QuestFood[FOM_RealmPlayer][foodName]) then
|
||||
FOM_DebugLog("Not skipping "..quantity.."x "..foodName.."; is needed for quest, but we have more than enough.");
|
||||
return false;
|
||||
else
|
||||
FOM_DebugLog("Skipping "..quantity.."x "..foodName.."; is needed for quest.");
|
||||
return true;
|
||||
end
|
||||
end
|
||||
end
|
||||
if (FOM_Config.AvoidBonusFood and FOM_IsInDiet(itemID, FOM_DIET_BONUS)) then
|
||||
FOM_DebugLog("Skipping "..quantity.."x "..foodName.."; has bonus effect when eaten by player.");
|
||||
return true;
|
||||
end
|
||||
--FOM_DebugLog("Not skipping "..quantity.."x "..foodName.."; doesn't have other uses.");
|
||||
return false;
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user