Skip to content

Commit

Permalink
GH-774 Relax return node validation for sequence nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed Aug 23, 2024
1 parent 301fd21 commit 3307fd1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/script/nodes/flow_control/sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class OScriptNodeSequence : public OScriptEditablePinNode
void remove_dynamic_pin(const Ref<OScriptNodePin>& 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
15 changes: 15 additions & 0 deletions src/script/nodes/functions/function_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "function_result.h"

#include "common/property_utils.h"
#include "script/nodes/flow_control/sequence.h"

class OScriptNodeFunctionResultInstance : public OScriptNodeInstance
{
Expand Down Expand Up @@ -137,8 +138,22 @@ void OScriptNodeFunctionResult::validate_node_during_build(BuildLog& p_log) cons
const Ref<OScriptNode> source = graph_nodes[E.from_node];
if (source.is_valid())
{
const Ref<OScriptNodeSequence> 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))
Expand Down

0 comments on commit 3307fd1

Please sign in to comment.