Merge pull request #36042 from sumit0190/exportInfNan

Read and write exported infs/nans correctly (#35388)
This commit is contained in:
Rémi Verschelde 2020-03-04 10:19:52 +01:00 committed by GitHub
commit 59290f98ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -532,6 +532,10 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = false;
else if (id == "null" || id == "nil")
value = Variant();
else if (id == "inf")
value = Math_INF;
else if (id == "nan")
value = Math_NAN;
else if (id == "Vector2") {
Vector<float> args;
@ -1499,8 +1503,10 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
case Variant::FLOAT: {
String s = rtosfix(p_variant.operator real_t());
if (s.find(".") == -1 && s.find("e") == -1)
s += ".0";
if (s != "inf" && s != "nan") {
if (s.find(".") == -1 && s.find("e") == -1)
s += ".0";
}
p_store_string_func(p_store_string_ud, s);
} break;
case Variant::STRING: {