From 4a9a416d46bb0bd7f2b92615dbde3b81b4975745 Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Fri, 30 Mar 2012 14:45:32 +0200 Subject: [PATCH] Can find files even if no .bsa file exists now --- apps/openmw/engine.cpp | 9 +++++++-- components/bsa/bsa_archive.cpp | 20 +++++++++++++++++++- components/files/collections.cpp | 5 +++++ components/files/collections.hpp | 2 ++ components/nifogre/ogre_nif_loader.cpp | 2 +- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 5e49ae2f7..990356191 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -204,13 +204,18 @@ OMW::Engine::~Engine() void OMW::Engine::loadBSA() { const Files::MultiDirCollection& bsa = mFileCollections.getCollection (".bsa"); - std::string dataDirectory; + for (Files::MultiDirCollection::TIter iter(bsa.begin()); iter!=bsa.end(); ++iter) { std::cout << "Adding " << iter->second.string() << std::endl; Bsa::addBSA(iter->second.string()); + } - dataDirectory = iter->second.parent_path().string(); + const Files::PathContainer& dataDirs = mFileCollections.getPaths(); + std::string dataDirectory; + for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter) + { + dataDirectory = iter->string(); std::cout << "Data dir " << dataDirectory << std::endl; Bsa::addDir(dataDirectory, mFSStrict); } diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 64dc97980..36f4b423c 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -52,8 +52,15 @@ private: bool comparePortion(const std::string& file1, const std::string& file2, int start, int size) const { + return lexicographical_compare(file1.substr(start,size), file2.substr(start,size), boost::algorithm::is_iless()); + for(int i = start; i < start+size; i++) { + if (i >= file1.size()) + return true; + else if (i >= file2.size()) + return false; + char one = tolower(file1.at(i)); char two = tolower(file2.at(i)); if(one != two) @@ -83,7 +90,18 @@ class DirArchive: public Ogre::FileSystemArchive bool findFile(const String& filename, std::string& copy) const { - copy = filename; + { + String passed = filename; + if(filename.at(filename.length() - 1) == '*' || filename.at(filename.length() - 1) == '?' || filename.at(filename.length() - 1) == '<' + || filename.at(filename.length() - 1) == '"' || filename.at(filename.length() - 1) == '>' || filename.at(filename.length() - 1) == ':' + || filename.at(filename.length() - 1) == '|') + { + passed = filename.substr(0, filename.length() - 2); + } + if(filename.at(filename.length() - 2) == '>') + passed = filename.substr(0, filename.length() - 6); + copy = passed; + } std::replace(copy.begin(), copy.end(), '\\', '/'); diff --git a/components/files/collections.cpp b/components/files/collections.cpp index 424b558e6..50340dca4 100644 --- a/components/files/collections.cpp +++ b/components/files/collections.cpp @@ -30,4 +30,9 @@ namespace Files return iter->second; } + + const Files::PathContainer& Collections::getPaths() const + { + return mDirectories; + } } diff --git a/components/files/collections.hpp b/components/files/collections.hpp index 1ddca9a5b..70aaec55e 100644 --- a/components/files/collections.hpp +++ b/components/files/collections.hpp @@ -21,6 +21,8 @@ namespace Files /// leading dot and must be all lower-case. const MultiDirCollection& getCollection(const std::string& extension) const; + const Files::PathContainer& getPaths() const; + private: typedef std::map MultiDirCollectionContainer; Files::PathContainer mDirectories; diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index f943231d0..2ab6ae621 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -1368,7 +1368,7 @@ void NIFLoader::loadResource(Resource *resource) if (!vfs->isFile(resourceName)) { - warn("File not found."); + warn("File "+resourceName+" not found."); return; }