2 Commits

Author SHA1 Message Date
DuvelCorp 9fc2f91834 Merge 2.0 release into master 2026-09-15 08:42:02 +02:00
Duvelcorp fd9618f184 Merge pull request '2.0' (#1) from 2.0 into master
Reviewed-on: https://codeberg.org/Duvelcorp/MetaHunt/pulls/1
2026-09-14 22:58:25 +02:00
3 changed files with 14 additions and 57 deletions
+2 -2
View File
@@ -30,8 +30,8 @@ MTH_FEED_TRACE = false
local function MTH_FEED_Trace(message) local function MTH_FEED_Trace(message)
if not MTH_FEED_TRACE then return end if not MTH_FEED_TRACE then return end
if MTH_DebugFrame and type(MTH_DebugFrame.AddInfo) == "function" then if type(DEFAULT_CHAT_FRAME) == "table" and DEFAULT_CHAT_FRAME.AddMessage then
MTH_DebugFrame:AddInfo("[MTH-FeedTrack] " .. tostring(message)) DEFAULT_CHAT_FRAME:AddMessage("|cff88aaff[MTH-FeedTrack]|r " .. tostring(message))
end end
end end
+9 -42
View File
@@ -2138,45 +2138,16 @@ local function MTH_PETS_SelectPetIdBySnapshot(store, snapshot, previousPetId)
if snapshot.signature and snapshot.signature ~= "" then if snapshot.signature and snapshot.signature ~= "" then
local list = store.signatureIndex[snapshot.signature] local list = store.signatureIndex[snapshot.signature]
if type(list) == "table" then if type(list) == "table" then
local liveIds = {} local count = 0
local candidateId = nil
for _, listedId in pairs(list) do for _, listedId in pairs(list) do
if listedId and store.activeById[tostring(listedId)] then if listedId and store.activeById[listedId] then
table.insert(liveIds, tostring(listedId)) count = count + 1
candidateId = listedId
end end
end end
local liveCount = table.getn(liveIds) if count == 1 then
if liveCount == 1 then return candidateId
return liveIds[1]
elseif liveCount > 1 then
-- Several records share this name+family (earlier fragmentation, or two
-- pets with the same name). Reuse the best existing match instead of
-- minting yet another empty shell that only worsens the fragmentation:
-- require a level match, then prefer loyalty match and records that
-- already carry tame/spellbook history, then most recently seen.
local snapLevel = tonumber(snapshot.level)
local snapLoyalty = tonumber(snapshot.loyaltyLevel)
local bestId = nil
local bestScore = -1
local bestSeen = -1
for i = 1, liveCount do
local rowId = liveIds[i]
local row = store.activeById[rowId]
if type(row) == "table" and snapLevel and tonumber(row.level) == snapLevel then
local score = 0
if snapLoyalty and tonumber(row.loyaltyLevel) == snapLoyalty then score = score + 2 end
if MTH_PETS_RowHasAnyTameMetadata(row) then score = score + 1 end
if type(row.petSpellbook) == "table" then score = score + 1 end
local seen = tonumber(row.lastSeen) or tonumber(row.lastUpdated) or 0
if score > bestScore or (score == bestScore and seen > bestSeen) then
bestScore = score
bestSeen = seen
bestId = rowId
end
end
end
if bestId then
return bestId
end
end end
end end
end end
@@ -2393,14 +2364,10 @@ local function MTH_PETS_RecordStableSlot(pets, slot, raw1, raw2, raw3, raw4, raw
local snapshotGuid = snapshot and snapshot.guid or nil local snapshotGuid = snapshot and snapshot.guid or nil
local signatureMatches = (existingSignature and snapshotSignature and existingSignature == snapshotSignature) and true or false local signatureMatches = (existingSignature and snapshotSignature and existingSignature == snapshotSignature) and true or false
local guidMatches = (existingGuid and snapshotGuid and existingGuid ~= "" and existingGuid == snapshotGuid) and true or false local guidMatches = (existingGuid and snapshotGuid and existingGuid ~= "" and existingGuid == snapshotGuid) and true or false
-- An empty shell must not lock the slot: a richer same-signature record may
-- exist that we should re-adopt instead (self-heals earlier fragmentation).
local existingHasData = MTH_PETS_RowHasAnyTameMetadata(existingRow)
or type(existingRow.petSpellbook) == "table" or existingRow.petNumber ~= nil
if guidMatches or (signatureMatches and existingHasData) then if signatureMatches or guidMatches then
petId = existingId petId = existingId
elseif not signatureMatches then else
MTH_PETS_LogConsistency("RecordStableSlot remapping stale slot=" .. tostring(slotNumber) MTH_PETS_LogConsistency("RecordStableSlot remapping stale slot=" .. tostring(slotNumber)
.. " existingId=" .. tostring(existingId) .. " existingId=" .. tostring(existingId)
.. " existingSignature='" .. tostring(existingSignature or "") .. "'" .. " existingSignature='" .. tostring(existingSignature or "") .. "'"
+3 -13
View File
@@ -2483,20 +2483,10 @@ function FOM_FlatFoodList()
local isExceptionReject = false; local isExceptionReject = false;
local isLevelOverrideReject = not FOM_IsItemPetLevelCompatible(itemID, petLevel); local isLevelOverrideReject = not FOM_IsItemPetLevelCompatible(itemID, petLevel);
local isQuarantineReject = FOM_IsQuarantined(itemID, petLevel, familyKey); local isQuarantineReject = FOM_IsQuarantined(itemID, petLevel, familyKey);
-- A food whose known level is below the pet's minimum is refused by the
-- server ("not high enough"); skip it up front so FOM never keeps
-- re-feeding a too-low stack just to free a bag slot.
local isLevelRuleReject = false;
if (petLevel > 0 and tonumber(foodLevel) ~= nil and type(MTH_FEED_GetDerivedMinFoodLevel) == "function") then
local minFoodLevel = MTH_FEED_GetDerivedMinFoodLevel(petLevel);
if (minFoodLevel ~= nil and tonumber(foodLevel) < minFoodLevel) then
isLevelRuleReject = true;
end
end
if (isExceptionReject) then if (isExceptionReject) then
rejectedByException = rejectedByException + 1; rejectedByException = rejectedByException + 1;
end end
if (isLevelOverrideReject or isLevelRuleReject) then if (isLevelOverrideReject) then
rejectedByLevelOverride = rejectedByLevelOverride + 1; rejectedByLevelOverride = rejectedByLevelOverride + 1;
end end
if (isQuarantineReject) then if (isQuarantineReject) then
@@ -2510,7 +2500,7 @@ function FOM_FlatFoodList()
unknownLevelCandidates = unknownLevelCandidates + 1; unknownLevelCandidates = unknownLevelCandidates + 1;
end end
if (isCompatible and not isExceptionReject and not isLevelOverrideReject and not isQuarantineReject and not isLevelRuleReject) then if (isCompatible and not isExceptionReject and not isLevelOverrideReject and not isQuarantineReject) then
compatibleCount = compatibleCount + 1; compatibleCount = compatibleCount + 1;
local foodQuality = tonumber(foodLevel); local foodQuality = tonumber(foodLevel);
if (foodQuality == nil) then if (foodQuality == nil) then
@@ -2521,7 +2511,7 @@ function FOM_FlatFoodList()
end end
end end
table.insert(foodList, {bag=bagNum, slot=itemNum, link=itemLink, itemId=itemID, count=itemCount, quality=foodQuality, useful=isUseful, temp=FOM_IsTemporaryFood(itemLink), knownLevel=hasKnownLevel}); table.insert(foodList, {bag=bagNum, slot=itemNum, link=itemLink, itemId=itemID, count=itemCount, quality=foodQuality, useful=isUseful, temp=FOM_IsTemporaryFood(itemLink), knownLevel=hasKnownLevel});
elseif (isAbovePreferredLevel and not isExceptionReject and not isLevelOverrideReject and not isQuarantineReject and not isLevelRuleReject) then elseif (isAbovePreferredLevel and not isExceptionReject and not isLevelOverrideReject and not isQuarantineReject) then
overflowCompatibleCount = overflowCompatibleCount + 1; overflowCompatibleCount = overflowCompatibleCount + 1;
local overflowQuality = tonumber(foodLevel); local overflowQuality = tonumber(foodLevel);
if (overflowQuality == nil) then if (overflowQuality == nil) then