summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorDmitrii Maganov <vonagam@gmail.com>2023-02-13 22:02:52 +0200
committerDmitrii Maganov <vonagam@gmail.com>2023-02-13 22:06:38 +0200
commit9cb2da89d6a763b497f87ff92bdbe8a7cc0258a8 (patch)
tree9770f43f84e97567b68958dc15e67d29a3718f2f /core
parent854d9c3d9c77270ff3260a8edcc12fccc85514c1 (diff)
GDScript: Fix usage of ints with typed array of floats
Diffstat (limited to 'core')
-rw-r--r--core/variant/container_type_validate.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/variant/container_type_validate.h b/core/variant/container_type_validate.h
index ad679db9d0..ffe1dc90a3 100644
--- a/core/variant/container_type_validate.h
+++ b/core/variant/container_type_validate.h
@@ -73,7 +73,7 @@ struct ContainerTypeValidate {
return type != p_type.type || class_name != p_type.class_name || script != p_type.script;
}
- // Coerces String and StringName into each other when needed.
+ // Coerces String and StringName into each other and int into float when needed.
_FORCE_INLINE_ bool validate(Variant &inout_variant, const char *p_operation = "use") const {
if (type == Variant::NIL) {
return true;
@@ -89,6 +89,9 @@ struct ContainerTypeValidate {
} else if (type == Variant::STRING_NAME && inout_variant.get_type() == Variant::STRING) {
inout_variant = StringName(inout_variant);
return true;
+ } else if (type == Variant::FLOAT && inout_variant.get_type() == Variant::INT) {
+ inout_variant = (float)inout_variant;
+ return true;
}
ERR_FAIL_V_MSG(false, "Attempted to " + String(p_operation) + " a variable of type '" + Variant::get_type_name(inout_variant.get_type()) + "' into a " + where + " of type '" + Variant::get_type_name(type) + "'.");