Skip to content

Commit c730455

Browse files
github-actions[bot]PeecheyLocalIdentity
authored
[pob2-port] Reduce EstimatePlayerProgress calls (#9873)
* Apply changes from PathOfBuildingCommunity/PathOfBuilding-PoE2#1972 * Fix merge * Fix test --------- Co-authored-by: Peechey <Peechey@users.noreply.github.com> Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent d5c31da commit c730455

2 files changed

Lines changed: 45 additions & 32 deletions

File tree

spec/System/TestRadiusJewelStatDiff_spec.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ describe("TestRadiusJewelStatDiff", function()
362362
local conqueredNode = nodesInRadius[1]
363363
local origNode = spec.tree.nodes[conqueredNode.id]
364364
simulateKaruiConquest(conqueredNode)
365+
-- The simulation happens after setup's calculation pass, so refresh the
366+
-- cached misc calculator before taking the conquered-state snapshot.
367+
build.calcsTab:BuildOutput()
365368

366369
-- Snapshot the state including the simulated conquest, then revert
367370
-- the conquered node back to the original tree node via override.

src/Modules/Build.lua

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
188188
end
189189
self.controls.pointDisplay = new("Control", {"LEFT",self.anchorTopBarRight,"RIGHT"}, {function() return getPointDisplayX() end, 0, 0, 20})
190190
self.controls.pointDisplay.width = function(control)
191-
control.str, control.req = self:EstimatePlayerProgress()
192191
return DrawStringWidth(16, "FIXED", control.str) + 8
193192
end
194193
self.controls.pointDisplay.Draw = function(control)
@@ -874,38 +873,48 @@ function buildMode:SyncLoadouts()
874873
end
875874

876875
function buildMode:EstimatePlayerProgress()
877-
local PointsUsed, AscUsed, SecondaryAscUsed = self.spec:CountAllocNodes()
878-
local extra = self.calcsTab.mainOutput and self.calcsTab.mainOutput.ExtraPoints or 0
879-
local usedMax, ascMax, secondaryAscMax, level, act = 99 + 23 + extra, 8, 8, 1, 0
880-
881-
-- Find estimated act and level based on points used
882-
repeat
883-
act = act + 1
884-
level = m_min(m_max(PointsUsed + 1 - acts[act].questPoints - actExtra(act, extra), acts[act].level), 100)
885-
until act == 11 or level <= acts[act + 1].level
886-
887-
if self.characterLevelAutoMode and self.characterLevel ~= level then
888-
self.characterLevel = level
889-
self.controls.characterLevel:SetText(self.characterLevel)
890-
self.configTab:BuildModList()
876+
if self.spec then
877+
local PointsUsed, AscUsed, SecondaryAscUsed = self.spec:CountAllocNodes()
878+
local extra = self.calcsTab.mainOutput and self.calcsTab.mainOutput.ExtraPoints or 0
879+
local usedMax, ascMax, secondaryAscMax, level, act = 99 + 23 + extra, 8, 8, 1, 0
880+
881+
-- Find estimated act and level based on points used
882+
repeat
883+
act = act + 1
884+
level = m_min(m_max(PointsUsed + 1 - acts[act].questPoints - actExtra(act, extra), acts[act].level), 100)
885+
until act == 11 or level <= acts[act + 1].level
886+
887+
if self.characterLevelAutoMode and self.characterLevel ~= level then
888+
self.characterLevel = level
889+
self.controls.characterLevel:SetText(self.characterLevel)
890+
self.configTab:BuildModList()
891+
end
892+
893+
-- Ascendancy points for lab
894+
-- this is a recommendation for beginners who are using Path of Building for the first time and trying to map out progress in PoB
895+
local labSuggest = level < 33 and ""
896+
or level < 55 and "\nLabyrinth: Normal Lab"
897+
or level < 68 and "\nLabyrinth: Cruel Lab"
898+
or level < 75 and "\nLabyrinth: Merciless Lab"
899+
or level < 90 and "\nLabyrinth: Uber Lab"
900+
or ""
901+
902+
if PointsUsed > usedMax then InsertIfNew(self.controls.warnings.lines, "You have too many passive points allocated") end
903+
if AscUsed > ascMax then InsertIfNew(self.controls.warnings.lines, "You have too many ascendancy points allocated") end
904+
if SecondaryAscUsed > secondaryAscMax then InsertIfNew(self.controls.warnings.lines, "You have too many secondary ascendancy points allocated") end
905+
self.Act = level < 90 and act <= 10 and act or "Endgame"
906+
907+
self.controls.pointDisplay.str = string.format("%s%3d / %3d %s%d / %d",
908+
PointsUsed > usedMax and colorCodes.NEGATIVE or "^7",
909+
PointsUsed, usedMax,
910+
AscUsed > ascMax and colorCodes.NEGATIVE or "^7",
911+
AscUsed, ascMax
912+
)
913+
self.controls.pointDisplay.req = string.format(
914+
"Required Level: %d\nEstimated Progress:\nAct: %s\nQuestpoints: %d\nExtra Skillpoints: %d%s",
915+
level, self.Act, acts[act].questPoints, actExtra(act, extra), labSuggest
916+
)
891917
end
892-
893-
-- Ascendancy points for lab
894-
-- this is a recommendation for beginners who are using Path of Building for the first time and trying to map out progress in PoB
895-
local labSuggest = level < 33 and ""
896-
or level < 55 and "\nLabyrinth: Normal Lab"
897-
or level < 68 and "\nLabyrinth: Cruel Lab"
898-
or level < 75 and "\nLabyrinth: Merciless Lab"
899-
or level < 90 and "\nLabyrinth: Uber Lab"
900-
or ""
901-
902-
if PointsUsed > usedMax then InsertIfNew(self.controls.warnings.lines, "You have too many passive points allocated") end
903-
if AscUsed > ascMax then InsertIfNew(self.controls.warnings.lines, "You have too many ascendancy points allocated") end
904-
if SecondaryAscUsed > secondaryAscMax then InsertIfNew(self.controls.warnings.lines, "You have too many secondary ascendancy points allocated") end
905-
self.Act = level < 90 and act <= 10 and act or "Endgame"
906-
907-
return string.format("%s%3d / %3d %s%d / %d", PointsUsed > usedMax and colorCodes.NEGATIVE or "^7", PointsUsed, usedMax, AscUsed > ascMax and colorCodes.NEGATIVE or "^7", AscUsed, ascMax),
908-
"Required Level: "..level.."\nEstimated Progress:\nAct: "..self.Act.."\nQuestpoints: "..acts[act].questPoints.."\nExtra Skillpoints: "..actExtra(act, extra)..labSuggest
909918
end
910919

911920
function buildMode:CanExit(mode)
@@ -1779,6 +1788,7 @@ function buildMode:RefreshStatList()
17791788
end
17801789
self:AddDisplayStatList(self.displayStats, self.calcsTab.mainEnv.player)
17811790
self:InsertItemWarnings()
1791+
self:EstimatePlayerProgress()
17821792
end
17831793

17841794
function buildMode:CompareStatList(tooltip, statList, actor, baseOutput, compareOutput, header, nodeCount)

0 commit comments

Comments
 (0)