aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_bsplugins/src/TESData/FileConflictParser.cpp
diff options
context:
space:
mode:
authorSulfurNitride <SulfurNitride@users.noreply.github.com>2026-04-12 21:04:15 -0500
committerSulfurNitride <SulfurNitride@users.noreply.github.com>2026-04-12 21:04:15 -0500
commit3949dcfce95af4bd305f258ff5b170d7d50435f6 (patch)
tree4c768be256c40f31794c3311f0a2c22933a6705a /libs/installer_bsplugins/src/TESData/FileConflictParser.cpp
parent892070f3dec1dc690983fd862880e37e711c2516 (diff)
VFS perf fixes, icon/stylesheet compat, download filename fix
VFS: - Open backing fd at mo2_open time for read-only handles so mo2_read can splice without re-opening the file on every read call. - Bump RLIMIT_NOFILE at mount time to fit the resulting fd pressure when the game keeps hundreds of BSAs open. - Dedicated node_cache_mutex so resolveByInode / mo2_lookup stop racing unordered_map writes while multiple tree_mutex readers are active. - max_read=1MB + matching conn->max_read and raised max_readahead/max_write so the kernel merges Wine's small sequential reads into bigger FUSE requests. - Per-op wall-clock counters in mo2_init() logs so we can distinguish VFS latency from game-side work. Proton launch: - Write dxvk.conf to the prefix and set DXVK_CONFIG_FILE to force dxvk.enableGraphicsPipelineLibrary=False, avoiding long GPL compile stalls on first run. UI / plugin compat: - Clamp IconDelegate's per-icon width to [8, 16] so narrow content columns don't trigger QIcon::pixmap(0,0) returning null and logging "failed to load icon" every repaint. - Pre-create lowercase symlinks in the stylesheet directory so QSS files authored on Windows resolve url(foo.svg) when on-disk files are Foo.svg. - Flip content icons empty-chessboard.png and facegen.png to 8-bit RGBA so Qt's built-in PNG reader loads them uniformly. - Add mobase.Version.canonicalString shim for legacy Python plugins that still call the old VersionInfo method on appVersion()'s return. - BSPluginList: compare normalized plugin name lists instead of byte hashes so the post-run case-fix refresh stops spuriously firing the "load order changed" dialog. - BSPluginList disabled by default. Download manager: - Parse CDN URL with QUrl + QUrlQuery and read the filename from the response-content-disposition query param (RFC 6266 quoted / unquoted / ext-value forms), not QFileInfo on the raw URL. - When the API or URL gives us a CDN object key (no archive extension), prefer the actual Content-Disposition header from the live response in metaDataChanged and downloadFinished. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'libs/installer_bsplugins/src/TESData/FileConflictParser.cpp')
-rw-r--r--libs/installer_bsplugins/src/TESData/FileConflictParser.cpp228
1 files changed, 228 insertions, 0 deletions
diff --git a/libs/installer_bsplugins/src/TESData/FileConflictParser.cpp b/libs/installer_bsplugins/src/TESData/FileConflictParser.cpp
new file mode 100644
index 0000000..e4958e4
--- /dev/null
+++ b/libs/installer_bsplugins/src/TESData/FileConflictParser.cpp
@@ -0,0 +1,228 @@
+#include "FileConflictParser.h"
+#include "PluginList.h"
+
+#include <log.h>
+
+#include <stdexcept>
+#include <string_view>
+
+namespace TESData
+{
+
+FileConflictParser::FileConflictParser(PluginList* pluginList, FileInfo* plugin,
+ bool lightSupported, bool mediumSupported,
+ bool blueprintSupported)
+ : m_PluginList{pluginList}, m_Plugin{plugin}, m_LightSupported{lightSupported},
+ m_MediumSupported{mediumSupported}, m_BlueprintSupported{blueprintSupported}
+{
+ m_PluginName = m_Plugin->name().toStdString();
+}
+
+bool FileConflictParser::Group(TESFile::GroupData group)
+{
+ if (group.hasDirectParent()) {
+ m_CurrentPath.push(group, m_Masters, m_PluginName);
+ m_PluginList->addGroupPlaceholder(m_PluginName, m_CurrentPath);
+ m_CurrentPath.pop();
+ return false;
+ }
+
+ if (m_Masters.empty() && group.hasFormType() && group.formType() != "GMST"_ts &&
+ group.formType() != "DOBJ"_ts) {
+ return false;
+ }
+
+ if (group.hasFormType() && group.formType() == "NAVI"_ts) {
+ return false;
+ }
+
+ m_CurrentPath.push(group, m_Masters, m_PluginName);
+ return true;
+}
+
+void FileConflictParser::EndGroup()
+{
+ m_CurrentPath.pop();
+}
+
+bool FileConflictParser::Form(TESFile::FormData form)
+{
+ m_CurrentType = form.type();
+
+ if (m_CurrentPath.groups().empty()) {
+ if (form.type() == "TES4"_ts) {
+ m_Plugin->setMasterFlagged(form.flags() & TESFile::RecordFlags::Master);
+ m_Plugin->setMediumFlagged(m_MediumSupported &&
+ (form.flags() & TESFile::RecordFlags::Medium));
+ m_Plugin->setBlueprintFlagged(m_BlueprintSupported &&
+ (form.flags() & TESFile::RecordFlags::Blueprint));
+ m_Plugin->setLightFlagged(
+ m_MediumSupported ? (form.flags() & TESFile::RecordFlags::SmallNew)
+ : m_LightSupported ? (form.flags() & TESFile::RecordFlags::SmallOld)
+ : false);
+ m_Plugin->setFormVersion(form.formVersion());
+ return true;
+ } else {
+ throw std::runtime_error("Unsupported header record");
+ }
+ }
+
+ switch (m_CurrentPath.groups().front().formType()) {
+ case "DOBJ"_ts:
+ case "GMST"_ts:
+ return true;
+ default:
+ m_CurrentPath.setFormId(form.formId(), m_Masters, m_PluginName);
+
+ const int localModIndex = form.localModIndex();
+ const bool isMasterRecord = localModIndex < m_Masters.size();
+ return isMasterRecord;
+ }
+}
+
+void FileConflictParser::EndForm()
+{
+ if (m_CurrentType != "TES4"_ts && m_CurrentType != "TES3"_ts &&
+ m_CurrentType != "GMST"_ts && m_CurrentType != "DOBJ"_ts) {
+
+ m_PluginList->addRecordConflict(m_PluginName, m_CurrentPath, m_CurrentType,
+ m_CurrentName);
+ }
+
+ m_CurrentPath.unsetFormId();
+ m_CurrentType = {};
+ m_CurrentChunk = {};
+ m_CurrentName.clear();
+}
+
+bool FileConflictParser::Chunk(TESFile::Type type)
+{
+ m_CurrentChunk = type;
+ if (m_CurrentPath.groups().empty()) {
+ switch (type) {
+ case "HEDR"_ts:
+ case "MAST"_ts:
+ case "CNAM"_ts:
+ case "SNAM"_ts:
+ return true;
+ }
+ return false;
+ } else if (m_CurrentPath.groups().front().formType() == "DOBJ"_ts) {
+ switch (type) {
+ case "DNAM"_ts:
+ return true;
+ }
+ return false;
+ } else {
+ switch (type) {
+ case "EDID"_ts:
+ return true;
+ }
+ return false;
+ }
+}
+
+void FileConflictParser::Data(std::istream& stream)
+{
+ if (m_CurrentPath.groups().empty()) {
+ return MainRecordData(stream);
+ }
+
+ switch (m_CurrentPath.groups().front().formType()) {
+ case "DOBJ"_ts:
+ return DefaultObjectData(stream);
+ case "GMST"_ts:
+ return GameSettingData(stream);
+ default:
+ return StandardData(stream);
+ }
+}
+
+void FileConflictParser::MainRecordData(std::istream& stream)
+{
+ switch (m_CurrentChunk) {
+ case "HEDR"_ts: {
+ struct Header
+ {
+ float version;
+ int32_t numRecords;
+ uint32_t nextObjectId;
+ };
+
+ const auto header = TESFile::readType<Header>(stream);
+ if (stream.fail()) {
+ MOBase::log::error("failed to read HEDR data");
+ return;
+ }
+
+ m_Plugin->setHasNoRecords(header.numRecords == 0);
+ m_Plugin->setHeaderVersion(header.version);
+ } break;
+
+ case "MAST"_ts: {
+ const std::string master = TESFile::readZstring(stream);
+ if (!master.empty()) {
+ m_Plugin->addMaster(QString::fromStdString(master.c_str()));
+ m_Masters.push_back(master);
+ }
+ } break;
+
+ case "CNAM"_ts: {
+ const std::string author = TESFile::readZstring(stream);
+ if (!author.empty()) {
+ m_Plugin->setAuthor(QString::fromLatin1(author.data()));
+ }
+ } break;
+
+ case "SNAM"_ts: {
+ const std::string desc = TESFile::readZstring(stream);
+ if (!desc.empty()) {
+ m_Plugin->setDescription(QString::fromLatin1(desc.data()));
+ }
+ } break;
+ }
+}
+
+void FileConflictParser::DefaultObjectData(std::istream& stream)
+{
+ switch (m_CurrentChunk) {
+ case "DNAM"_ts:
+ while (stream.peek() != std::char_traits<char>::eof()) {
+ const TESFile::Type name = TESFile::readType<TESFile::Type>(stream);
+ [[maybe_unused]] const std::uint32_t formId =
+ TESFile::readType<std::uint32_t>(stream);
+ if (name == TESFile::Type()) {
+ continue;
+ }
+ if (name == "BBBB"_ts) {
+ break;
+ }
+ m_CurrentPath.setTypeId(name);
+ m_PluginList->addRecordConflict(m_PluginName, m_CurrentPath, "DOBJ"_ts, "");
+ }
+ break;
+ }
+}
+
+void FileConflictParser::GameSettingData(std::istream& stream)
+{
+ switch (m_CurrentChunk) {
+ case "EDID"_ts: {
+ const std::string editorId = TESFile::readZstring(stream);
+ m_CurrentPath.setEditorId(editorId);
+ m_PluginList->addRecordConflict(m_PluginName, m_CurrentPath, "GMST"_ts, "");
+ } break;
+ }
+}
+
+void FileConflictParser::StandardData(std::istream& stream)
+{
+ switch (m_CurrentChunk) {
+ case "EDID"_ts: {
+ std::string editorId = TESFile::readZstring(stream);
+ m_CurrentName = std::move(editorId);
+ } break;
+ }
+}
+
+} // namespace TESData