Fixed dependency loops created by inactive props
depending on their parent toggles
This commit is contained in:
@@ -10,8 +10,10 @@ export default function computeToggleDependencies(node, dependencyGraph){
|
|||||||
prop.enabled
|
prop.enabled
|
||||||
) return;
|
) return;
|
||||||
walkDown(node.children, child => {
|
walkDown(node.children, child => {
|
||||||
child.node._computationDetails.toggleAncestors.push(prop);
|
// Only for children that aren't inactive
|
||||||
|
if (child.node.inactive) return;
|
||||||
// The child nodes depend on the toggle condition compuation
|
// The child nodes depend on the toggle condition compuation
|
||||||
|
child.node._computationDetails.toggleAncestors.push(prop);
|
||||||
dependencyGraph.addLink(child.node._id, prop._id, 'toggle');
|
dependencyGraph.addLink(child.node._id, prop._id, 'toggle');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ export function buildComputationFromProps(properties, creature, variables){
|
|||||||
// Walk the property trees computing things that need to be inherited
|
// Walk the property trees computing things that need to be inherited
|
||||||
walkDown(forest, node => {
|
walkDown(forest, node => {
|
||||||
computeInactiveStatus(node);
|
computeInactiveStatus(node);
|
||||||
|
});
|
||||||
|
// Inactive status must be complete for the whole tree before toggle deps
|
||||||
|
// are calculated
|
||||||
|
walkDown(forest, node => {
|
||||||
computeToggleDependencies(node, dependencyGraph);
|
computeToggleDependencies(node, dependencyGraph);
|
||||||
computeSlotQuantityFilled(node, dependencyGraph);
|
computeSlotQuantityFilled(node, dependencyGraph);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,11 +51,22 @@ function compute(computation, node){
|
|||||||
|
|
||||||
function pushDependenciesToStack(nodeId, graph, stack, computation){
|
function pushDependenciesToStack(nodeId, graph, stack, computation){
|
||||||
graph.forEachLinkedNode(nodeId, linkedNode => {
|
graph.forEachLinkedNode(nodeId, linkedNode => {
|
||||||
if (linkedNode._visitedChildren && !linkedNode._visited){
|
if (linkedNode._visitedChildren && !linkedNode._visited) {
|
||||||
const pather = path.nba(graph, {
|
// This is a dependency loop, find a path from the node to itself
|
||||||
oriented: true
|
// and store that path as a dependency loop error
|
||||||
});
|
const pather = path.nba(graph, { oriented: true });
|
||||||
const loop = pather.find(nodeId, nodeId);
|
let loop = [];
|
||||||
|
// Pather doesn't like going from a node to iteself, so find all the
|
||||||
|
// paths going from the next node back to the original node
|
||||||
|
// and return the shortest one
|
||||||
|
graph.forEachLinkedNode(nodeId, nextNode => {
|
||||||
|
const newLoop = pather.find(nextNode.id, nodeId);
|
||||||
|
if (!newLoop.length) return;
|
||||||
|
if (!loop.length || newLoop.length < loop.length - 1) {
|
||||||
|
loop = [linkedNode, ...newLoop];
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
if (loop.length) {
|
if (loop.length) {
|
||||||
computation.errors.push({
|
computation.errors.push({
|
||||||
type: 'dependencyLoop',
|
type: 'dependencyLoop',
|
||||||
|
|||||||
Reference in New Issue
Block a user