From c4dbd8a7445e74dd0b6959de56c952bad7da1a21 Mon Sep 17 00:00:00 2001 From: sumit0190 Date: Sun, 9 Feb 2020 00:46:13 -0500 Subject: Read and write exported infs/nans correctly (#35388) --- core/variant_parser.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 6ca9d6c246..f22ffda665 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -512,6 +512,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 args; @@ -1586,8 +1590,10 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str case Variant::REAL: { 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: { -- cgit v1.2.3