Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions src/Classes/CalcsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ end

-- Estimate the offensive and defensive power of all unallocated nodes
function CalcsTabClass:PowerBuilder()
--local timer_start = GetTime()
-- local timer_start = GetTime()
local useFullDPS = self.powerStat and self.powerStat.stat == "FullDPS"
local calcFunc, calcBase = self:GetMiscCalculator()
local cache = { }
Expand All @@ -494,18 +494,31 @@ function CalcsTabClass:PowerBuilder()
end

local start = GetTime()
local nodeIndex = 0
local total = 0

for nodeId, node in pairs(self.build.spec.nodes) do
wipeTable(node.power)
if node.modKey ~= "" and not self.mainEnv.grantedPassives[nodeId] then
distanceMap[node.pathDist or 1000] = distanceMap[node.pathDist or 1000] or { }
distanceMap[node.pathDist or 1000][nodeId] = node
if not (self.nodePowerMaxDepth and self.nodePowerMaxDepth < node.pathDist) then
total = total + 1
end
end
end
for distance, nodes in pairs(distanceMap) do
t_insert(distanceList, { distance, nodes })
end
distanceMap = nil
table.sort(distanceList, function(a, b) return a[1] < b[1] end)
-- Count eligible cluster nodes
for _, node in pairs(self.build.spec.tree.clusterNodeMap) do
if not node.alloc and node.modKey ~= "" and not self.mainEnv.grantedPassives[node.id] then
total = total + 1
end
end

for _, data in ipairs(distanceList) do
local distance, nodes = data[1], data[2]
if self.nodePowerMaxDepth and self.nodePowerMaxDepth < distance then
Expand Down Expand Up @@ -559,7 +572,11 @@ function CalcsTabClass:PowerBuilder()
end
end
end
nodeIndex = nodeIndex + 1
if coroutine.running() and GetTime() - start > 100 then
if self.build.powerBuilderProgressCallback then
self.build.powerBuilderProgressCallback(m_floor(nodeIndex/total*100))
end
coroutine.yield()
start = GetTime()
end
Expand All @@ -581,15 +598,19 @@ function CalcsTabClass:PowerBuilder()
if self.powerStat and self.powerStat.stat and not self.powerStat.ignoreForNodes then
node.power.singleStat = self:CalculatePowerStat(self.powerStat, output, calcBase)
end
end
if coroutine.running() and GetTime() - start > 100 then
coroutine.yield()
start = GetTime()
nodeIndex = nodeIndex + 1
if coroutine.running() and GetTime() - start > 100 then
if self.build.powerBuilderProgressCallback then
self.build.powerBuilderProgressCallback(m_floor(nodeIndex/total*100))
end
coroutine.yield()
start = GetTime()
end
end
end
self.powerMax = newPowerMax
self.powerBuilderInitialized = true
--ConPrintf("Power Build time: %d ms", GetTime() - timer_start)
-- ConPrintf("Power Build time: %d ms", GetTime() - timer_start)
end

function CalcsTabClass:CalculatePowerStat(selection, original, modified)
Expand Down
9 changes: 9 additions & 0 deletions src/Classes/TreeTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,15 @@ local TreeTabClass = newClass("TreeTab", "ControlHost", function(self, build)
end
end)
self.controls.powerReportList.shown = false
-- Progress callback from the CalcsTab power builder coroutine
self.build.powerBuilderProgressCallback = function(percent)
if percent then
self.controls.powerReportList.label = string.format("Building Tree... (%d%%)", percent)
else
self.controls.powerReportList.label = "Building Tree..."
end
end
-- Completion callback from the CalcsTab power builder coroutine
self.build.powerBuilderCallback = function()
local powerStat = self.build.calcsTab.powerStat or data.powerStatList[1]
local report = self:BuildPowerReportList(powerStat)
Expand Down