Skip to content

Commit

Permalink
Fix limited processing flag not persisting through recursions causing…
Browse files Browse the repository at this point in the history
… crash (#8192)

* FIX: crash due to limited processing flag not persisting between
recursive calc.perform calls.

This fix may re-introduce #6898 in some cases.

* Revert "FIX: crash due to limited processing flag not persisting between"

This reverts commit 1a19ab0.

* FIX: limited processing flag not persisting through recursions

* FIX: spelling
  • Loading branch information
Paliak authored Aug 17, 2024
1 parent 2f04fb4 commit b6aa420
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Modules/CalcMirages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ local function calculateMirage(env, config)
if mirageSkill then
local newSkill, newEnv = calcs.copyActiveSkill(env, env.mode, mirageSkill)
newSkill.skillCfg.skillCond["usedByMirage"] = true
newSkill.skillData.limitedProcessing = true
newEnv.limitedSkills = newEnv.limitedSkills or {}
newEnv.limitedSkills[cacheSkillUUID(newSkill, newEnv)] = true
newSkill.skillData.mirageUses = env.player.mainSkill.skillData.storedUses
newSkill.skillTypes[SkillType.OtherThingUsesSkill] = true

Expand Down
2 changes: 1 addition & 1 deletion src/Modules/CalcPerform.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ function calcs.perform(env, skipEHP)
-- computed cached versions to satisfy the order of operations.
-- See: https://github.com/PathOfBuildingCommunity/PathOfBuilding/pull/5164
for _, activeSkill in ipairs(env.player.activeSkillList) do
if not activeSkill.skillFlags.disable and not activeSkill.skillData.limitedProcessing then
if not activeSkill.skillFlags.disable and not (env.limitedSkills and env.limitedSkills[cacheSkillUUID(activeSkill, env)]) then
if (activeSkill.activeEffect.grantedEffect.name == "Blight" or activeSkill.activeEffect.grantedEffect.name == "Blight of Contagion" or activeSkill.activeEffect.grantedEffect.name == "Blight of Atrophy") and activeSkill.skillPart == 2 then
local rate, duration = getCachedOutputValue(env, activeSkill, "Speed", "Duration")
local baseMaxStages = activeSkill.skillModList:Sum("BASE", env.player.mainSkill.skillCfg, "BlightBaseMaxStages")
Expand Down
4 changes: 2 additions & 2 deletions src/Modules/CalcTriggers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ local configTable = {
end

if env.player.mainSkill.activeEffect.grantedEffect.name == "Snipe" then
if env.player.mainSkill.skillData.limitedProcessing then
if (env.limitedSkills and env.limitedSkills[cacheSkillUUID(env.player.mainSkill, env)]) then
-- Snipe is being used by some other skill. In this case snipe does not get more damage mods
snipeStages = 0
else
Expand Down Expand Up @@ -1420,7 +1420,7 @@ local function getUniqueItemTriggerName(skill)
end

function calcs.triggers(env, actor)
if actor and not actor.mainSkill.skillFlags.disable and not actor.mainSkill.skillData.limitedProcessing then
if actor and not actor.mainSkill.skillFlags.disable and not (env.limitedSkills and env.limitedSkills[cacheSkillUUID(actor.mainSkill, env)]) then
local skillName = actor.mainSkill.activeEffect.grantedEffect.name
local triggerName = actor.mainSkill.triggeredBy and actor.mainSkill.triggeredBy.grantedEffect.name
local uniqueName = isTriggered(actor.mainSkill) and getUniqueItemTriggerName(actor.mainSkill)
Expand Down
12 changes: 11 additions & 1 deletion src/Modules/Calcs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,22 @@ end
-- Process active skill
function calcs.buildActiveSkill(env, mode, skill, targetUUID, limitedProcessingFlags)
local fullEnv, _, _, _ = calcs.initEnv(env.build, mode, env.override)

-- env.limitedSkills contains a map of uuids that should be limited in calculation
-- this is in order to prevent infinite recursion loops
fullEnv.limitedSkills = fullEnv.limitedSkills or {}
for uuid, _ in pairs(env.limitedSkills or {}) do
fullEnv.limitedSkills[uuid] = true
end
for uuid, _ in pairs(limitedProcessingFlags or {}) do
fullEnv.limitedSkills[uuid] = true
end

targetUUID = targetUUID or cacheSkillUUID(skill, env)
for _, activeSkill in ipairs(fullEnv.player.activeSkillList) do
local activeSkillUUID = cacheSkillUUID(activeSkill, fullEnv)
if activeSkillUUID == targetUUID then
fullEnv.player.mainSkill = activeSkill
fullEnv.player.mainSkill.skillData.limitedProcessing = limitedProcessingFlags and limitedProcessingFlags[activeSkillUUID]
calcs.perform(fullEnv, true)
return
end
Expand Down

0 comments on commit b6aa420

Please sign in to comment.