From dea0ed56fcfc4fa0bd0ebaa58dfd047c5af856d2 Mon Sep 17 00:00:00 2001 From: hppeng Date: Wed, 20 Jul 2022 02:17:54 -0700 Subject: [PATCH 1/4] Fix atree validator sometimes giving the wrong reason accidentally used reasons from previous iteration --- js/atree.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/atree.js b/js/atree.js index 0a6151c..1ab5e4c 100644 --- a/js/atree.js +++ b/js/atree.js @@ -416,6 +416,7 @@ const atree_validate = new (class extends ComputeNode { reachable.add(ability.id); } if (atree_to_add.length == _add.length) { + atree_to_add = _add; break; } atree_to_add = _add; From 75f4fc684bb24c168eb656a02b6a49bee09ccaa9 Mon Sep 17 00:00:00 2001 From: hppeng Date: Wed, 20 Jul 2022 12:06:34 -0700 Subject: [PATCH 2/4] Add debug flag to fix compute graph memory leak mfw no destructor hook --- builder/doc.html | 1 + js/computation_graph.js | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/builder/doc.html b/builder/doc.html index 9b735e8..0a52469 100644 --- a/builder/doc.html +++ b/builder/doc.html @@ -1376,6 +1376,7 @@ + diff --git a/js/computation_graph.js b/js/computation_graph.js index 0dcc8d8..d144e29 100644 --- a/js/computation_graph.js +++ b/js/computation_graph.js @@ -1,5 +1,6 @@ -let all_nodes = []; +let all_nodes = new Set(); let node_debug_stack = []; +let COMPUTE_GRAPH_DEBUG = false; class ComputeNode { /** * Make a generic compute node. @@ -21,7 +22,7 @@ class ComputeNode { // 0: clean this.inputs_dirty = new Map(); this.inputs_dirty_count = 0; - all_nodes.push(this); + if (COMPUTE_GRAPH_DEBUG) { all_nodes.add(this); } } /** @@ -34,7 +35,7 @@ class ComputeNode { if (this.dirty === 0) { return; } - node_debug_stack.push(this.name); + if (COMPUTE_GRAPH_DEBUG) { node_debug_stack.push(this.name); } if (this.dirty == 2) { let calc_inputs = new Map(); for (const input of this.inputs) { @@ -46,7 +47,7 @@ class ComputeNode { for (const child of this.children) { child.mark_input_clean(this.name, this.value); } - node_debug_stack.pop(); + if (COMPUTE_GRAPH_DEBUG) { node_debug_stack.pop(); } return this; } @@ -190,7 +191,7 @@ function calcSchedule(node, timeout) { } node.mark_dirty(); node.update_task = setTimeout(function() { - node_debug_stack = []; + if (COMPUTE_GRAPH_DEBUG) { node_debug_stack = []; } node.update(); node.update_task = null; }, timeout); From 4aee8f2d31f6f799d2b3990de018c0a764430ed5 Mon Sep 17 00:00:00 2001 From: fin444 Date: Thu, 21 Jul 2022 11:26:46 -0700 Subject: [PATCH 3/4] dependencies in atree tooltips --- js/atree.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/js/atree.js b/js/atree.js index 623aa29..1e9bd6b 100644 --- a/js/atree.js +++ b/js/atree.js @@ -1143,6 +1143,7 @@ function generateTooltip(UI_elem, node_elem, ability, atree_map) { let apUsed = 0; let maxAP = parseInt(document.getElementById("active_AP_cap").innerHTML); let archChosen = 0; + let satisfiedDependencies = []; let blockedBy = []; for (let [id, node_wrap] of atree_map.entries()) { if (!node_wrap.active || id == ability.id) { @@ -1152,6 +1153,9 @@ function generateTooltip(UI_elem, node_elem, ability, atree_map) { if (node_wrap.ability.archetype == ability.archetype) { archChosen++; } + if (ability.dependencies.includes(id)) { + satisfiedDependencies.push(id); + } if (ability.blockers.includes(id)) { blockedBy.push(node_wrap.ability.display_name); } @@ -1182,6 +1186,19 @@ function generateTooltip(UI_elem, node_elem, ability, atree_map) { container.appendChild(archReq); } + // dependencies + console.log(satisfiedDependencies) + for (let i = 0; i < ability.dependencies.length; i++) { + let dependency = make_elem("p", ["scaled-font-sm", "my-0", "mx-1"], {}); + if (satisfiedDependencies.includes(ability.dependencies[i])) { + dependency.innerHTML = reqYes; + } else { + dependency.innerHTML = reqNo; + } + dependency.innerHTML += " Required Ability: " + atree_map.get(ability.dependencies[i]).ability.display_name; + container.appendChild(dependency); + } + // blockers for (let i = 0; i < blockedBy.length; i++) { let blocker = make_elem("p", ["scaled-font-sm", "my-0", "mx-1"], {}); From 868e56b0ea6c89b7f53cb0f31493e628f851c373 Mon Sep 17 00:00:00 2001 From: fin444 Date: Thu, 21 Jul 2022 17:17:33 -0700 Subject: [PATCH 4/4] remove print statement --- js/atree.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/atree.js b/js/atree.js index 1e9bd6b..2b38f27 100644 --- a/js/atree.js +++ b/js/atree.js @@ -1187,7 +1187,6 @@ function generateTooltip(UI_elem, node_elem, ability, atree_map) { } // dependencies - console.log(satisfiedDependencies) for (let i = 0; i < ability.dependencies.length; i++) { let dependency = make_elem("p", ["scaled-font-sm", "my-0", "mx-1"], {}); if (satisfiedDependencies.includes(ability.dependencies[i])) {