mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Use normalized path for correctActorModelPath
This commit is contained in:
parent
376911f645
commit
afa769408a
10 changed files with 30 additions and 25 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue