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

Function CreateObjectFromZipFile

src/openrct2/object/ObjectFactory.cpp:448–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446 };
447
448 std::unique_ptr<Object> CreateObjectFromZipFile(std::string_view path, bool loadImages)
449 {
450 try
451 {
452 auto archive = Zip::Open(path, ZipAccess::read);
453 auto jsonBytes = archive->GetFileData("object.json");
454 if (jsonBytes.empty())
455 {
456 throw std::runtime_error("Unable to open object.json.");
457 }
458
459 json_t jRoot = Json::FromVector(jsonBytes);
460
461 if (jRoot.is_object())
462 {
463 auto fileDataRetriever = ZipDataRetriever(path, *archive);
464 return CreateObjectFromJson(jRoot, &fileDataRetriever, loadImages, path);
465 }
466 }
467 catch (const std::exception& e)
468 {
469 Console::Error::WriteLine("Unable to open or read '%s': %s", std::string(path).c_str(), e.what());
470 }
471 return nullptr;
472 }
473
474 std::unique_ptr<Object> CreateObjectFromJsonFile(const std::string& path, bool loadImages)
475 {

Callers 1

CreateObjectFromFileFunction · 0.85

Calls 8

FromVectorFunction · 0.85
ZipDataRetrieverClass · 0.85
CreateObjectFromJsonFunction · 0.85
WriteLineFunction · 0.85
OpenFunction · 0.50
GetFileDataMethod · 0.45
emptyMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected