Fix crash when debugging BT node state while tree is not running
This commit is contained in:
@@ -170,7 +170,11 @@ void Behavior::OnDisable()
|
||||
|
||||
bool Behavior::GetNodeDebugRelevancy(const BehaviorTreeNode* node, const Behavior* behavior)
|
||||
{
|
||||
return node && behavior && node->_executionIndex != -1 && behavior->_knowledge.RelevantNodes.Get(node->_executionIndex);
|
||||
return node &&
|
||||
behavior &&
|
||||
node->_executionIndex >= 0 &&
|
||||
node->_executionIndex < behavior->_knowledge.RelevantNodes.Count() &&
|
||||
behavior->_knowledge.RelevantNodes.Get(node->_executionIndex);
|
||||
}
|
||||
|
||||
String Behavior::GetNodeDebugInfo(const BehaviorTreeNode* node, Behavior* behavior)
|
||||
@@ -179,7 +183,7 @@ String Behavior::GetNodeDebugInfo(const BehaviorTreeNode* node, Behavior* behavi
|
||||
return String::Empty;
|
||||
BehaviorUpdateContext context;
|
||||
Platform::MemoryClear(&context, sizeof(context));
|
||||
if (behavior && node->_executionIndex != -1 && behavior->_knowledge.RelevantNodes.Get(node->_executionIndex))
|
||||
if (GetNodeDebugRelevancy(node, behavior))
|
||||
{
|
||||
// Pass behavior and knowledge data only for relevant nodes to properly access it
|
||||
context.Behavior = behavior;
|
||||
|
||||
Reference in New Issue
Block a user