This commit is contained in:
Cliencer
2026-09-28 00:20:07 +08:00
parent 4cc8371ab8
commit 4c01debee2
5 changed files with 170 additions and 56 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ PfExtend_Config_Template["About"]={
return {text="Cliencer(海蓝钢板)"}
end,
["Version"]=function ()
return {text="1.1.1"}
return {text="1.1.2"}
end,
["Github"]=function ()
return {text="https://github.com/Cliencer/pfExtend"}
+37 -27
View File
@@ -112,6 +112,7 @@ PFEXQuestHelper.QuestFilter = function(id)
}
if not quests[id] then ret.UNKNOWN = true return ret end
if type(quests[id]) ~= "table" then ret.UNKNOWN = true return ret end
if quests[id]["lvl"] then ret.lvl = quests[id]["lvl"] end
if quests[id]["min"] then ret.min = quests[id]["min"] end
@@ -222,6 +223,7 @@ end
PFEXQuestHelper.GetStartZones = function(id)
local ret = {}
if type(quests[id]) ~= "table" then return ret end
if quests[id]["start"] then
if quests[id]["start"]["U"] then
for _, unit in pairs(quests[id]["start"]["U"]) do
@@ -239,25 +241,30 @@ PFEXQuestHelper.GetStartZones = function(id)
end
if quests[id]["start"]["I"] then
for _, item in pairs(quests[id]["start"]["I"]) do --V,U,O,R
if items[item] then
if type(items[item]) == "table" then
for lootType, lootSources in pairs(items[item]) do
if lootType == "R" then
for id, chance in pairs(lootSources) do
if refloot[id] then
for refLootType, refLootSources in pairs(refloot[id]) do
for refId, _ in pairs(refLootSources) do
for _, v in ipairs(PFEXQuestHelper.ReadCoords(refId, refLootType)) do
table.insert(ret, v)
-- 第三方数据包可能混入非表条目,跳过而不是中断
if type(lootSources) == "table" then
if lootType == "R" then
for id, chance in pairs(lootSources) do
if type(refloot[id]) == "table" then
for refLootType, refLootSources in pairs(refloot[id]) do
if type(refLootSources) == "table" then
for refId, _ in pairs(refLootSources) do
for _, v in ipairs(PFEXQuestHelper.ReadCoords(refId, refLootType)) do
table.insert(ret, v)
end
end
end
end
end
end
end
end
if lootType == "V" or lootType == "U" or lootType == "O" then
for id, chance in pairs(lootSources) do
for _, v in ipairs(PFEXQuestHelper.ReadCoords(id, lootType)) do
table.insert(ret, v)
if lootType == "V" or lootType == "U" or lootType == "O" then
for id, chance in pairs(lootSources) do
for _, v in ipairs(PFEXQuestHelper.ReadCoords(id, lootType)) do
table.insert(ret, v)
end
end
end
end
@@ -276,21 +283,24 @@ PFEXQuestHelper.UpdateDatabase = function()
end
for questId, data in pairs(quests) do
local questInWhatZone = PFEXQuestHelper.GetStartZones(questId)
local multiNum = table.getn(questInWhatZone);
PfExtend_Database["QuestHelper"]["QuestZoneData"][questId] = questInWhatZone;
for _, zone in pairs(questInWhatZone) do
if PfExtend_Database["QuestHelper"]["ZoneQuestData"][zone] == nil then
PfExtend_Database["QuestHelper"]["ZoneQuestData"][zone] = {}
-- 跳过数据包中的损坏条目(非表数据)
if type(data) == "table" then
local questInWhatZone = PFEXQuestHelper.GetStartZones(questId)
local multiNum = table.getn(questInWhatZone);
PfExtend_Database["QuestHelper"]["QuestZoneData"][questId] = questInWhatZone;
for _, zone in pairs(questInWhatZone) do
if PfExtend_Database["QuestHelper"]["ZoneQuestData"][zone] == nil then
PfExtend_Database["QuestHelper"]["ZoneQuestData"][zone] = {}
end
PfExtend_Database["QuestHelper"]["ZoneQuestData"][zone][questId] = multiNum;
end
PfExtend_Database["QuestHelper"]["ZoneQuestData"][zone][questId] = multiNum;
end
if PfExtend_Database["QuestHelper"]["QuestAfter"][questId] == nil then PfExtend_Database["QuestHelper"]["QuestAfter"][questId] = {} end
if data["pre"] then
for _, pre in pairs(data["pre"]) do
if PfExtend_Database["QuestHelper"]["QuestAfter"][pre] == nil then PfExtend_Database["QuestHelper"]["QuestAfter"][pre] = {} end
if not table.contain(PfExtend_Database["QuestHelper"]["QuestAfter"][pre], questId) then
table.insert(PfExtend_Database["QuestHelper"]["QuestAfter"][pre], questId)
if PfExtend_Database["QuestHelper"]["QuestAfter"][questId] == nil then PfExtend_Database["QuestHelper"]["QuestAfter"][questId] = {} end
if data["pre"] then
for _, pre in pairs(data["pre"]) do
if PfExtend_Database["QuestHelper"]["QuestAfter"][pre] == nil then PfExtend_Database["QuestHelper"]["QuestAfter"][pre] = {} end
if not table.contain(PfExtend_Database["QuestHelper"]["QuestAfter"][pre], questId) then
table.insert(PfExtend_Database["QuestHelper"]["QuestAfter"][pre], questId)
end
end
end
end
+41 -27
View File
@@ -1,9 +1,16 @@
PfExtend_Database["ShowLoots"] = {
["LootData"] = {},
["itemQualityData"] = {},
["updated"] = false,
["version"] = nil
};
-- 仅在缺失时初始化,保留已存档的掉落库(否则每次登录都会触发全量重建)
if type(PfExtend_Database["ShowLoots"]) ~= "table" then
PfExtend_Database["ShowLoots"] = {};
end
if type(PfExtend_Database["ShowLoots"]["LootData"]) ~= "table" then
PfExtend_Database["ShowLoots"]["LootData"] = {};
end
if type(PfExtend_Database["ShowLoots"]["itemQualityData"]) ~= "table" then
PfExtend_Database["ShowLoots"]["itemQualityData"] = {};
end
if PfExtend_Database["ShowLoots"]["updated"] == nil then
PfExtend_Database["ShowLoots"]["updated"] = false;
end
PFEXShowLoots = {
LootListShown = {},
@@ -26,29 +33,36 @@ PFEXShowLoots.UpdateDatabase = function()
end
local db = { U = {}, O = {} }
for itemId, itemData in pairs(pfDB["items"]["data"]) do
for lootType, LootData in pairs(itemData) do
for from, probability in pairs(LootData) do
if probability > 0 then
if lootType == "U" or lootType == "O" then
if db[lootType] == nil then
db[lootType] = {};
end
if db[lootType][from] == nil then
db[lootType][from] = {};
end
-- 第三方数据包可能混入非表条目,跳过而不是中断整个重建
if type(itemData) == "table" then
for lootType, LootData in pairs(itemData) do
if type(LootData) == "table" then
for from, probability in pairs(LootData) do
if type(probability) == "number" and probability > 0 then
if lootType == "U" or lootType == "O" then
if db[lootType] == nil then
db[lootType] = {};
end
if db[lootType][from] == nil then
db[lootType][from] = {};
end
db[lootType][from][itemId] = probability;
elseif lootType == "R" then
if pfDB["refloot"]["data"][from] then
for refLootType, refLootData in pairs(pfDB["refloot"]["data"][from]) do
for refFrom, refProbability in pairs(refLootData) do
if db[refLootType] == nil then
db[refLootType] = {};
db[lootType][from][itemId] = probability;
elseif lootType == "R" then
if type(pfDB["refloot"]["data"][from]) == "table" then
for refLootType, refLootData in pairs(pfDB["refloot"]["data"][from]) do
if type(refLootData) == "table" then
for refFrom, refProbability in pairs(refLootData) do
if db[refLootType] == nil then
db[refLootType] = {};
end
if db[refLootType][refFrom] == nil then
db[refLootType][refFrom] = {};
end
db[refLootType][refFrom][itemId] = probability;
end
end
end
if db[refLootType][refFrom] == nil then
db[refLootType][refFrom] = {};
end
db[refLootType][refFrom][itemId] = probability;
end
end
end
+1 -1
View File
@@ -1,7 +1,7 @@
## Interface: 11200
## Title: |cff33ffccpf|cffffffffExtend
## Author: Cliencer
## Version: 1.1.1
## Version: 1.1.2
## Notes: Display all monster drops, query the task chain. This module is based on pfQuest. Command: /pfex
## Title-zhCN:|CFF33AAFF[辅助]|RpfQuest扩展
## Notes-zhCN: 显示怪物全部掉落,任务链查询|N命令:/pfex
+90
View File
@@ -0,0 +1,90 @@
# ShowLoots 防御修复验证: 含毒数据不再中断重建 + 存档不再被登录重置
import sys
from lupa import LuaRuntime
lua = LuaRuntime()
lua.execute('unpack = table.unpack')
lua.execute(r'''
-- ===== 模拟 WoW 环境 =====
DEFAULT_CHAT_FRAME = { msgs = {} }
DEFAULT_CHAT_FRAME.AddMessage = function(self, t) table.insert(self.msgs, t) end
pfExtend_Loc = setmetatable({}, { __index = function(t, k) return k end })
pfExtendCompat = { itemsuffix = ":0:0:0", mod = function(a,b) return a % b end }
pfMap = { tooltip = { SetScript = function() end },
GetColor = function() return 1, 1, 1 end,
GetMapID = function() return 1 end }
function CreateFrame() return { SetScript = function() end, Show = function() end, Hide = function() end } end
GetCurrentMapContinent = function() return 1 end
GetCurrentMapZone = function() return 1 end
GetTime = function() return 0 end
GetMouseFocus = function() return nil end
GetItemInfo = function() return nil end
UnitExists = function() return false end
UnitPlayerControlled = function() return false end
IsAltKeyDown = function() return false end
''')
lua.execute(r'''
IsControlKeyDown = function() return false end
GameTooltip = { IsShown = function() return false end, SetScript = function() end }
ITEM_QUALITY_COLORS = {}
pfBrowser_fav = nil
pfDatabase = { GetIDByName = function() return {} end }
PfExtend_Global = { ReadSetting = function() return true end,
sortKeyValueTable = function() return {} end }
-- 含毒物品数据: 覆盖报告中的布尔条目及各种边界
pfDB = {
items = {
data = {
[1] = { ["U"] = { [100] = 2.5 } }, -- 正常
[2] = true, -- 布尔物品条目
[3] = { ["U"] = true }, -- 布尔LootData (本次报错)
[4] = { ["U"] = { [100] = "bad" } }, -- 非数字掉率
[5] = { ["R"] = { [7] = 3 } }, -- 引用表(正常)
[6] = { ["R"] = { [8] = 1 } }, -- 引用表(目标损坏)
[7] = { ["U"] = { [100] = 0 } }, -- 0掉率应跳过
},
loc = {},
},
refloot = {
data = {
[7] = { ["U"] = { [200] = 1 } },
[8] = true, -- 布尔refloot
},
},
}
-- 预置存档, 验证加载时不再被清空
PfExtend_Database = { ShowLoots = {
LootData = { U = { [999] = { [42] = 1.5 } } },
itemQualityData = { [42] = 3 },
updated = true,
version = "sentinel",
} }
''')
lua.execute(open('modules/ShowLoots/main.lua', encoding='utf-8').read())
lua.execute(r'''
-- 测试1: 存档保持
sl = PfExtend_Database["ShowLoots"]
persist_ok = sl.version == "sentinel"
and sl.LootData.U[999][42] == 1.5
and sl.itemQualityData[42] == 3
and sl.updated == true
-- 测试2: 含毒数据重建
rebuild_ok, err = pcall(PFEXShowLoots.UpdateDatabase)
db = PfExtend_Database["ShowLoots"]["LootData"]
data_ok = rebuild_ok
and db.U[100][1] == 2.5 -- 正常条目保留
and db.U[200][5] == 3 -- 引用表展开保留
and db.U[100][4] == nil -- 非数字掉率跳过
and db.U[100][7] == nil -- 0掉率跳过
and db.U[100][3] == nil -- 布尔LootData条目整体跳过
''')
print('存档保持(登录不再重置):', lua.eval('persist_ok'))
print('重建未崩溃:', lua.eval('rebuild_ok'), lua.eval('err') or '')
print('数据正确性(好条目保留/坏条目跳过):', lua.eval('data_ok'))