Skip to content

Delegate archive extraction to GameArchiveHandler when built-in archive support is unavailable#20

Open
LegendMaster03 wants to merge 6 commits intoModOrganizer2:masterfrom
LegendMaster03:master
Open

Delegate archive extraction to GameArchiveHandler when built-in archive support is unavailable#20
LegendMaster03 wants to merge 6 commits intoModOrganizer2:masterfrom
LegendMaster03:master

Conversation

@LegendMaster03
Copy link
Copy Markdown

This PR updates modorganizer-bsa_extractor so archive extraction can be delegated to a game-provided GameArchiveHandler when the active game does not expose MO2’s built-in DataArchives capability.

Behavior after this change:

  • If the active game exposes DataArchives, the existing built-in extraction path remains unchanged
  • Otherwise, if the active game exposes GameArchiveHandler, extraction is delegated to the game plugin
  • If neither capability exists, the extractor stays unavailable/inert for that game

Why:

  • Some supported games use archive formats that are not Bethesda archive formats
  • Extraction for those games should be provided by the game plugin rather than forced through bsatk
  • This preserves the existing behavior for Bethesda games while making extraction extensible for other game families

Implementation notes:

  • Adds archive-handler dispatch logic
  • Keeps the Bethesda path as the default when built-in archive support exists
  • Adds tests for the dispatch/capability logic

Tested with:

  • stock Bethesda/built-in archive path still available
  • XnGine downstream archive-handler implementation for delegated extraction
  • MO2 2.5.2
  • MO2 2.5.3-beta.2

LegendMaster03 and others added 6 commits March 30, 2026 18:08
Introduce a dispatch layer to delegate archive extraction to game-provided handlers while falling back to bsatk for .bsa/.ba2 files. Adds archivehandlerdispatch.{h,cpp} and a temporary local GameArchiveHandler shim (disabled by default via macro until upstream uibase support exists). BsaExtractor was updated to use the dispatch: it now chooses between extractWithGameHandler and the existing bsatk extraction path. CMakeLists were updated to include the new source and enable tests; tests using GoogleTest for archive dispatch were added under tests/. README updated with maintainer notes and vcpkg.json now includes gtest. This change enables pluggable archive formats and adds unit coverage for the dispatch logic.
Remove the extractor-local GameArchiveHandler shim and switch to the canonical uibase feature lookup. Update archivehandlerdispatch to return the game feature directly, delete the local gamearchivehandler.h, and adapt bsaextractor to the new progress callback (qint64 current, qint64 total): show archive-level progress, compute percent with std::clamp, and adjust the lambda and progress label. README updated to document the delegated progress callback and note the expectation that the uibase API is available.
Delay registration of the mod install hook to avoid early-startup initialization hazards by scheduling tryRegisterInstallHook() via QTimer (2s). Add BSA_EXTRACTOR_DISABLE_INSTALL_HOOK env var to opt out, introduce tryRegisterInstallHook() to safely obtain modList and register the onModInstalled callback, and track registration with m_InstallHookRegistered. Resolve installed mods by name on the Qt event loop (QueuedConnection) to avoid stale pointers and add defensive null checks and warning logs. Add necessary includes (QTimer, QtDebug), update translation locations, and add mo2-uibase to test dependencies.
Add support for using MO2's built-in DataArchives feature when available and add a flag to include built-in archive patterns when scanning a directory. Introduces canUseBuiltInArchiveTools() and includes the uibase/dataarchives header; changes findExtractableArchives() to accept an includeBuiltInArchives bool and updates callers in BsaExtractor and tests accordingly. Also guards BsaExtractor initialization to avoid registering when neither built-in tools nor a game handler are present, updates CMake to optionally add uibase include path, updates translations (line shifts) and expands .gitignore with local/build entries. Note: API change to findExtractableArchives requires updating callers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant