Remove "air gap" nodes (#240)

* Remove "air gap" nodes

they... just aren't necessary... compute graph supports having inputs in the middle anyway
WHY did I do this in the past (and it caused issues with dusty update)

* Fix loading older item db versions and v0 links

* Remove debug prints

Co-authored-by: hppeng <hppeng>
This commit is contained in:
hppeng-wynn 2022-12-20 21:34:11 +00:00 committed by GitHub
parent 049ca0a482
commit eeb5d61c74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 38 deletions

View file

@ -1314,13 +1314,13 @@
<script type="text/javascript" src="../js/load_tome.js"></script> <script type="text/javascript" src="../js/load_tome.js"></script>
<script type="text/javascript" src="../js/custom.js"></script> <script type="text/javascript" src="../js/custom.js"></script>
<script type="text/javascript" src="../js/craft.js"></script> <script type="text/javascript" src="../js/craft.js"></script>
<script type="text/javascript" src="../js/builder/atree_constants_min.js"></script>
<script type="text/javascript" src="../js/builder/build.js"></script> <script type="text/javascript" src="../js/builder/build.js"></script>
<script type="text/javascript" src="../js/builder/builder_constants.js"></script> <script type="text/javascript" src="../js/builder/builder_constants.js"></script>
<script type="text/javascript" src="../js/builder/build_encode_decode.js"></script> <script type="text/javascript" src="../js/builder/build_encode_decode.js"></script>
<script type="text/javascript" src="../js/builder/atree.js"></script> <script type="text/javascript" src="../js/builder/atree.js"></script>
<script type="text/javascript" src="../js/builder/builder.js"></script>
<script type="text/javascript" src="../js/builder/builder_graph.js"></script> <script type="text/javascript" src="../js/builder/builder_graph.js"></script>
<script type="text/javascript" src="../js/builder/builder.js"></script>
<!--script type="text/javascript" src="../js/builder/optimize.js"></script-->
<div id="graph_body" style="max-width: 100%; height: 100vh"> <div id="graph_body" style="max-width: 100%; height: 100vh">
<button id="saveButton">JANKY Export SVG</button> <button id="saveButton">JANKY Export SVG</button>

View file

@ -53,6 +53,7 @@ async function parse_hash(url_tag) {
let powdering = ["", "", "", "", ""]; let powdering = ["", "", "", "", ""];
let info = url_tag.split("_"); let info = url_tag.split("_");
let version = info[0]; let version = info[0];
// Whether skillpoints are manually updated. True if they should be set to something other than default values
let save_skp = false; let save_skp = false;
let skillpoints = [0, 0, 0, 0, 0]; let skillpoints = [0, 0, 0, 0, 0];
let level = 106; let level = 106;
@ -157,7 +158,9 @@ async function parse_hash(url_tag) {
} }
//level, skill point assignments, and powdering //level, skill point assignments, and powdering
if (version_number == 1) { if (version_number == 0) {
// do nothing! lol
} else if (version_number == 1) {
let powder_info = data_str; let powder_info = data_str;
let res = parsePowdering(powder_info); let res = parsePowdering(powder_info);
powdering = res[0]; powdering = res[0];
@ -222,6 +225,8 @@ async function parse_hash(url_tag) {
for (let i in skillpoints) { for (let i in skillpoints) {
setValue(skp_order[i] + "-skp", skillpoints[i]); setValue(skp_order[i] + "-skp", skillpoints[i]);
} }
return save_skp;
} }
/* Stores the entire build in a string using B64 encoding and adds it to the URL. /* Stores the entire build in a string using B64 encoding and adds it to the URL.

View file

@ -358,14 +358,16 @@ async function init() {
}); });
} catch (e) { } catch (e) {
console.log("Could not initialize macy components. Maybe you're offline?"); console.log("Could not initialize macy components. Maybe you're offline?");
console.log(e);
} }
await parse_hash(url_tag); const save_skp = await parse_hash(url_tag);
try { try {
init_autocomplete(); init_autocomplete();
} catch (e) { } catch (e) {
console.log("Could not initialize autocomplete. Maybe you're offline?"); console.log("Could not initialize autocomplete. Maybe you're offline?");
console.log(e);
} }
builder_graph_init(); builder_graph_init(save_skp);
for (const item_node of item_nodes) { for (const item_node of item_nodes) {
if (item_node.get_value() === null) { if (item_node.get_value() === null) {
// likely DB load failure... // likely DB load failure...

View file

@ -865,6 +865,7 @@ let radiance_affected = [ /*"hp"*/, "fDef", "wDef", "aDef", "tDef", "eDef", "hpr
]; ];
/** /**
* Scale stats if radiance is enabled. * Scale stats if radiance is enabled.
* TODO: skillpoints...
*/ */
const radiance_node = new (class extends ComputeNode { const radiance_node = new (class extends ComputeNode {
constructor() { super('radiance-node->:('); } constructor() { super('radiance-node->:('); }
@ -936,6 +937,7 @@ class AggregateEditableIDNode extends ComputeNode {
let edit_id_output; let edit_id_output;
function resetEditableIDs() { function resetEditableIDs() {
edit_id_output.mark_dirty().update();
edit_id_output.notify(); edit_id_output.notify();
} }
/** /**
@ -947,6 +949,9 @@ class EditableIDSetterNode extends ComputeNode {
constructor(notify_nodes) { constructor(notify_nodes) {
super("builder-id-setter"); super("builder-id-setter");
this.notify_nodes = notify_nodes.slice(); this.notify_nodes = notify_nodes.slice();
for (const child of this.notify_nodes) {
child.link_to(this);
}
} }
compute_func(input_map) { compute_func(input_map) {
@ -959,20 +964,7 @@ class EditableIDSetterNode extends ComputeNode {
} }
} }
/**
* Overriding this to bridge the transparent gap.
*/
mark_dirty(dirty_state=2) {
super.mark_dirty(dirty_state);
for (const node of this.notify_nodes) {
node.mark_dirty(dirty_state);
}
return this;
}
notify() { notify() {
this.mark_dirty();
this.update();
// NOTE: DO NOT merge these loops for performance reasons!!! // NOTE: DO NOT merge these loops for performance reasons!!!
for (const node of this.notify_nodes) { for (const node of this.notify_nodes) {
node.mark_dirty(); node.mark_dirty();
@ -993,6 +985,9 @@ class SkillPointSetterNode extends ComputeNode {
constructor(notify_nodes) { constructor(notify_nodes) {
super("builder-skillpoint-setter"); super("builder-skillpoint-setter");
this.notify_nodes = notify_nodes.slice(); this.notify_nodes = notify_nodes.slice();
for (const child of this.notify_nodes) {
child.link_to(this);
}
} }
compute_func(input_map) { compute_func(input_map) {
@ -1001,13 +996,6 @@ class SkillPointSetterNode extends ComputeNode {
for (const [idx, elem] of skp_order.entries()) { for (const [idx, elem] of skp_order.entries()) {
document.getElementById(elem+'-skp').value = build.total_skillpoints[idx]; document.getElementById(elem+'-skp').value = build.total_skillpoints[idx];
} }
// NOTE: DO NOT merge these loops for performance reasons!!!
for (const node of this.notify_nodes) {
node.mark_dirty();
}
for (const node of this.notify_nodes) {
node.update();
}
} }
} }
@ -1052,7 +1040,11 @@ let stat_agg_node;
let edit_agg_node; let edit_agg_node;
let atree_graph_creator; let atree_graph_creator;
function builder_graph_init() { /**
* Parameters:
* save_skp: bool True if skillpoints are modified away from skp engine defaults.
*/
function builder_graph_init(save_skp) {
// Phase 1/3: Set up item input, propagate updates, etc. // Phase 1/3: Set up item input, propagate updates, etc.
// Level input node. // Level input node.
@ -1133,6 +1125,7 @@ function builder_graph_init() {
// Edit IDs setter declared up here to set ids so they will be populated by default. // Edit IDs setter declared up here to set ids so they will be populated by default.
edit_id_output = new EditableIDSetterNode(edit_input_nodes); // Makes shallow copy of list. edit_id_output = new EditableIDSetterNode(edit_input_nodes); // Makes shallow copy of list.
edit_id_output.link_to(build_node); edit_id_output.link_to(build_node);
edit_agg_node.link_to(edit_id_output, 'edit-id-setter');
for (const skp of skp_order) { for (const skp of skp_order) {
const elem = document.getElementById(skp+'-skp'); const elem = document.getElementById(skp+'-skp');
@ -1208,8 +1201,11 @@ function builder_graph_init() {
node.update(); node.update();
} }
let skp_output = new SkillPointSetterNode(edit_input_nodes); let skp_output = new SkillPointSetterNode(skp_inputs);
skp_output.link_to(build_node); skp_output.link_to(build_node);
if (!save_skp) {
skp_output.update().mark_dirty().update();
}
let build_warnings_node = new DisplayBuildWarningsNode(); let build_warnings_node = new DisplayBuildWarningsNode();
build_warnings_node.link_to(build_node, 'build'); build_warnings_node.link_to(build_node, 'build');

View file

@ -30,10 +30,10 @@ class ComputeNode {
*/ */
update() { update() {
if (this.inputs_dirty_count != 0) { if (this.inputs_dirty_count != 0) {
return; return this;
} }
if (this.dirty === 0) { if (this.dirty === 0) {
return; return this;
} }
if (COMPUTE_GRAPH_DEBUG) { node_debug_stack.push(this.name); } if (COMPUTE_GRAPH_DEBUG) { node_debug_stack.push(this.name); }
if (this.dirty == 2) { if (this.dirty == 2) {
@ -150,10 +150,10 @@ class ValueCheckComputeNode extends ComputeNode {
*/ */
update() { update() {
if (this.inputs_dirty_count != 0) { if (this.inputs_dirty_count != 0) {
return; return this;
} }
if (this.dirty === 0) { if (this.dirty === 0) {
return; return this;
} }
let calc_inputs = new Map(); let calc_inputs = new Map();
@ -179,7 +179,6 @@ class ValueCheckComputeNode extends ComputeNode {
mark_dirty(dirty_state="unused") { mark_dirty(dirty_state="unused") {
return super.mark_dirty(1); return super.mark_dirty(1);
} }
} }
let graph_live_update = false; let graph_live_update = false;
@ -196,8 +195,10 @@ function calcSchedule(node, timeout) {
node.mark_dirty(); node.mark_dirty();
node.update_task = setTimeout(function() { node.update_task = setTimeout(function() {
if (COMPUTE_GRAPH_DEBUG) { node_debug_stack = []; } if (COMPUTE_GRAPH_DEBUG) { node_debug_stack = []; }
graph_live_update = false;
node.update(); node.update();
node.update_task = null; node.update_task = null;
graph_live_update = true;
}, timeout); }, timeout);
} }

View file

@ -208,11 +208,6 @@ async function load_init() {
}); });
} }
// List of 'raw' "none" items (No Helmet, etc), in order helmet, chestplate... ring1, ring2, brace, neck, weapon.
for (const it of item_types) {
itemLists.set(it, []);
}
let none_items = [ let none_items = [
["armor", "helmet", "No Helmet"], ["armor", "helmet", "No Helmet"],
["armor", "chestplate", "No Chestplate"], ["armor", "chestplate", "No Chestplate"],
@ -251,7 +246,11 @@ for (let i = 0; i < none_items.length; i++) {
} }
function init_maps() { function init_maps() {
//warp // List of 'raw' "none" items (No Helmet, etc), in order helmet, chestplate... ring1, ring2, brace, neck, weapon.
for (const it of item_types) {
itemLists.set(it, []);
}
itemMap = new Map(); itemMap = new Map();
/* Mapping from item names to set names. */ /* Mapping from item names to set names. */
idMap = new Map(); idMap = new Map();