aboutsummaryrefslogtreecommitdiff
path: root/core/variant_op.cpp
diff options
context:
space:
mode:
authorBil Bas (Spooner)2015-02-19 15:45:49 +0000
committerBil Bas (Spooner)2015-02-19 15:45:49 +0000
commitdb2381de7afffc932d051ec9fc853bfe06645060 (patch)
treee14003d1d8d327c1511f051f1970ac2ce498d6a6 /core/variant_op.cpp
parente3bf8ab02da6a5d4f4d52aa3b1ac73df59f76282 (diff)
downloadgodot-db2381de7afffc932d051ec9fc853bfe06645060.tar.gz
godot-db2381de7afffc932d051ec9fc853bfe06645060.tar.zst
godot-db2381de7afffc932d051ec9fc853bfe06645060.zip
Diffstat (limited to 'core/variant_op.cpp')
-rw-r--r--core/variant_op.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 21bbc8c7e..10b9a67da 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -738,18 +738,22 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
_RETURN( p_a._data._int % p_b._data._int );
} else if (p_a.type==STRING) {
- const String *str=reinterpret_cast<const String*>(p_a._data._mem);
+ const String* format=reinterpret_cast<const String*>(p_a._data._mem);
+ String result;
+ bool error;
if (p_b.type==ARRAY) {
// e.g. "frog %s %d" % ["fish", 12]
- const Array *arr=reinterpret_cast<const Array*>(p_b._data._mem);
- _RETURN(str->sprintf(*arr));
+ const Array* args=reinterpret_cast<const Array*>(p_b._data._mem);
+ result=format->sprintf(*args, &error);
} else {
// e.g. "frog %d" % 12
- Array arr;
- arr.push_back(p_b);
- _RETURN(str->sprintf(arr));
+ Array args;
+ args.push_back(p_b);
+ result=format->sprintf(args, &error);
}
+ r_valid = !error;
+ _RETURN(result);
}
r_valid=false;