mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-13 10:13:06 +00:00
Ignore missing localization string files by esmtool
Dawnguard.esm from Skyrim depends on files stored in Dawnguard.bsa which is not processed by esmtool.
This commit is contained in:
parent
358b7ad3ec
commit
e537d1d0d4
3 changed files with 28 additions and 5 deletions
|
|
@ -526,7 +526,7 @@ namespace EsmTool
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const ToUTF8::StatelessUtf8Encoder encoder(ToUTF8::calculateEncoding(info.encoding));
|
const ToUTF8::StatelessUtf8Encoder encoder(ToUTF8::calculateEncoding(info.encoding));
|
||||||
ESM4::Reader reader(std::move(stream), info.filename, nullptr, &encoder);
|
ESM4::Reader reader(std::move(stream), info.filename, nullptr, &encoder, true);
|
||||||
const Params params(info);
|
const Params params(info);
|
||||||
|
|
||||||
if (!params.mQuite)
|
if (!params.mQuite)
|
||||||
|
|
|
||||||
|
|
@ -91,11 +91,12 @@ namespace ESM4
|
||||||
}
|
}
|
||||||
|
|
||||||
Reader::Reader(Files::IStreamPtr&& esmStream, const std::filesystem::path& filename, VFS::Manager const* vfs,
|
Reader::Reader(Files::IStreamPtr&& esmStream, const std::filesystem::path& filename, VFS::Manager const* vfs,
|
||||||
const ToUTF8::StatelessUtf8Encoder* encoder)
|
const ToUTF8::StatelessUtf8Encoder* encoder, bool ignoreMissingLocalizedStrings)
|
||||||
: mVFS(vfs)
|
: mVFS(vfs)
|
||||||
, mEncoder(encoder)
|
, mEncoder(encoder)
|
||||||
, mFileSize(0)
|
, mFileSize(0)
|
||||||
, mStream(std::move(esmStream))
|
, mStream(std::move(esmStream))
|
||||||
|
, mIgnoreMissingLocalizedStrings(ignoreMissingLocalizedStrings)
|
||||||
{
|
{
|
||||||
// used by ESMReader only?
|
// used by ESMReader only?
|
||||||
mCtx.filename = filename;
|
mCtx.filename = filename;
|
||||||
|
|
@ -243,12 +244,28 @@ namespace ESM4
|
||||||
|
|
||||||
if (mVFS != nullptr)
|
if (mVFS != nullptr)
|
||||||
{
|
{
|
||||||
const Files::IStreamPtr stream = mVFS->get(Files::pathToUnicodeString(path));
|
const std::string vfsPath = Files::pathToUnicodeString(path);
|
||||||
|
|
||||||
|
if (mIgnoreMissingLocalizedStrings && !mVFS->exists(vfsPath))
|
||||||
|
{
|
||||||
|
Log(Debug::Warning) << "Ignore missing VFS strings file: " << vfsPath;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Files::IStreamPtr stream = mVFS->get(vfsPath);
|
||||||
buildLStringIndex(stringType, *stream);
|
buildLStringIndex(stringType, *stream);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Files::IStreamPtr stream = Files::openConstrainedFileStream(mCtx.filename.parent_path() / path);
|
const std::filesystem::path fsPath = mCtx.filename.parent_path() / path;
|
||||||
|
|
||||||
|
if (mIgnoreMissingLocalizedStrings && !std::filesystem::exists(fsPath))
|
||||||
|
{
|
||||||
|
Log(Debug::Warning) << "Ignore missing strings file: " << fsPath;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Files::IStreamPtr stream = Files::openConstrainedFileStream(fsPath);
|
||||||
buildLStringIndex(stringType, *stream);
|
buildLStringIndex(stringType, *stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -361,8 +378,12 @@ namespace ESM4
|
||||||
const auto it = mLStringIndex.find(stringId);
|
const auto it = mLStringIndex.find(stringId);
|
||||||
|
|
||||||
if (it == mLStringIndex.end())
|
if (it == mLStringIndex.end())
|
||||||
|
{
|
||||||
|
if (mIgnoreMissingLocalizedStrings)
|
||||||
|
return;
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"ESM4::Reader::getLocalizedString localized string not found for " + formIdToString(stringId));
|
"ESM4::Reader::getLocalizedString localized string not found for " + formIdToString(stringId));
|
||||||
|
}
|
||||||
|
|
||||||
str = it->second;
|
str = it->second;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,8 @@ namespace ESM4
|
||||||
|
|
||||||
std::vector<Reader*>* mGlobalReaderList = nullptr;
|
std::vector<Reader*>* mGlobalReaderList = nullptr;
|
||||||
|
|
||||||
|
bool mIgnoreMissingLocalizedStrings = false;
|
||||||
|
|
||||||
void buildLStringIndex(LocalizedStringType stringType, const std::u8string& prefix);
|
void buildLStringIndex(LocalizedStringType stringType, const std::u8string& prefix);
|
||||||
|
|
||||||
void buildLStringIndex(LocalizedStringType stringType, std::istream& stream);
|
void buildLStringIndex(LocalizedStringType stringType, std::istream& stream);
|
||||||
|
|
@ -187,7 +189,7 @@ namespace ESM4
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Reader(Files::IStreamPtr&& esmStream, const std::filesystem::path& filename, VFS::Manager const* vfs,
|
Reader(Files::IStreamPtr&& esmStream, const std::filesystem::path& filename, VFS::Manager const* vfs,
|
||||||
const ToUTF8::StatelessUtf8Encoder* encoder);
|
const ToUTF8::StatelessUtf8Encoder* encoder, bool ignoreMissingLocalizedStrings = false);
|
||||||
|
|
||||||
~Reader();
|
~Reader();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue