Create function to create object from file

This commit is contained in:
Gymnasiast committed 2025-09-21 21:18:22 +02:00
1 parent db5f56f4aa
commit 161a8359fc
3 files changed
+26 -26

No files matched your search

+2 -26
View File
@@ -98,20 +98,7 @@ namespace OpenRCT2
public:
std::optional<ObjectRepositoryItem> Create([[maybe_unused]] int32_t language, const std::string& path) const override
{
std::unique_ptr<Object> object;
auto extension = Path::GetExtension(path);
if (String::iequals(extension, ".json"))
{
object = ObjectFactory::CreateObjectFromJsonFile(_objectRepository, path, false);
}
else if (String::iequals(extension, ".parkobj"))
{
object = ObjectFactory::CreateObjectFromZipFile(_objectRepository, path, false);
}
else
{
object = ObjectFactory::CreateObjectFromLegacyFile(_objectRepository, path.c_str(), false);
}
std::unique_ptr<Object> object = ObjectFactory::CreateObjectFromFile(_objectRepository, path, false);
// All official DAT files have a JSON object counterpart. Avoid loading the obsolete .DAT versions,
// which can happen if the user copies the official DAT objects to their custom content folder.
@@ -271,18 +258,7 @@ namespace OpenRCT2
std::unique_ptr<Object> LoadObject(const ObjectRepositoryItem* ori) override
{
Guard::ArgumentNotNull(ori, GUARD_LINE);
auto extension = Path::GetExtension(ori->Path);
if (String::iequals(extension, ".json"))
{
return ObjectFactory::CreateObjectFromJsonFile(*this, ori->Path, !gOpenRCT2NoGraphics);
}
if (String::iequals(extension, ".parkobj"))
{
return ObjectFactory::CreateObjectFromZipFile(*this, ori->Path, !gOpenRCT2NoGraphics);
}
return ObjectFactory::CreateObjectFromLegacyFile(*this, ori->Path.c_str(), !gOpenRCT2NoGraphics);
return ObjectFactory::CreateObjectFromFile(*this, ori->Path, !gOpenRCT2NoGraphics);
}
void RegisterLoadedObject(const ObjectRepositoryItem* ori, std::unique_ptr<Object>&& object) override