Use normalized path in PreloadItem

pull/3236/head
elsid 3 months ago
parent 1d98b5c66b
commit 7a5c478e34
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -11,6 +11,7 @@
#include <components/esm3/loadcell.hpp> #include <components/esm3/loadcell.hpp>
#include <components/loadinglistener/reporter.hpp> #include <components/loadinglistener/reporter.hpp>
#include <components/misc/constants.hpp> #include <components/misc/constants.hpp>
#include <components/misc/pathhelpers.hpp>
#include <components/misc/resourcehelpers.hpp> #include <components/misc/resourcehelpers.hpp>
#include <components/misc/strings/algorithm.hpp> #include <components/misc/strings/algorithm.hpp>
#include <components/misc/strings/lower.hpp> #include <components/misc/strings/lower.hpp>
@ -105,8 +106,8 @@ namespace MWWorld
} }
} }
std::string mesh; VFS::Path::Normalized mesh;
std::string kfname; VFS::Path::Normalized kfname;
for (std::string_view path : mMeshes) for (std::string_view path : mMeshes)
{ {
if (mAbort) if (mAbort)
@ -121,19 +122,15 @@ namespace MWWorld
if (!vfs.exists(mesh)) if (!vfs.exists(mesh))
continue; continue;
size_t slashpos = mesh.find_last_of("/\\"); if (Misc::getFileName(mesh).starts_with('x') && Misc::getFileExtension(mesh) == "nif")
if (slashpos != std::string::npos && slashpos != mesh.size() - 1)
{ {
if (Misc::StringUtils::toLower(mesh[slashpos + 1]) == 'x' kfname = mesh;
&& Misc::StringUtils::ciEndsWith(mesh, ".nif")) kfname.changeExtension("kf");
{ if (vfs.exists(kfname))
kfname = mesh; mPreloadedObjects.insert(mKeyframeManager->get(kfname));
kfname.replace(kfname.size() - 4, 4, ".kf");
if (vfs.exists(kfname))
mPreloadedObjects.insert(mKeyframeManager->get(kfname));
}
} }
mPreloadedObjects.insert(mSceneManager->getTemplate(VFS::Path::toNormalized(mesh)));
mPreloadedObjects.insert(mSceneManager->getTemplate(mesh));
if (mPreloadInstances) if (mPreloadInstances)
mPreloadedObjects.insert(mBulletShapeManager->cacheInstance(mesh)); mPreloadedObjects.insert(mBulletShapeManager->cacheInstance(mesh));
else else

Loading…
Cancel
Save