Ignore missing localization string files by esmtool

Dawnguard.esm from Skyrim depends on files stored in Dawnguard.bsa which is not
processed by esmtool.
simplify_debugging
elsid 1 year ago
parent 358b7ad3ec
commit e537d1d0d4
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -526,7 +526,7 @@ namespace EsmTool
try
{
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);
if (!params.mQuite)

@ -91,11 +91,12 @@ namespace ESM4
}
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)
, mEncoder(encoder)
, mFileSize(0)
, mStream(std::move(esmStream))
, mIgnoreMissingLocalizedStrings(ignoreMissingLocalizedStrings)
{
// used by ESMReader only?
mCtx.filename = filename;
@ -243,12 +244,28 @@ namespace ESM4
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);
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);
}
@ -361,8 +378,12 @@ namespace ESM4
const auto it = mLStringIndex.find(stringId);
if (it == mLStringIndex.end())
{
if (mIgnoreMissingLocalizedStrings)
return;
throw std::runtime_error(
"ESM4::Reader::getLocalizedString localized string not found for " + formIdToString(stringId));
}
str = it->second;
}

@ -160,6 +160,8 @@ namespace ESM4
std::vector<Reader*>* mGlobalReaderList = nullptr;
bool mIgnoreMissingLocalizedStrings = false;
void buildLStringIndex(LocalizedStringType stringType, const std::u8string& prefix);
void buildLStringIndex(LocalizedStringType stringType, std::istream& stream);
@ -187,7 +189,7 @@ namespace ESM4
public:
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();

Loading…
Cancel
Save