From 2599aba19625074c7c03fb8a13f660d56803e7bd Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 8 Jul 2018 20:36:04 +0300 Subject: [PATCH 1/3] Fix check whether file name starts with x or X If path doens't contains / or \, then slashpos will be 0. Therefore slashpos + 1 = 1 doesn't point to first symbol. xmesh.nif ^ slashpos + 1 --- components/nifbullet/bulletnifloader.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index 8f827e4e2..a7afabf8f 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -88,18 +88,13 @@ osg::ref_ptr BulletNifLoader::load(const Nif::NIFFilePtr& else { bool autogenerated = hasAutoGeneratedCollision(node); - bool isAnimated = false; // files with the name convention xmodel.nif usually have keyframes stored in a separate file xmodel.kf (see Animation::addAnimSource). // assume all nodes in the file will be animated std::string filename = nif->getFilename(); - size_t slashpos = filename.find_last_of("/\\"); - if (slashpos == std::string::npos) - slashpos = 0; - if (slashpos+1 < filename.size() && (filename[slashpos+1] == 'x' || filename[slashpos+1] == 'X')) - { - isAnimated = true; - } + const std::size_t slashpos = filename.find_last_of("/\\"); + const std::size_t letterPos = slashpos == std::string::npos ? 0 : slashpos + 1; + const bool isAnimated = letterPos < filename.size() && (filename[letterPos] == 'x' || filename[letterPos] == 'X'); handleNode(node, 0, autogenerated, isAnimated, autogenerated); From 3f21c49479e1927f8ceea2345bc91717e1e9fb8f Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 8 Jul 2018 20:52:16 +0300 Subject: [PATCH 2/3] Put check for nif file name into separate function --- components/nifbullet/bulletnifloader.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index a7afabf8f..be5a7d9d6 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -34,6 +34,13 @@ btVector3 getbtVector(const osg::Vec3f &v) return btVector3(v.x(), v.y(), v.z()); } +bool pathFileNameStartsWithX(const std::string& path) +{ + const std::size_t slashpos = path.find_last_of("/\\"); + const std::size_t letterPos = slashpos == std::string::npos ? 0 : slashpos + 1; + return letterPos < path.size() && (path[letterPos] == 'x' || path[letterPos] == 'X'); +} + } namespace NifBullet @@ -91,10 +98,7 @@ osg::ref_ptr BulletNifLoader::load(const Nif::NIFFilePtr& // files with the name convention xmodel.nif usually have keyframes stored in a separate file xmodel.kf (see Animation::addAnimSource). // assume all nodes in the file will be animated - std::string filename = nif->getFilename(); - const std::size_t slashpos = filename.find_last_of("/\\"); - const std::size_t letterPos = slashpos == std::string::npos ? 0 : slashpos + 1; - const bool isAnimated = letterPos < filename.size() && (filename[letterPos] == 'x' || filename[letterPos] == 'X'); + const bool isAnimated = pathFileNameStartsWithX(nif->getFilename()); handleNode(node, 0, autogenerated, isAnimated, autogenerated); From 686830a6e32b3cc8615df3eb665d15c5469e6ffd Mon Sep 17 00:00:00 2001 From: elsid Date: Tue, 10 Jul 2018 23:52:51 +0300 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44c7398ba..9223b891d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,7 +61,8 @@ Bug #4489: Goodbye doesn't block dialogue hyperlinks Bug #4490: PositionCell on player gives "Error: tried to add local script twice" Bug #4491: Training cap based off Base Skill instead of Modified Skill - Bug #4495: Crossbow animations blending is buggy + Bug #4495: Crossbow animations blending is buggy + Bug #4497: File names starting with x or X are not classified as animation Bug #3249: Fixed revert function not updating views properly Feature #2606: Editor: Implemented (optional) case sensitive global search Feature #3276: Editor: Search- Show number of (remaining) search results and indicate a search without any results