diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-06-26 16:48:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-26 16:48:21 +0200 |
commit | 2c96942df9318ea8a4f3ad06d007e46e3108fa48 (patch) | |
tree | 7bbadae4a12d3a21c35f8f7fdef69018ebde010d /scene | |
parent | 261bdfa14dd548b9872bcaaf1b3d729ea0428295 (diff) | |
parent | 6e9272eea81b594476a48a1b968a38212d773bf2 (diff) |
Merge pull request #30088 from akien-mga/node-get_node_and_resource
Node: Fix logic of has/get_node_and_resource and document it
Diffstat (limited to 'scene')
-rw-r--r-- | scene/main/node.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index ee23b24b3c..26186638d7 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2477,21 +2477,18 @@ bool Node::has_node_and_resource(const NodePath &p_path) const { if (!has_node(p_path)) return false; - Node *node = get_node(p_path); - - bool result = false; - - node->get_indexed(p_path.get_subnames(), &result); + RES res; + Vector<StringName> leftover_path; + Node *node = get_node_and_resource(p_path, res, leftover_path, false); - return result; + return (node && res.is_valid()); } Array Node::_get_node_and_resource(const NodePath &p_path) { - Node *node; RES res; Vector<StringName> leftover_path; - node = get_node_and_resource(p_path, res, leftover_path); + Node *node = get_node_and_resource(p_path, res, leftover_path, false); Array result; if (node) @@ -2521,7 +2518,7 @@ Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<Str int j = 0; // If not p_last_is_property, we shouldn't consider the last one as part of the resource - for (; j < p_path.get_subname_count() - p_last_is_property; j++) { + for (; j < p_path.get_subname_count() - (int)p_last_is_property; j++) { RES new_res = j == 0 ? node->get(p_path.get_subname(j)) : r_res->get(p_path.get_subname(j)); if (new_res.is_null()) { |