diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index e8a65c230..08063fa62 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -136,7 +136,7 @@ namespace MWSound max = std::max(min, max); } - return Files::FileListLocator(mSoundFiles, snd->sound, mFSStrict); + return Files::FileListLocator(mSoundFiles, snd->sound, mFSStrict, true); } // Add a sound to the list and play it @@ -376,7 +376,7 @@ namespace MWSound void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename) { // The range values are not tested - std::string filePath = Files::FileListLocator(mSoundFiles, filename, mFSStrict); + std::string filePath = Files::FileListLocator(mSoundFiles, filename, mFSStrict, true); if(!filePath.empty()) add(filePath, ptr, "_say_sound", 1, 1, 100, 20000, false); else diff --git a/components/files/filelibrary.cpp b/components/files/filelibrary.cpp index f1467166e..482b675a9 100644 --- a/components/files/filelibrary.cpp +++ b/components/files/filelibrary.cpp @@ -94,7 +94,7 @@ namespace Files boost::filesystem::path result(""); if (sectionName == "") { - return FileListLocator(mPriorityList, boost::filesystem::path(item), strict); + return FileListLocator(mPriorityList, boost::filesystem::path(item), strict, false); } else { @@ -103,7 +103,7 @@ namespace Files std::cout << "Warning: There is no section named " << sectionName << "\n"; return result; } - result = FileListLocator(mMap[sectionName], boost::filesystem::path(item), strict); + result = FileListLocator(mMap[sectionName], boost::filesystem::path(item), strict, false); } return result; } diff --git a/components/files/fileops.cpp b/components/files/fileops.cpp index f57eaa546..ed16b9fa5 100644 --- a/components/files/fileops.cpp +++ b/components/files/fileops.cpp @@ -42,13 +42,18 @@ bool isFile(const char *name) } // Locates path in path container - boost::filesystem::path FileListLocator (const Files::PathContainer& list, const boost::filesystem::path& toFind, bool strict) + boost::filesystem::path FileListLocator (const Files::PathContainer& list, const boost::filesystem::path& toFind, + bool strict, bool ignoreExtensions) { boost::filesystem::path result(""); if (list.empty()) return result; - std::string toFindStr = toFind.string(); + std::string toFindStr; + if (ignoreExtensions) + toFindStr = boost::filesystem::basename(toFind); + else + toFindStr = toFind.string(); std::string fullPath; @@ -94,9 +99,9 @@ bool isFile(const char *name) } // Overloaded form of the locator that takes a string and returns a string - std::string FileListLocator (const Files::PathContainer& list,const std::string& toFind, bool strict) + std::string FileListLocator (const Files::PathContainer& list,const std::string& toFind, bool strict, bool ignoreExtensions) { - return FileListLocator(list, boost::filesystem::path(toFind), strict).string(); + return FileListLocator(list, boost::filesystem::path(toFind), strict, ignoreExtensions).string(); } } diff --git a/components/files/fileops.hpp b/components/files/fileops.hpp index 49ef7b947..bf1c51485 100644 --- a/components/files/fileops.hpp +++ b/components/files/fileops.hpp @@ -27,10 +27,11 @@ bool isFile(const char *name); /// that contains the searched path. /// If it's not found it returns and empty path /// Takes care of slashes, backslashes and it has a strict option. - boost::filesystem::path FileListLocator (const Files::PathContainer& list, const boost::filesystem::path& toFind, bool strict); + boost::filesystem::path FileListLocator (const Files::PathContainer& list, const boost::filesystem::path& toFind, + bool strict, bool ignoreExtensions); /// Overloaded form of the locator that takes a string and returns a string - std::string FileListLocator (const Files::PathContainer& list,const std::string& toFind, bool strict); + std::string FileListLocator (const Files::PathContainer& list,const std::string& toFind, bool strict, bool ignoreExtensions); }