Use normalized path for correctActorModelPath

This commit is contained in:
elsid 2024-10-19 14:07:47 +02:00
parent 376911f645
commit afa769408a
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
10 changed files with 30 additions and 25 deletions

View file

@ -142,22 +142,23 @@ std::string Misc::ResourceHelpers::correctBookartPath(
return image;
}
std::string Misc::ResourceHelpers::correctActorModelPath(std::string_view resPath, const VFS::Manager* vfs)
VFS::Path::Normalized Misc::ResourceHelpers::correctActorModelPath(
VFS::Path::NormalizedView resPath, const VFS::Manager* vfs)
{
std::string mdlname(resPath);
std::string::size_type p = mdlname.find_last_of("/\\");
std::string mdlname(resPath.value());
std::string::size_type p = mdlname.find_last_of('/');
if (p != std::string::npos)
mdlname.insert(mdlname.begin() + p + 1, 'x');
mdlname.insert(mdlname.begin() + static_cast<std::string::difference_type>(p) + 1, 'x');
else
mdlname.insert(mdlname.begin(), 'x');
std::string kfname = mdlname;
if (Misc::StringUtils::ciEndsWith(kfname, ".nif"))
kfname.replace(kfname.size() - 4, 4, ".kf");
VFS::Path::Normalized kfname(mdlname);
if (Misc::getFileExtension(mdlname) == "nif")
kfname.changeExtension("kf");
if (!vfs->exists(kfname))
{
return std::string(resPath);
}
return VFS::Path::Normalized(resPath);
return mdlname;
}