summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2019-01-15 19:50:48 -0200
committerGeorge Marques <george@gmarqu.es>2019-01-15 19:50:48 -0200
commit31433ae8e4159d01ed57c334c72eb8593185b145 (patch)
tree6984a64b18897b2e6afcb2ed5613e7624d09656d
parent4f72c6be8a7eb1876fc1c6ea35eadf31c81a674a (diff)
GDScript: check for underscore prefix when type-checking
Some classes are represented internally with an underscore prefix, so we need to make sure we match this representation when type-checking, otherwise the check might fail on a valid scenario.
-rw-r--r--modules/gdscript/gdscript_function.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h
index aab1af1250..f4058664ff 100644
--- a/modules/gdscript/gdscript_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -74,8 +74,14 @@ struct GDScriptDataType {
return false;
}
Object *obj = p_variant.operator Object *();
- if (obj && !ClassDB::is_parent_class(obj->get_class_name(), native_type)) {
- return false;
+ if (obj) {
+ if (!ClassDB::is_parent_class(obj->get_class_name(), native_type)) {
+ // Try with underscore prefix
+ StringName underscore_native_type = "_" + native_type;
+ if (!ClassDB::is_parent_class(obj->get_class_name(), underscore_native_type)) {
+ return false;
+ }
+ }
}
return true;
} break;