From d48daf2135dd136298f2aea8d4768214ce261a9d Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Mon, 1 Apr 2024 01:45:40 +0200 Subject: [PATCH] BlackboardPlan: Avoid circular references in derived mode If the same plan resource is assigned in BehaviorTree and in BTPlayer, simply use the resource as is. Using the same resource for `BehaviorTree` and `BTPlayer` will disable derived mode, and allow managing from `BTPlayer` . There is a risk of using `NodePath` variables with different scenes: the path may actually be different if node structure is not the same. It will lead to fetching breaking for some of those scenes. --- blackboard/blackboard_plan.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blackboard/blackboard_plan.cpp b/blackboard/blackboard_plan.cpp index a430187..4545a6b 100644 --- a/blackboard/blackboard_plan.cpp +++ b/blackboard/blackboard_plan.cpp @@ -121,7 +121,11 @@ bool BlackboardPlan::_property_get_revert(const StringName &p_name, Variant &r_p } void BlackboardPlan::set_base_plan(const Ref &p_base) { - base = p_base; + if (p_base == this) { + base.unref(); + } else { + base = p_base; + } sync_with_base_plan(); notify_property_list_changed(); }