Fix loading null as Guid for object refs in C++ Json parser
This commit is contained in:
@@ -188,7 +188,7 @@ void GameSettings::Deserialize(DeserializeStream& stream, ISerializeModifier* mo
|
||||
SplashScreen = JsonTools::GetGuid(stream, "SplashScreen");
|
||||
CustomSettings.Clear();
|
||||
const auto customSettings = stream.FindMember("CustomSettings");
|
||||
if (customSettings != stream.MemberEnd())
|
||||
if (customSettings != stream.MemberEnd() && customSettings->value.IsArray())
|
||||
{
|
||||
auto& items = customSettings->value;
|
||||
for (auto it = items.MemberBegin(); it != items.MemberEnd(); ++it)
|
||||
|
||||
@@ -103,6 +103,28 @@ Matrix JsonTools::GetMatrix(const Value& value)
|
||||
return result;
|
||||
}
|
||||
|
||||
Guid JsonTools::GetGuid(const Value& value)
|
||||
{
|
||||
if (value.IsNull())
|
||||
return Guid::Empty;
|
||||
CHECK_RETURN(value.GetStringLength() == 32, Guid::Empty);
|
||||
|
||||
// Split
|
||||
const char* a = value.GetString();
|
||||
const char* b = a + 8;
|
||||
const char* c = b + 8;
|
||||
const char* d = c + 8;
|
||||
|
||||
// Parse
|
||||
Guid result;
|
||||
StringUtils::ParseHex(a, 8, &result.A);
|
||||
StringUtils::ParseHex(b, 8, &result.B);
|
||||
StringUtils::ParseHex(c, 8, &result.C);
|
||||
StringUtils::ParseHex(d, 8, &result.D);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
DateTime JsonTools::GetDate(const Value& value)
|
||||
{
|
||||
return DateTime(value.GetInt64());
|
||||
|
||||
@@ -174,24 +174,7 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
static Guid GetGuid(const Value& value)
|
||||
{
|
||||
CHECK_RETURN(value.GetStringLength() == 32, Guid::Empty);
|
||||
|
||||
// Split
|
||||
const char* a = value.GetString();
|
||||
const char* b = a + 8;
|
||||
const char* c = b + 8;
|
||||
const char* d = c + 8;
|
||||
|
||||
// Parse
|
||||
Guid result;
|
||||
StringUtils::ParseHex(a, 8, &result.A);
|
||||
StringUtils::ParseHex(b, 8, &result.B);
|
||||
StringUtils::ParseHex(c, 8, &result.C);
|
||||
StringUtils::ParseHex(d, 8, &result.D);
|
||||
return result;
|
||||
}
|
||||
static Guid GetGuid(const Value& value);
|
||||
|
||||
static DateTime GetDate(const Value& value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user