MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ExtractSourceGames

Function ExtractSourceGames

src/openrct2/object/ObjectFactory.cpp:492–522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

CreateObjectFromJsonFunction · 0.85

Calls 5

ParseSourceGameFunction · 0.85
GetStringFunction · 0.85
SetSourceGamesMethod · 0.80
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected