From b6aa42008474728944a07c97f9faa3f1635c0c6b Mon Sep 17 00:00:00 2001 From: Paliak <91493239+Paliak@users.noreply.github.com> Date: Sat, 17 Aug 2024 19:59:55 +0200 Subject: [PATCH] Fix limited processing flag not persisting through recursions causing 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 1a19ab0877d3a3e3349396bee6884f8d7f949802. * FIX: limited processing flag not persisting through recursions * FIX: spelling --- src/Modules/CalcMirages.lua | 3 ++- src/Modules/CalcPerform.lua | 2 +- src/Modules/CalcTriggers.lua | 4 ++-- src/Modules/Calcs.lua | 12 +++++++++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Modules/CalcMirages.lua b/src/Modules/CalcMirages.lua index 1cb076837e..6e5cc51951 100644 --- a/src/Modules/CalcMirages.lua +++ b/src/Modules/CalcMirages.lua @@ -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 diff --git a/src/Modules/CalcPerform.lua b/src/Modules/CalcPerform.lua index bc24862dbc..8fba4c7c53 100644 --- a/src/Modules/CalcPerform.lua +++ b/src/Modules/CalcPerform.lua @@ -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") diff --git a/src/Modules/CalcTriggers.lua b/src/Modules/CalcTriggers.lua index 508d1010ce..4bcfd86730 100644 --- a/src/Modules/CalcTriggers.lua +++ b/src/Modules/CalcTriggers.lua @@ -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 @@ -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) diff --git a/src/Modules/Calcs.lua b/src/Modules/Calcs.lua index fb3bf380f5..68f46b9189 100644 --- a/src/Modules/Calcs.lua +++ b/src/Modules/Calcs.lua @@ -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