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

Method FindLegacyObject

src/openrct2/object/ImageTable.cpp:382–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380 }
381
382 std::string ImageTable::FindLegacyObject(const std::string& name)
383 {
384 const auto& env = GetContext()->GetPlatformEnvironment();
385 auto objectsPath = env.GetDirectoryPath(DirBase::rct2, DirId::objects);
386 auto objectPath = Path::Combine(objectsPath, name);
387 if (File::Exists(objectPath))
388 {
389 return objectPath;
390 }
391
392 std::string altName = name;
393 auto rangeStart = name.find(".DAT");
394 if (rangeStart != std::string::npos)
395 {
396 altName.replace(rangeStart, 4, ".POB");
397 }
398 objectPath = Path::Combine(objectsPath, altName);
399 if (File::Exists(objectPath))
400 {
401 return objectPath;
402 }
403
404 if (!File::Exists(objectPath))
405 {
406 // Search recursively for any file with the target name (case insensitive)
407 auto filter = Path::Combine(objectsPath, u8"*.dat;*.pob");
408 auto scanner = Path::ScanDirectory(filter, true);
409 while (scanner->Next())
410 {
411 auto currentName = Path::GetFileName(scanner->GetPathRelative());
412 if (String::iequals(currentName, name) || String::iequals(currentName, altName))
413 {
414 objectPath = scanner->GetPath();
415 break;
416 }
417 }
418 }
419 return objectPath;
420 }
421
422 ImageTable::~ImageTable()
423 {

Callers

nothing calls this directly

Calls 10

GetContextFunction · 0.85
ExistsFunction · 0.85
GetFileNameFunction · 0.85
iequalsFunction · 0.85
GetDirectoryPathMethod · 0.80
findMethod · 0.80
NextMethod · 0.80
GetPathRelativeMethod · 0.80
CombineFunction · 0.50
GetPathMethod · 0.45

Tested by

no test coverage detected