mirror of
https://github.com/rivi-s/pfQuest-turtle.git
synced 2026-11-15 23:50:35 +00:00
Only the root-indexes of each database are now patched. This should speed up the loading procedure and make it easier to browse through the lua database files.
86 lines
2.6 KiB
Lua
86 lines
2.6 KiB
Lua
local loc = GetLocale()
|
|
local dbs = { "items", "quests", "quests-itemreq", "objects", "units", "zones", "professions", "areatrigger", "refloot" }
|
|
local noloc = { "items", "quests", "objects", "units" }
|
|
|
|
-- Patch databases to merge TurtleWoW data
|
|
local function patchtable(base, diff)
|
|
for k, v in pairs(diff) do
|
|
if type(v) == "string" and v == "_" then
|
|
base[k] = nil
|
|
else
|
|
base[k] = v
|
|
end
|
|
end
|
|
end
|
|
|
|
local loc_core, loc_update
|
|
for _, db in pairs(dbs) do
|
|
if pfDB[db]["data-turtle"] then
|
|
patchtable(pfDB[db]["data"], pfDB[db]["data-turtle"])
|
|
end
|
|
|
|
for loc, _ in pairs(pfDB.locales) do
|
|
if pfDB[db][loc] and pfDB[db][loc.."-turtle"] then
|
|
loc_update = pfDB[db][loc.."-turtle"] or pfDB[db]["enUS-turtle"]
|
|
patchtable(pfDB[db][loc], loc_update)
|
|
end
|
|
end
|
|
end
|
|
|
|
loc_core = pfDB["professions"][loc] or pfDB["professions"]["enUS"]
|
|
loc_update = pfDB["professions"][loc.."-turtle"] or pfDB["professions"]["enUS-turtle"]
|
|
if loc_update then patchtable(loc_core, loc_update) end
|
|
|
|
if pfDB["minimap-turtle"] then patchtable(pfDB["minimap"], pfDB["minimap-turtle"]) end
|
|
if pfDB["meta-turtle"] then patchtable(pfDB["meta"], pfDB["meta-turtle"]) end
|
|
|
|
-- Update bitmasks to include custom races
|
|
if pfDB.bitraces then
|
|
pfDB.bitraces[256] = "Goblin"
|
|
pfDB.bitraces[512] = "BloodElf"
|
|
end
|
|
|
|
-- Use turtle-wow database url
|
|
pfQuest.dburl = "https://database.turtle-wow.org/?quest="
|
|
|
|
-- Disable Minimap in custom dungeon maps
|
|
function pfMap:HasMinimap(map_id)
|
|
-- disable dungeon minimap
|
|
local has_minimap = not IsInInstance()
|
|
|
|
-- enable dungeon minimap if continent is less then 3 (e.g AV)
|
|
if IsInInstance() and GetCurrentMapContinent() < 3 then
|
|
has_minimap = true
|
|
end
|
|
|
|
return has_minimap
|
|
end
|
|
|
|
-- Reload all pfQuest internal database shortcuts
|
|
pfDatabase:Reload()
|
|
|
|
-- Automatically clear quest cache if new turtle quests have been found
|
|
local updatecheck = CreateFrame("Frame")
|
|
updatecheck:RegisterEvent("PLAYER_ENTERING_WORLD")
|
|
updatecheck:SetScript("OnEvent", function()
|
|
if pfDB["quests"]["data-turtle"] then
|
|
-- count all known turtle-wow quests
|
|
local count = 0
|
|
for k, v in pairs(pfDB["quests"]["data-turtle"]) do
|
|
count = count + 1
|
|
end
|
|
|
|
pfQuest:Debug("TurtleWoW loaded with |cff33ffcc" .. count .. "|r quests.")
|
|
|
|
-- check if the last count differs to the current amount of quests
|
|
if not pfQuest_turtlecount or pfQuest_turtlecount ~= count then
|
|
-- remove quest cache to force reinitialisation of all quests.
|
|
pfQuest:Debug("New quests found. Reloading |cff33ffccCache|r")
|
|
pfQuest_questcache = {}
|
|
end
|
|
|
|
-- write current count to the saved variable
|
|
pfQuest_turtlecount = count
|
|
end
|
|
end)
|