Skip to content

Commit

Permalink
Fixed rare compute crash when having empty action resources
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaumRystra committed Jun 16, 2024
1 parent ada4acc commit 599c9f0
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export default function computeAction(computation: CreatureComputation, node: No
}
});
prop.resources.itemsConsumed?.forEach(itemConsumed => {
if (!itemConsumed.itemId || itemConsumed.available < itemConsumed.quantity?.value) {
if (!itemConsumed?.itemId || itemConsumed.available < itemConsumed.quantity?.value) {
prop.insufficientResources = true;
}
});
prop.resources.attributesConsumed?.forEach(attConsumed => {
if (!attConsumed.variableName) return;
if (!attConsumed?.variableName) return;
if (!(attConsumed.available >= attConsumed.quantity?.value)) {
prop.insufficientResources = true;
}
Expand All @@ -37,7 +37,7 @@ function computeResources(computation, node) {
resources.attributesConsumed.forEach(attConsumed => {
if (!attConsumed.variableName) return;
const att = computation.scope[attConsumed.variableName];
if (!att._id) return;
if (!att?._id) return;
attConsumed.available = att.value;
attConsumed.statName = att.name;
});
Expand Down

0 comments on commit 599c9f0

Please sign in to comment.