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

Method Create

src/openrct2/object/ObjectRepository.cpp:95–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93
94 public:
95 std::optional<ObjectRepositoryItem> Create([[maybe_unused]] int32_t language, const std::string& path) const override
96 {
97 std::unique_ptr<Object> object = ObjectFactory::CreateObjectFromFile(path, false);
98
99 // All official DAT files have a JSON object counterpart. Avoid loading the obsolete .DAT versions,
100 // which can happen if the user copies the official DAT objects to their custom content folder.
101 if (object == nullptr
102 || (object->GetGeneration() == ObjectGeneration::DAT
103 && object->GetObjectEntry().GetSourceGame() != ObjectSourceGame::custom))
104 {
105 return std::nullopt;
106 }
107
108 ObjectRepositoryItem item = {};
109 item.Type = object->GetObjectType();
110 item.Generation = object->GetGeneration();
111 item.Identifier = object->GetIdentifier();
112 item.ObjectEntry = object->GetObjectEntry();
113 item.Version = object->GetVersion();
114 item.Path = path;
115 item.Name = object->GetName();
116 item.Authors = object->GetAuthors();
117 item.Sources = object->GetSourceGames();
118 if (object->IsCompatibilityObject())
119 item.Flags |= ObjectItemFlags::IsCompatibilityObject;
120 object->SetRepositoryItem(&item);
121 return item;
122 }
123
124 protected:
125 void Serialise(DataSerialiser& ds, const ObjectRepositoryItem& item) const override

Callers 1

ScanObjectMethod · 0.45

Calls 9

CreateObjectFromFileFunction · 0.85
GetGenerationMethod · 0.80
GetSourceGameMethod · 0.80
GetObjectTypeMethod · 0.80
GetIdentifierMethod · 0.80
GetSourceGamesMethod · 0.80
IsCompatibilityObjectMethod · 0.80
GetNameMethod · 0.45
SetRepositoryItemMethod · 0.45

Tested by

no test coverage detected