diff --git a/bt/bt_instance.h b/bt/bt_instance.h index d68c92a..83dbf78 100644 --- a/bt/bt_instance.h +++ b/bt/bt_instance.h @@ -18,7 +18,7 @@ class BTInstance : public RefCounted { private: Ref root_task; - uint64_t owner_node_id; + uint64_t owner_node_id = 0; String source_bt_path; BT::Status last_status = BT::FRESH; @@ -39,7 +39,7 @@ protected: public: _FORCE_INLINE_ Ref get_root_task() const { return root_task; } - _FORCE_INLINE_ Node *get_owner_node() const { return Object::cast_to(OBJECT_DB_GET_INSTANCE(owner_node_id)); } + _FORCE_INLINE_ Node *get_owner_node() const { return owner_node_id ? Object::cast_to(OBJECT_DB_GET_INSTANCE(owner_node_id)) : nullptr; } _FORCE_INLINE_ BT::Status get_last_status() const { return last_status; } _FORCE_INLINE_ bool is_instance_valid() const { return root_task.is_valid(); } _FORCE_INLINE_ String get_source_bt_path() const { return source_bt_path; } diff --git a/editor/debugger/behavior_tree_data.h b/editor/debugger/behavior_tree_data.h index e909757..8391250 100644 --- a/editor/debugger/behavior_tree_data.h +++ b/editor/debugger/behavior_tree_data.h @@ -47,7 +47,7 @@ public: }; List tasks; - uint64_t bt_instance_id; + uint64_t bt_instance_id = 0; NodePath node_owner_path; String source_bt_path; diff --git a/editor/debugger/limbo_debugger.cpp b/editor/debugger/limbo_debugger.cpp index 4f3fc11..e4abe35 100644 --- a/editor/debugger/limbo_debugger.cpp +++ b/editor/debugger/limbo_debugger.cpp @@ -132,6 +132,7 @@ bool LimboDebugger::is_active() const { } void LimboDebugger::_track_tree(uint64_t p_instance_id) { + ERR_FAIL_COND(p_instance_id == 0); ERR_FAIL_COND(!active_bt_instances.has(p_instance_id)); _untrack_tree(); diff --git a/editor/debugger/limbo_debugger.h b/editor/debugger/limbo_debugger.h index 9b8e446..9149026 100644 --- a/editor/debugger/limbo_debugger.h +++ b/editor/debugger/limbo_debugger.h @@ -49,7 +49,7 @@ protected: #ifdef DEBUG_ENABLED private: HashSet active_bt_instances; - uint64_t tracked_instance_id; + uint64_t tracked_instance_id = 0; bool session_active = false; void _track_tree(uint64_t p_instance_id); diff --git a/editor/debugger/limbo_debugger_plugin.h b/editor/debugger/limbo_debugger_plugin.h index 0da1567..8ef3db9 100644 --- a/editor/debugger/limbo_debugger_plugin.h +++ b/editor/debugger/limbo_debugger_plugin.h @@ -52,7 +52,7 @@ class LimboDebuggerTab : public PanelContainer { private: struct BTInstanceInfo { - uint64_t instance_id; + uint64_t instance_id = 0; String owner_node_path; };