Skip to content

Commit

Permalink
Merge pull request #36042 from sumit0190/exportInfNan
Browse files Browse the repository at this point in the history
Read and write exported infs/nans correctly (#35388)
  • Loading branch information
akien-mga authored Mar 4, 2020
2 parents 7ece081 + c4dbd8a commit 59290f9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/variant_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit 59290f9

Please sign in to comment.