Fix infinite loops in calculating max affordable

This commit is contained in:
thepaperpilot 2023-05-12 17:07:54 -05:00
parent b6a3c49cc5
commit ff1ace0609

View file

@ -1458,7 +1458,8 @@ export function calculateMaxAffordable(
}
while (
Decimal.lt(affordable, maxBulkAmount) &&
Decimal.lt(affordable, Number.MAX_SAFE_INTEGER)
Decimal.lt(affordable, Number.MAX_SAFE_INTEGER) &&
Decimal.add(directSum, 1).gte(affordable)
) {
const nextCost = formula.evaluate(
affordable.add(unref(formula.innermostVariable) ?? 0)