mirror of
https://github.com/Blaststar/Questie-Octo-Vanilla.git
synced 2026-10-21 04:40:49 +00:00
Various fixes and added professions/class trainers
This commit is contained in:
@@ -30,6 +30,8 @@ N.stats={
|
||||
spiritHealer=0,
|
||||
stableMaster=0,
|
||||
vendor=0,
|
||||
classTrainer=0,
|
||||
professionTrainer=0,
|
||||
rareMob=0,
|
||||
}
|
||||
|
||||
@@ -55,6 +57,8 @@ local function NewStats()
|
||||
spiritHealer=0,
|
||||
stableMaster=0,
|
||||
vendor=0,
|
||||
classTrainer=0,
|
||||
professionTrainer=0,
|
||||
rareMob=0,
|
||||
}
|
||||
end
|
||||
@@ -298,6 +302,8 @@ local optionalServiceSettings={
|
||||
spiritHealer={"showMapSpiritHealer","showMinimapSpiritHealer"},
|
||||
stableMaster={"showMapStableMaster","showMinimapStableMaster"},
|
||||
vendor={"showMapVendor","showMinimapVendor"},
|
||||
classTrainer={"showMapClassTrainer","showMinimapClassTrainer"},
|
||||
professionTrainer={"showMapProfessionTrainer","showMinimapProfessionTrainer"},
|
||||
}
|
||||
|
||||
local function OptionalServiceEnabled(role)
|
||||
@@ -380,6 +386,66 @@ local function ProcessServiceObjectSlice(metaKey,role,statKey,cursor,limit)
|
||||
return cursor,false
|
||||
end
|
||||
|
||||
-- Trainers are stored two levels deep: meta["trainers"][class] and
|
||||
-- meta["professions"][profession] each hold a flat {[creatureID]=faction} table.
|
||||
-- We flatten that lazily so the incremental builder can pause between frames:
|
||||
-- the cursor is {groupKey=<class/profession>, innerCursor=<creatureID>}. Each
|
||||
-- emitted node is tagged with trainerKey=<group> so the renderer can pick the
|
||||
-- right icon out of the ringed class/profession atlas.
|
||||
local function ProcessTrainerSlice(metaKey,role,statKey,cursor,limit)
|
||||
local root=TrackingMeta(metaKey)
|
||||
if type(root)~="table" then return nil,true end
|
||||
local factionCode=PlayerFactionCode()
|
||||
if not factionCode then return nil,true end
|
||||
|
||||
cursor=cursor or {}
|
||||
local groupKey=cursor.groupKey
|
||||
local innerCursor=cursor.innerCursor
|
||||
|
||||
local count=0
|
||||
while count<(limit or 128) do
|
||||
if groupKey==nil then
|
||||
groupKey=next(root,nil)
|
||||
innerCursor=nil
|
||||
if groupKey==nil then return nil,true end
|
||||
end
|
||||
|
||||
local group=root[groupKey]
|
||||
local rawID,allowed
|
||||
if type(group)=="table" then rawID,allowed=next(group,innerCursor) end
|
||||
|
||||
if rawID==nil then
|
||||
-- Group exhausted (or not a table): advance to the next group. Empty
|
||||
-- profession tables fall straight through here without costing a slot.
|
||||
groupKey=next(root,groupKey)
|
||||
innerCursor=nil
|
||||
if groupKey==nil then return nil,true end
|
||||
else
|
||||
innerCursor=rawID
|
||||
local creatureID=tonumber(rawID)
|
||||
if creatureID and creatureID>0 and FactionAllows(allowed,factionCode) then
|
||||
local coords=QuestieOcto.DatabaseAPI:GetCreatureCoords(creatureID)
|
||||
if coords and next(coords) then
|
||||
AddNode({
|
||||
questID=0,
|
||||
role=role,
|
||||
sourceKind="creature",
|
||||
sourceID=creatureID,
|
||||
sourceName=QuestieOcto.DatabaseAPI:GetCreatureName(creatureID),
|
||||
coords=coords,
|
||||
serviceFaction=allowed,
|
||||
trainerKey=tostring(groupKey)
|
||||
})
|
||||
CurrentStats()[statKey]=(CurrentStats()[statKey] or 0)+1
|
||||
end
|
||||
end
|
||||
count=count+1
|
||||
end
|
||||
end
|
||||
|
||||
return {groupKey=groupKey,innerCursor=innerCursor},false
|
||||
end
|
||||
|
||||
local function ProcessRareMobSlice(cursor,limit)
|
||||
local list=TrackingMeta("rares")
|
||||
if not list then return nil,true end
|
||||
@@ -537,6 +603,8 @@ local function StatKeyForNode(node)
|
||||
if node.role=="spiritHealer" then return "spiritHealer" end
|
||||
if node.role=="stableMaster" then return "stableMaster" end
|
||||
if node.role=="vendor" then return "vendor" end
|
||||
if node.role=="classTrainer" then return "classTrainer" end
|
||||
if node.role=="professionTrainer" then return "professionTrainer" end
|
||||
if node.role=="rareMob" then return "rareMob" end
|
||||
return nil
|
||||
end
|
||||
@@ -756,6 +824,8 @@ function N:Rebuild()
|
||||
{kind="creature",metaKey="spirithealer",role="spiritHealer",statKey="spiritHealer",optional=true},
|
||||
{kind="creature",metaKey="stablemaster",role="stableMaster",statKey="stableMaster",optional=true},
|
||||
{kind="creature",metaKey="vendor",role="vendor",statKey="vendor",optional=true},
|
||||
{kind="trainer",metaKey="trainers",role="classTrainer",statKey="classTrainer",optional=true},
|
||||
{kind="trainer",metaKey="professions",role="professionTrainer",statKey="professionTrainer",optional=true},
|
||||
{kind="rare"},
|
||||
}
|
||||
|
||||
@@ -775,6 +845,8 @@ function N:Rebuild()
|
||||
nextCursor,done=ProcessServiceCreatureSlice(job.metaKey,job.role,job.statKey,cursor,128)
|
||||
elseif job.kind=="object" then
|
||||
nextCursor,done=ProcessServiceObjectSlice(job.metaKey,job.role,job.statKey,cursor,128)
|
||||
elseif job.kind=="trainer" then
|
||||
nextCursor,done=ProcessTrainerSlice(job.metaKey,job.role,job.statKey,cursor,128)
|
||||
elseif job.kind=="rare" then
|
||||
nextCursor,done=ProcessRareMobSlice(cursor,128)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user