From 3307fd16a3ac9d6fd1f920ebe19e311ab634b06f Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Fri, 23 Aug 2024 15:30:59 -0400 Subject: [PATCH] GH-774 Relax return node validation for sequence nodes --- src/script/nodes/flow_control/sequence.h | 3 +++ src/script/nodes/functions/function_result.cpp | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/script/nodes/flow_control/sequence.h b/src/script/nodes/flow_control/sequence.h index 0d7e1235..e0eedfa1 100644 --- a/src/script/nodes/flow_control/sequence.h +++ b/src/script/nodes/flow_control/sequence.h @@ -58,6 +58,9 @@ class OScriptNodeSequence : public OScriptEditablePinNode void remove_dynamic_pin(const Ref& p_pin) override; String get_pin_prefix() const override { return "then"; } //~ End OScriptEditablePinNode Interface + + // Get the number of configured steps + int get_steps() const { return _steps; } }; #endif // ORCHESTRATOR_SCRIPT_NODE_SEQUENCE_H diff --git a/src/script/nodes/functions/function_result.cpp b/src/script/nodes/functions/function_result.cpp index ec9af314..ad8fed32 100644 --- a/src/script/nodes/functions/function_result.cpp +++ b/src/script/nodes/functions/function_result.cpp @@ -17,6 +17,7 @@ #include "function_result.h" #include "common/property_utils.h" +#include "script/nodes/flow_control/sequence.h" class OScriptNodeFunctionResultInstance : public OScriptNodeInstance { @@ -137,8 +138,22 @@ void OScriptNodeFunctionResult::validate_node_during_build(BuildLog& p_log) cons const Ref source = graph_nodes[E.from_node]; if (source.is_valid()) { + const Ref sequence = source; + if (source->is_loop_port(E.from_port)) + { skipped.insert(E.to_node); + } + else if (sequence.is_valid()) + { + // Sequence nodes are designed to execute each "Then X" output pin in sequential + // order and therefore, only the last sequence output port should be mandated to + // connect to a return node, skipping the prior branches similar to loops. + const int steps = sequence->get_steps(); + if (E.from_port < (steps - 1)) + skipped.insert(E.to_node); + } + } if (skipped.has(E.from_node))