Skip to content

Commit 9eaec76

Browse files
committed
Avoid unsafe graph cloning in calc paths
1 parent dc503f8 commit 9eaec76

6 files changed

Lines changed: 425 additions & 99 deletions

File tree

src/Classes/ModStore.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ local ModStoreClass = newClass("ModStore", function(self, parent)
3232
self.actor = parent and parent.actor or { }
3333
self.multipliers = { }
3434
self.conditions = { }
35+
-- ModDB/ModList instances participate in actor/parent graphs and are not plain copyTable() targets.
36+
graphNodeTag(self, self._className or "ModStore")
3537
end)
3638

3739
function ModStoreClass:ScaleAddMod(mod, scale, replace)
@@ -45,7 +47,7 @@ function ModStoreClass:ScaleAddMod(mod, scale, replace)
4547
if scale == 1 or unscalable then
4648
self:AddMod(mod)
4749
else
48-
local scaledMod = copyTable(mod)
50+
local scaledMod = type(mod.value) == "table" and copyTableSafe(mod, false) or copyTable(mod)
4951
local subMod = scaledMod
5052
if type(scaledMod.value) == "table" then
5153
if scaledMod.value.mod then
@@ -367,7 +369,7 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
367369
mult = 1 / mult
368370
end
369371
if type(value) == "table" then
370-
value = copyTable(value)
372+
value = copyTableSafe(value, false)
371373
if value.mod then
372374
value.mod.value = value.mod.value * mult + (tag.base or 0)
373375
if limitTotal then
@@ -453,7 +455,7 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
453455
end
454456
end
455457
if type(value) == "table" then
456-
value = copyTable(value)
458+
value = copyTableSafe(value, false)
457459
if value.mod then
458460
value.mod.value = value.mod.value * mult + (tag.base or 0)
459461
if limitTotal then
@@ -502,7 +504,7 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
502504
end
503505
end
504506
if type(value) == "table" then
505-
value = copyTable(value)
507+
value = copyTableSafe(value, false)
506508
if value.mod then
507509
value.mod.value = m_ceil(value.mod.value * mult + (tag.base or 0))
508510
if limitTotal then
@@ -901,4 +903,4 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
901903
end
902904
end
903905
return value
904-
end
906+
end

0 commit comments

Comments
 (0)