Skip to content

Baldur's Gate 3: bug fixes - #240

Open
daescha wants to merge 9 commits into
ModOrganizer2:masterfrom
daescha:bg3-fixes
Open

daescha wants to merge 9 commits into
ModOrganizer2:masterfrom
daescha:bg3-fixes

Conversation

@daescha

@daescha daescha commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Baldur's Gate 3: bug fixes

Fixes in the BG3 plugin. Each one has a unit test under tests/, run with python -m unittest.

  • modsettings.lsx escaping: mod names and folders with &, <, > or quotes produce valid XML.
  • Profile switch: the modsettings.lsx path follows the current profile.
  • LSLib download: the download picks the .zip asset, checks GitHub's sha256 digest, uses a network timeout and overwrites old tools on update.
  • Force-loaded DLLs: mod DLLs load into bg3.exe and bg3_dx11.exe only, not the Larian Launcher.
  • Empty-folder cleanup: nested empty folders are removed bottom-up and the root stays.
  • Data checker: the strongest status across entries wins, so a fixable entry is not hidden by a later valid one.
  • YAML/JSON conversion: unreadable files are skipped with a warning, and files are read and written as UTF-8.
  • File mapping: canceling keeps the modsettings.lsx mapping, and mappings are built per call.
  • Cleanups: isinstance checks, closed file handles in the diff log, and an explicit is_file flag for create_dir_if_needed.

Follow-up PRs

Three more PRs build on this one and open after it merges. Each link shows only that branch's own commits.

  1. Read paks in Python (diff): reads LSPK v15, v16 and v18 meta.lsx and file lists in Python, and uses Divine only for Zstd, solid or corrupt paks. Adds an Extract Pak tool, and runs Divine with an argument list and a timeout.
  2. Thread-safe metadata parsing (diff): workers parse paks; only the main thread touches Qt, the organizer and meta.ini. Cancel aborts the launch, LSLib downloads only when a pak needs Divine, and the cache stores each pak's size and mtime.
  3. Install and load-order helpers (diff): pak variant picker on install, warnings for out-of-order dependencies and an emptied modsettings.lsx, and an Import Game Mods tool.

@daescha

daescha commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

@Holt59 ready for review when you have time.

@daescha

daescha commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Wiki plan: after this PR merges, add the page below as Game:-Baldur's-Gate-3 and link it from Home.md with:

* [Baldur's Gate 3](https://github.com/ModOrganizer2/modorganizer-basic_games/wiki/Game:-Baldur's-Gate-3)

The extract_full_package setting comes from this PR; the rest matches master.

Proposed page
[PCGamingWiki](https://www.pcgamingwiki.com/wiki/Baldur%27s_Gate_3) | [Nexus Mods](https://www.nexusmods.com/baldursgate3)

## Current Support
* Pak mods (`Mods\*.pak`), with load order written to `modsettings.xml` on every launch
* Script Extender and its config files (`Script Extender` folder)
* Native DLL mods (`bin`), force-loaded without Native Mod Loader
* Loose file override mods (`Data`)
* Mod workspaces: unpacked mod folders are built into paks on launch
* Pak metadata (name, UUID, version, dependencies) read with [LSLib](https://github.com/Norbyte/lslib), downloaded on first use
* Executables: DX11, Vulkan and Larian Launcher
* Savegames in `PlayerProfiles\Public\Savegames\Story`

## Mod Installation
The plugin sorts archive contents into these folders. Most mods from Nexus install without changes.

| Mod folder        | Virtual Mapped Path                                                   |
| ----------------- | --------------------------------------------------------------------- |
| Mods\\*.pak       | %LOCALAPPDATA%\Larian Studios\Baldur's Gate 3\Mods                   |
| Script Extender   | %LOCALAPPDATA%\Larian Studios\Baldur's Gate 3\Script Extender        |
| bin               | Baldur's Gate 3\bin                                                   |
| Data              | Baldur's Gate 3\Data                                                  |

Files the game writes (`LevelCache`, `Stats`, `Temp`, `GMCampaigns`, Script Extender logs) go to Overwrite.

## Load Order
* The left pane order is the pak load order.
* MO2 rebuilds `modsettings.xml` before each executable starts. Do not manage it with another mod manager at the same time.
* Dependencies come from each pak's `meta.lsx`. Run **Tools → BG3 Tools → Reparse Pak Metadata** after editing a pak by hand.

## Script Extender
* Install [BG3 Script Extender](https://github.com/Norbyte/bg3se) as a normal mod; MO2 puts its `DWrite.dll` in `bin`.
* Launch through the MO2 executables, not Steam or the Larian Launcher, so the VFS is active.
* Optional: enable `convert_yamls_to_json` to edit Script Extender mod configs as YAML. **Tools → BG3 Tools → Convert JSONS to YAML** converts existing configs.

## Plugin Settings
Under **Settings → Plugins → Baldur's Gate 3**.

| Setting | Default | Effect |
| ------- | ------- | ------ |
| force_load_dlls | true | Force-load every DLL in active mods |
| autobuild_paks | true | Build pak-like folders into paks on each run |
| delete_levelcache_folders_older_than_x_days | 3 | Clean old `Overwrite\LevelCache` entries; negative disables |
| remove_extracted_metadata | true | Delete extracted `meta.lsx` files after parsing |
| extract_full_package | false | Extract the whole pak when parsing metadata |
| convert_yamls_to_json | false | Convert YAML configs to JSON on each run |
| log_diff | false | Log a diff of `modsettings.xml` before and after the game runs |

## Tools
Under **Tools → BG3 Tools**:
* **Check For LsLib Updates**: download the latest LSLib release
* **Reparse Pak Metadata**: reread metadata of all active paks now
* **Convert JSONS to YAML**: convert JSON configs in active mods to YAML

## Troubleshooting
* Mods missing in game: enable `log_diff` and check whether the game rewrote `modsettings.xml`.
* LSLib download fails: run **Check For LsLib Updates**, or place LSLib in the plugin's `tools` folder.
* A mod shows as invalid: it lacks `Mods\*.pak`, `bin`, `Script Extender` or `Data` at its root; fix the folder layout in the installer.

Version Changelog:
* MO v2.5.x: Added plugin

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