Fix: Resolve nil pairs error in Townsfolk initialization on custom servers

This commit is contained in:
Xurkon
2026-02-24 16:10:01 -06:00
parent 26bdefb46e
commit 7c99ce2a79
+16 -9
View File
@@ -6,9 +6,6 @@ local QuestieDB = QuestieLoader:ImportModule("QuestieDB")
---@type QuestieProfessions ---@type QuestieProfessions
local QuestieProfessions = QuestieLoader:ImportModule("QuestieProfessions") local QuestieProfessions = QuestieLoader:ImportModule("QuestieProfessions")
local _, playerClass = UnitClass("player")
local playerFaction = UnitFactionGroup("player")
local tinsert = tinsert local tinsert = tinsert
local sub, bitband, strlen = string.sub, bit.band, string.len local sub, bitband, strlen = string.sub, bit.band, string.len
@@ -289,7 +286,8 @@ function Townsfolk.PostBoot() -- post DB boot (use queries here)
or {5140,2928,8924,5173,2930,8923}, or {5140,2928,8924,5173,2930,8923},
["DRUID"] = {17034,17026,17035,17021,17038,17036,17037} ["DRUID"] = {17034,17026,17035,17021,17038,17036,17037}
} }
reagents = reagents[playerClass] local _, playerClass = UnitClass("player")
reagents = (playerClass and reagents[playerClass]) or {}
if Questie.IsSoD then if Questie.IsSoD then
table.insert(reagents, 212160) -- In SoD the Chronoboon Displacer is sold by reagent vendors table.insert(reagents, 212160) -- In SoD the Chronoboon Displacer is sold by reagent vendors
end end
@@ -316,14 +314,21 @@ end
function Townsfolk:BuildCharacterTownsfolk() function Townsfolk:BuildCharacterTownsfolk()
Questie.db.char.townsfolk = {} Questie.db.char.townsfolk = {}
Questie.db.char.vendorList = {} Questie.db.char.vendorList = {}
Questie.db.char.townsfolkClass = UnitClass("player")
local _, playerClass = UnitClass("player")
local playerFaction = UnitFactionGroup("player")
Questie.db.char.townsfolkClass = playerClass
for key, npcs in pairs(Questie.db.global.factionSpecificTownsfolk[playerFaction]) do if playerFaction and Questie.db.global.factionSpecificTownsfolk[playerFaction] then
Questie.db.char.townsfolk[key] = npcs for key, npcs in pairs(Questie.db.global.factionSpecificTownsfolk[playerFaction]) do
Questie.db.char.townsfolk[key] = npcs
end
end end
for key, npcs in pairs(Questie.db.global.classSpecificTownsfolk[playerClass]) do if Questie.db.global.classSpecificTownsfolk[playerClass] then
Questie.db.char.townsfolk[key] = npcs for key, npcs in pairs(Questie.db.global.classSpecificTownsfolk[playerClass]) do
Questie.db.char.townsfolk[key] = npcs
end
end end
end end
@@ -356,6 +361,7 @@ local function _UpdateFoodDrink()
end end
function Townsfolk:UpdatePlayerVendors() -- call on levelup function Townsfolk:UpdatePlayerVendors() -- call on levelup
local _, playerClass = UnitClass("player")
_UpdateFoodDrink() _UpdateFoodDrink()
if playerClass == "HUNTER" then if playerClass == "HUNTER" then
_UpdatePetFood() _UpdatePetFood()
@@ -366,6 +372,7 @@ function Townsfolk:UpdatePlayerVendors() -- call on levelup
end end
function Townsfolk:PopulateVendors(itemList, existingTable, restrictLevel) function Townsfolk:PopulateVendors(itemList, existingTable, restrictLevel)
local playerFaction = UnitFactionGroup("player")
local factionKey = playerFaction == "Alliance" and "A" or "H" local factionKey = playerFaction == "Alliance" and "A" or "H"
local tbl = existingTable or {} local tbl = existingTable or {}
-- Create a cache to minimize db calls -- Create a cache to minimize db calls