Skip to content

Commit

Permalink
Fix another potential crash related to debugger not being active
Browse files Browse the repository at this point in the history
  • Loading branch information
limbonaut committed Dec 28, 2023
1 parent 9e33b81 commit 4cf5a18
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bt/bt_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "modules/limboai/hsm/limbo_state.h"
#include "modules/limboai/util/limbo_string_names.h"

#include "core/debugger/engine_debugger.h"
#include "core/error/error_macros.h"
#include "core/object/class_db.h"
#include "core/variant/variant.h"
Expand All @@ -24,7 +25,9 @@ void BTState::_setup() {
tree_instance = behavior_tree->instantiate(get_agent(), get_blackboard());

#ifdef DEBUG_ENABLED
LimboDebugger::get_singleton()->register_bt_instance(tree_instance, get_path());
if (tree_instance.is_valid() && EngineDebugger::is_active()) {
LimboDebugger::get_singleton()->register_bt_instance(tree_instance, get_path());
}
#endif
}

Expand All @@ -48,12 +51,12 @@ void BTState::_update(double p_delta) {
void BTState::_notification(int p_notification) {
switch (p_notification) {
case NOTIFICATION_ENTER_TREE: {
if (tree_instance.is_valid()) {
if (tree_instance.is_valid() && EngineDebugger::is_active()) {
LimboDebugger::get_singleton()->register_bt_instance(tree_instance, get_path());
}
} break;
case NOTIFICATION_EXIT_TREE: {
if (tree_instance.is_valid()) {
if (tree_instance.is_valid() && EngineDebugger::is_active()) {
LimboDebugger::get_singleton()->unregister_bt_instance(tree_instance, get_path());
}
} break;
Expand Down

0 comments on commit 4cf5a18

Please sign in to comment.