| 490 | } |
| 491 | |
| 492 | static void ExtractSourceGames(const std::string& id, json_t& jRoot, Object& result) |
| 493 | { |
| 494 | auto sourceGames = jRoot["sourceGame"]; |
| 495 | if (sourceGames.is_array() || sourceGames.is_string()) |
| 496 | { |
| 497 | std::vector<ObjectSourceGame> sourceGameVector; |
| 498 | for (const auto& jSourceGame : sourceGames) |
| 499 | { |
| 500 | sourceGameVector.push_back(ParseSourceGame(Json::GetString(jSourceGame))); |
| 501 | } |
| 502 | if (!sourceGameVector.empty()) |
| 503 | { |
| 504 | result.SetSourceGames(sourceGameVector); |
| 505 | } |
| 506 | else |
| 507 | { |
| 508 | LOG_ERROR("Object %s has an incorrect sourceGame parameter.", id.c_str()); |
| 509 | result.SetSourceGames({ ObjectSourceGame::custom }); |
| 510 | } |
| 511 | } |
| 512 | // >90% of objects are custom, so allow omitting the parameter without displaying an error. |
| 513 | else if (sourceGames.is_null()) |
| 514 | { |
| 515 | result.SetSourceGames({ ObjectSourceGame::custom }); |
| 516 | } |
| 517 | else |
| 518 | { |
| 519 | LOG_ERROR("Object %s has an incorrect sourceGame parameter.", id.c_str()); |
| 520 | result.SetSourceGames({ ObjectSourceGame::custom }); |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | static bool isUsingClassic() |
| 525 | { |
no test coverage detected