Skip to content

Commit e67977f

Browse files
committed
Added compatibility with 10.1.5 and the new Evoker Spec. New specs and classes should no longer require a data update
1 parent d1d3b59 commit e67977f

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

LibTalentTree-1.0.lua

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
-- as of 10.1.0, most data will be loaded (and cached) from blizzard's APIs when the Lib loads
33
-- @curseforge-project-slug: libtalenttree@
44

5-
local MAJOR, MINOR = "LibTalentTree-1.0", 8
5+
local MAJOR, MINOR = "LibTalentTree-1.0", 9
66
--- @class LibTalentTree
77
local LibTalentTree = LibStub:NewLibrary(MAJOR, MINOR)
88

99
if not LibTalentTree then return end -- No upgrade needed
1010

11+
local MAX_LEVEL = 70;
1112
LibTalentTree.dataVersion = 0 -- overwritten in LibTalentTree-1.0_data.lua
1213

1314
---@alias edgeType
@@ -128,7 +129,7 @@ local function getGridLineFromCoordinate(start, spacing, halfwayEnabled, coordin
128129
end
129130

130131
local function buildCache()
131-
local level = 70;
132+
local level = MAX_LEVEL;
132133
local configID = Constants.TraitConsts.VIEW_TRAIT_CONFIG_ID;
133134

134135
LibTalentTree.cache = {};
@@ -350,7 +351,8 @@ function LibTalentTree:IsNodeVisibleForSpec(specId, nodeId)
350351
assert(type(specId) == 'number', 'specId must be a number');
351352
assert(type(nodeId) == 'number', 'nodeId must be a number');
352353

353-
local class = LibTalentTree.specMap[specId];
354+
local specMap = useCache and self.cache.specMap or self.specMap;
355+
local class = specMap[specId];
354356
assert(class, 'Unknown specId: ' .. specId);
355357

356358
local treeId = self:GetClassTreeId(class);
@@ -399,7 +401,8 @@ function LibTalentTree:IsNodeGrantedForSpec(specId, nodeId)
399401
assert(type(specId) == 'number', 'specId must be a number');
400402
assert(type(nodeId) == 'number', 'nodeId must be a number');
401403

402-
local class = LibTalentTree.specMap[specId];
404+
local specMap = useCache and self.cache.specMap or self.specMap;
405+
local class = specMap[specId];
403406
assert(class, 'Unknown specId: ' .. specId);
404407

405408
local treeId = self:GetClassTreeId(class);
@@ -540,16 +543,20 @@ function LibTalentTree:GetGates(specId)
540543
assert(type(specId) == 'number', 'specId must be a number');
541544

542545
if (gateCache[specId]) then return deepCopy(gateCache[specId]); end
543-
local class = LibTalentTree.specMap[specId];
546+
local specMap = useCache and self.cache.specMap or self.specMap;
547+
local class = specMap[specId];
544548
assert(class, 'Unknown specId: ' .. specId);
545549

546550
local treeId = self:GetClassTreeId(class);
547551
local gates = {};
548552

549553
local nodesByConditions = {};
550-
local conditions = self.gateData[treeId];
554+
local gateData = useCache and self.cache.gateData or self.gateData;
555+
local conditions = gateData[treeId];
551556

552-
for nodeId, nodeInfo in pairs(self.nodeData[treeId]) do
557+
local nodeData = useCache and self.cache.nodeData or self.nodeData;
558+
559+
for nodeId, nodeInfo in pairs(nodeData[treeId]) do
553560
if (#nodeInfo.conditionIDs > 0 and self:IsNodeVisibleForSpec(specId, nodeId)) then
554561
for _, conditionId in pairs(nodeInfo.conditionIDs) do
555562
if conditions[conditionId] then

0 commit comments

Comments
 (0)