fix: force learner on when base db is missing

This commit is contained in:
Xurkon
2026-06-05 20:23:29 -05:00
parent a0409eef8c
commit 3eda8d01ed
5 changed files with 75 additions and 5 deletions
@@ -63,6 +63,22 @@ local function ApplyLearnerMode()
end
end
local function GetLearnerRuntimeMode()
local QuestieLearner = QuestieLoader:ImportModule("QuestieLearner")
if QuestieLearner and QuestieLearner.GetDataSourceMode then
return QuestieLearner:GetDataSourceMode()
end
return (Questie.dbLearner.global and Questie.dbLearner.global.settings and Questie.dbLearner.global.settings.dataSourceMode) or "auto"
end
local function IsLearnerRuntimeEnabled()
local QuestieLearner = QuestieLoader:ImportModule("QuestieLearner")
if QuestieLearner and QuestieLearner.IsEnabled then
return QuestieLearner:IsEnabled()
end
return Questie.dbLearner.global and Questie.dbLearner.global.settings and Questie.dbLearner.global.settings.enabled
end
-----------------------------------------------------------------------
-- Export Dialog
-----------------------------------------------------------------------
@@ -225,8 +241,8 @@ function QuestieOptions.tabs.database:Initialize()
type = "toggle",
order = 2.05,
name = function() return l10n("Enable Learner Recording") end,
desc = function() return l10n("Record live learner data. Disable this to stop recording and live learner injection.") end,
get = function() return Questie.dbLearner.global and Questie.dbLearner.global.settings and Questie.dbLearner.global.settings.enabled end,
desc = function() return l10n("Record live learner data. Disable this to stop recording and live learner injection. Learner will still auto-enable if the static DB is missing.") end,
get = function() return IsLearnerRuntimeEnabled() end,
set = function(_, v)
if Questie.dbLearner.global and Questie.dbLearner.global.settings then
Questie.dbLearner.global.settings.enabled = v
@@ -246,9 +262,7 @@ function QuestieOptions.tabs.database:Initialize()
static = l10n("Static Only"),
none = l10n("Neither (base DB only)"),
},
get = function()
return (Questie.dbLearner.global and Questie.dbLearner.global.settings and Questie.dbLearner.global.settings.dataSourceMode) or "auto"
end,
get = function() return GetLearnerRuntimeMode() end,
set = function(_, v)
if Questie.dbLearner.global and Questie.dbLearner.global.settings then
Questie.dbLearner.global.settings.dataSourceMode = v
+13
View File
@@ -508,6 +508,12 @@ end
function QuestieInit:LoadDatabase(key)
local function MarkBaseDatabaseMissing()
QuestieDB.baseDatabaseMissing = true
QuestieDB.baseDatabaseMissingKeys = QuestieDB.baseDatabaseMissingKeys or {}
QuestieDB.baseDatabaseMissingKeys[key] = true
end
if type(QuestieDB[key]) == "string" then
-- Fix #6: `loadstring` at LOAD TIME is safe, but calling it here during
-- event-driven runtime taints any tables produced on WotLK/Era clients.
@@ -530,6 +536,7 @@ function QuestieInit:LoadDatabase(key)
"[DBDiag] LEGACY DB ('" .. key .. "' is string) on modern client. "
.. "Runtime loadstring() would taint this data. "
.. "Please reinstall the Questie-X-WotLKDB addon in split-file format.")
MarkBaseDatabaseMissing()
QuestieDB[key] = {}
return
end
@@ -543,16 +550,19 @@ function QuestieInit:LoadDatabase(key)
QuestieDB[key] = result
else
Questie:Debug(Questie.DEBUG_DEVELOP, "[DBDiag] ERROR executing('" .. key .. "'): " .. tostring(result))
MarkBaseDatabaseMissing()
QuestieDB[key] = nil
end
else
Questie:Debug(Questie.DEBUG_DEVELOP, "[DBDiag] ERROR loadstring('" .. key .. "'): " .. tostring(loadErr) .. " | len=" .. string.len(QuestieDB[key] or ""))
MarkBaseDatabaseMissing()
QuestieDB[key] = nil
end
elseif type(QuestieDB[key]) == "table" then
Questie:Debug(Questie.DEBUG_DEVELOP, "[LoadDatabase] '" .. key .. "' already a table (split-file format), skipping loadstring")
else
Questie:Debug(Questie.DEBUG_DEVELOP, "Database is missing, this is likely do to era vs tbc: ", key)
MarkBaseDatabaseMissing()
end
if not QuestieDB[key] then
QuestieDB[key] = {}
@@ -566,6 +576,9 @@ function QuestieInit:LoadBaseDB()
-- Pointer compilation will look at npcDataOverrides etc, which are populated by plugins.
-- Base tables (Classic) are loaded here.
QuestieDB.baseDatabaseMissing = false
QuestieDB.baseDatabaseMissingKeys = {}
QuestieInit:LoadDatabase("npcData")
QuestieInit:LoadDatabase("objectData")
QuestieInit:LoadDatabase("questData")
+13
View File
@@ -51,7 +51,17 @@ local function HasAscensionQuestObjectiveData(questId)
return IsAscensionProtected("QUEST", questId, 10)
end
local function IsBaseDatabaseMissing()
return QuestieDB
and QuestieDB.IsBaseDatabaseMissing
and QuestieDB:IsBaseDatabaseMissing()
end
local function GetDataSourceMode()
if IsBaseDatabaseMissing() then
return "learner"
end
local settings = Questie
and Questie.dbLearner
and Questie.dbLearner.global
@@ -470,6 +480,9 @@ end
function QuestieLearner:IsEnabled()
if not EnsureLearnedData() then return false end
if IsBaseDatabaseMissing() then
return true
end
return Questie.dbLearner.global.settings.enabled
end