mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 17:49:41 +00:00
Can find files even if no .bsa file exists now
This commit is contained in:
parent
60b95e7992
commit
4a9a416d46
5 changed files with 34 additions and 4 deletions
|
@ -204,13 +204,18 @@ OMW::Engine::~Engine()
|
||||||
void OMW::Engine::loadBSA()
|
void OMW::Engine::loadBSA()
|
||||||
{
|
{
|
||||||
const Files::MultiDirCollection& bsa = mFileCollections.getCollection (".bsa");
|
const Files::MultiDirCollection& bsa = mFileCollections.getCollection (".bsa");
|
||||||
std::string dataDirectory;
|
|
||||||
for (Files::MultiDirCollection::TIter iter(bsa.begin()); iter!=bsa.end(); ++iter)
|
for (Files::MultiDirCollection::TIter iter(bsa.begin()); iter!=bsa.end(); ++iter)
|
||||||
{
|
{
|
||||||
std::cout << "Adding " << iter->second.string() << std::endl;
|
std::cout << "Adding " << iter->second.string() << std::endl;
|
||||||
Bsa::addBSA(iter->second.string());
|
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;
|
std::cout << "Data dir " << dataDirectory << std::endl;
|
||||||
Bsa::addDir(dataDirectory, mFSStrict);
|
Bsa::addDir(dataDirectory, mFSStrict);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,15 @@ private:
|
||||||
|
|
||||||
bool comparePortion(const std::string& file1, const std::string& file2, int start, int size) const
|
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++)
|
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 one = tolower(file1.at(i));
|
||||||
char two = tolower(file2.at(i));
|
char two = tolower(file2.at(i));
|
||||||
if(one != two)
|
if(one != two)
|
||||||
|
@ -83,7 +90,18 @@ class DirArchive: public Ogre::FileSystemArchive
|
||||||
|
|
||||||
bool findFile(const String& filename, std::string& copy) const
|
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(), '\\', '/');
|
std::replace(copy.begin(), copy.end(), '\\', '/');
|
||||||
|
|
||||||
|
|
|
@ -30,4 +30,9 @@ namespace Files
|
||||||
|
|
||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Files::PathContainer& Collections::getPaths() const
|
||||||
|
{
|
||||||
|
return mDirectories;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ namespace Files
|
||||||
/// leading dot and must be all lower-case.
|
/// leading dot and must be all lower-case.
|
||||||
const MultiDirCollection& getCollection(const std::string& extension) const;
|
const MultiDirCollection& getCollection(const std::string& extension) const;
|
||||||
|
|
||||||
|
const Files::PathContainer& getPaths() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<std::string, MultiDirCollection> MultiDirCollectionContainer;
|
typedef std::map<std::string, MultiDirCollection> MultiDirCollectionContainer;
|
||||||
Files::PathContainer mDirectories;
|
Files::PathContainer mDirectories;
|
||||||
|
|
|
@ -1368,7 +1368,7 @@ void NIFLoader::loadResource(Resource *resource)
|
||||||
|
|
||||||
if (!vfs->isFile(resourceName))
|
if (!vfs->isFile(resourceName))
|
||||||
{
|
{
|
||||||
warn("File not found.");
|
warn("File "+resourceName+" not found.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue