Core: Require game mod descriptor json to self-identify as one.

This commit is contained in:
Admiral H. Curtiss 2021-12-09 00:01:10 +01:00
parent f4e2d369c0
commit b50861ea44
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
1 changed files with 7 additions and 2 deletions

View File

@ -115,10 +115,15 @@ std::optional<GameModDescriptor> ParseGameModDescriptorString(std::string_view j
return std::nullopt;
GameModDescriptor descriptor;
bool is_game_mod_descriptor = false;
bool is_valid_version = false;
for (const auto& [key, value] : json_root.get<picojson::object>())
{
if (key == "version" && value.is<double>())
if (key == "type" && value.is<std::string>())
{
is_game_mod_descriptor = value.get<std::string>() == "dolphin-game-mod-descriptor";
}
else if (key == "version" && value.is<double>())
{
is_valid_version = value.get<double>() == 1.0;
}
@ -140,7 +145,7 @@ std::optional<GameModDescriptor> ParseGameModDescriptorString(std::string_view j
ParseRiivolutionObject(json_directory, value.get<picojson::object>());
}
}
if (!is_valid_version)
if (!is_game_mod_descriptor || !is_valid_version)
return std::nullopt;
return descriptor;
}