mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-06 07:15:36 +00:00
Merge branch 'fix_esm_loader' into 'master'
Load only supported content formats by EsmLoader See merge request OpenMW/openmw!1427
This commit is contained in:
commit
a332dec681
2 changed files with 41 additions and 1 deletions
|
@ -101,4 +101,27 @@ namespace
|
|||
EXPECT_EQ(esmData.mLands.size(), 0);
|
||||
EXPECT_EQ(esmData.mStatics.size(), 0);
|
||||
}
|
||||
|
||||
TEST_F(EsmLoaderTest, loadEsmDataShouldSkipUnsupportedFormats)
|
||||
{
|
||||
Query query;
|
||||
query.mLoadActivators = true;
|
||||
query.mLoadCells = true;
|
||||
query.mLoadContainers = true;
|
||||
query.mLoadDoors = true;
|
||||
query.mLoadGameSettings = true;
|
||||
query.mLoadLands = true;
|
||||
query.mLoadStatics = true;
|
||||
const std::vector<std::string> contentFiles {{"script.omwscripts"}};
|
||||
std::vector<ESM::ESMReader> readers(contentFiles.size());
|
||||
ToUTF8::Utf8Encoder* const encoder = nullptr;
|
||||
const EsmData esmData = loadEsmData(query, contentFiles, mFileCollections, readers, encoder);
|
||||
EXPECT_EQ(esmData.mActivators.size(), 0);
|
||||
EXPECT_EQ(esmData.mCells.size(), 0);
|
||||
EXPECT_EQ(esmData.mContainers.size(), 0);
|
||||
EXPECT_EQ(esmData.mDoors.size(), 0);
|
||||
EXPECT_EQ(esmData.mGameSettings.size(), 0);
|
||||
EXPECT_EQ(esmData.mLands.size(), 0);
|
||||
EXPECT_EQ(esmData.mStatics.size(), 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
@ -206,10 +207,26 @@ namespace EsmLoader
|
|||
{
|
||||
ShallowContent result;
|
||||
|
||||
const std::set<std::string> supportedFormats {
|
||||
".esm",
|
||||
".esp",
|
||||
".omwgame",
|
||||
".omwaddon",
|
||||
".project",
|
||||
};
|
||||
|
||||
for (std::size_t i = 0; i < contentFiles.size(); ++i)
|
||||
{
|
||||
const std::string &file = contentFiles[i];
|
||||
const Files::MultiDirCollection& collection = fileCollections.getCollection(boost::filesystem::path(file).extension().string());
|
||||
const std::string extension = boost::filesystem::path(file).extension().string();
|
||||
|
||||
if (supportedFormats.find(extension) == supportedFormats.end())
|
||||
{
|
||||
Log(Debug::Warning) << "Skipping unsupported content file: " << file;
|
||||
continue;
|
||||
}
|
||||
|
||||
const Files::MultiDirCollection& collection = fileCollections.getCollection(extension);
|
||||
|
||||
ESM::ESMReader& reader = readers[i];
|
||||
reader.setEncoder(encoder);
|
||||
|
|
Loading…
Reference in a new issue