mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Re-index BSAs
This commit is contained in:
parent
d7744e8b16
commit
7914fd5c9c
6 changed files with 28 additions and 11 deletions
|
@ -21,8 +21,8 @@ namespace VFS
|
||||||
public:
|
public:
|
||||||
virtual ~Archive() {}
|
virtual ~Archive() {}
|
||||||
|
|
||||||
/// Clears cached data for archives that may change.
|
/// Clears cached data.
|
||||||
virtual void resetIfNotStatic(){};
|
virtual void reset() = 0;
|
||||||
|
|
||||||
/// List all resources contained in this archive, and run the resource names through the given normalize function.
|
/// List all resources contained in this archive, and run the resource names through the given normalize function.
|
||||||
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char)) = 0;
|
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char)) = 0;
|
||||||
|
|
|
@ -5,14 +5,15 @@ namespace VFS
|
||||||
|
|
||||||
|
|
||||||
BsaArchive::BsaArchive(const std::string &filename)
|
BsaArchive::BsaArchive(const std::string &filename)
|
||||||
|
: mFileName(filename)
|
||||||
{
|
{
|
||||||
mFile.open(filename);
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
const Bsa::BSAFile::FileList &filelist = mFile.getList();
|
void BsaArchive::reset()
|
||||||
for(Bsa::BSAFile::FileList::const_iterator it = filelist.begin();it != filelist.end();++it)
|
{
|
||||||
{
|
mResources.clear();
|
||||||
mResources.push_back(BsaArchiveFile(&*it, &mFile));
|
load();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BsaArchive::listResources(std::map<std::string, File *> &out, char (*normalize_function)(char))
|
void BsaArchive::listResources(std::map<std::string, File *> &out, char (*normalize_function)(char))
|
||||||
|
@ -26,6 +27,17 @@ void BsaArchive::listResources(std::map<std::string, File *> &out, char (*normal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BsaArchive::load()
|
||||||
|
{
|
||||||
|
mFile.open(mFileName);
|
||||||
|
|
||||||
|
const Bsa::BSAFile::FileList &filelist = mFile.getList();
|
||||||
|
for(Bsa::BSAFile::FileList::const_iterator it = filelist.begin();it != filelist.end();++it)
|
||||||
|
{
|
||||||
|
mResources.push_back(BsaArchiveFile(&*it, &mFile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
|
||||||
BsaArchiveFile::BsaArchiveFile(const Bsa::BSAFile::FileStruct *info, Bsa::BSAFile* bsa)
|
BsaArchiveFile::BsaArchiveFile(const Bsa::BSAFile::FileStruct *info, Bsa::BSAFile* bsa)
|
||||||
|
|
|
@ -24,9 +24,14 @@ namespace VFS
|
||||||
public:
|
public:
|
||||||
BsaArchive(const std::string& filename);
|
BsaArchive(const std::string& filename);
|
||||||
|
|
||||||
|
virtual void reset();
|
||||||
|
|
||||||
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char));
|
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char));
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void load();
|
||||||
|
|
||||||
|
std::string mFileName;
|
||||||
Bsa::BSAFile mFile;
|
Bsa::BSAFile mFile;
|
||||||
|
|
||||||
std::vector<BsaArchiveFile> mResources;
|
std::vector<BsaArchiveFile> mResources;
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace VFS
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSystemArchive::resetIfNotStatic()
|
void FileSystemArchive::reset()
|
||||||
{
|
{
|
||||||
mIndex.clear();
|
mIndex.clear();
|
||||||
mBuiltIndex = false;
|
mBuiltIndex = false;
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace VFS
|
||||||
public:
|
public:
|
||||||
FileSystemArchive(const std::string& path);
|
FileSystemArchive(const std::string& path);
|
||||||
|
|
||||||
virtual void resetIfNotStatic();
|
virtual void reset();
|
||||||
|
|
||||||
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char));
|
virtual void listResources(std::map<std::string, File*>& out, char (*normalize_function) (char));
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace VFS
|
||||||
void Manager::rebuildIndex()
|
void Manager::rebuildIndex()
|
||||||
{
|
{
|
||||||
for (std::vector<Archive*>::const_iterator it = mArchives.begin(); it != mArchives.end(); ++it)
|
for (std::vector<Archive*>::const_iterator it = mArchives.begin(); it != mArchives.end(); ++it)
|
||||||
(*it)->resetIfNotStatic();
|
(*it)->reset();
|
||||||
|
|
||||||
buildIndex();
|
buildIndex();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue