Compare commits

..

2 Commits

Author SHA1 Message Date
Serhii Snitsaruk 2ca9de6dbf
Warn about type mismatch when populating blackboard 2024-08-15 22:44:10 +02:00
Serhii Snitsaruk 7e83c1f246
Fix BTState overwriting blackboard variables on init 2024-08-15 22:15:53 +02:00
2 changed files with 2 additions and 3 deletions

View File

@ -13,6 +13,7 @@
#define BLACKBOARD_H #define BLACKBOARD_H
#include "bb_variable.h" #include "bb_variable.h"
#include "core/typedefs.h"
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
#include "core/object/object.h" #include "core/object/object.h"

View File

@ -417,14 +417,12 @@ void BlackboardPlan::populate_blackboard(const Ref<Blackboard> &p_blackboard, bo
ERR_FAIL_COND(p_blackboard.is_null()); ERR_FAIL_COND(p_blackboard.is_null());
for (const Pair<StringName, BBVariable> &p : var_list) { for (const Pair<StringName, BBVariable> &p : var_list) {
if (p_blackboard->has_local_var(p.first) && !overwrite) { if (p_blackboard->has_local_var(p.first) && !overwrite) {
#ifdef DEBUG_ENABLED
Variant::Type existing_type = p_blackboard->get_var(p.first).get_type(); Variant::Type existing_type = p_blackboard->get_var(p.first).get_type();
Variant::Type planned_type = p.second.get_type(); Variant::Type planned_type = p.second.get_type();
if (existing_type != planned_type && existing_type != Variant::NIL && planned_type != Variant::NIL && !(existing_type == Variant::OBJECT && planned_type == Variant::NODE_PATH)) { if (existing_type != planned_type && existing_type != Variant::NIL && planned_type != Variant::NIL) {
WARN_PRINT(vformat("BlackboardPlan: Not overwriting %s as it already exists in the blackboard, but it has a different type than planned (%s vs %s). File: %s", WARN_PRINT(vformat("BlackboardPlan: Not overwriting %s as it already exists in the blackboard, but it has a different type than planned (%s vs %s). File: %s",
LimboUtility::get_singleton()->decorate_var(p.first), Variant::get_type_name(existing_type), Variant::get_type_name(planned_type), get_path())); LimboUtility::get_singleton()->decorate_var(p.first), Variant::get_type_name(existing_type), Variant::get_type_name(planned_type), get_path()));
} }
#endif
continue; continue;
} }
bool has_mapping = parent_scope_mapping.has(p.first); bool has_mapping = parent_scope_mapping.has(p.first);