Allow loading images from .pob files (#15122)

This commit is contained in:
Michael Steenbeek authored and GitHub committed 2021-07-28 21:25:51 +02:00
1 parent 87007ba2a3
commit 71ff9bf6d6
2 files changed
+20 -3

No files matched your search

+19 -2
View File
@@ -270,15 +270,32 @@ std::string ImageTable::FindLegacyObject(const std::string& name)
const auto env = GetContext()->GetPlatformEnvironment();
auto objectsPath = env->GetDirectoryPath(DIRBASE::RCT2, DIRID::OBJECT);
auto objectPath = Path::Combine(objectsPath, name);
if (File::Exists(objectPath))
{
return objectPath;
}
std::string altName = name;
auto rangeStart = name.find(".DAT");
if (rangeStart != std::string::npos)
{
altName.replace(rangeStart, 4, ".POB");
}
objectPath = Path::Combine(objectsPath, altName);
if (File::Exists(objectPath))
{
return objectPath;
}
if (!File::Exists(objectPath))
{
// Search recursively for any file with the target name (case insensitive)
auto filter = Path::Combine(objectsPath, "*.dat");
auto filter = Path::Combine(objectsPath, "*.dat;*.pob");
auto scanner = Path::ScanDirectory(filter, true);
while (scanner->Next())
{
auto currentName = Path::GetFileName(scanner->GetPathRelative());
if (String::Equals(currentName, name, true))
if (String::Equals(currentName, name, true) || String::Equals(currentName, altName, true))
{
objectPath = scanner->GetPath();
break;