Skip to content

Preserve authored BFRES resource sizes during merge#16

Open
MediaMoots wants to merge 7 commits into
TKMM-Team:masterfrom
MediaMoots:dev
Open

Preserve authored BFRES resource sizes during merge#16
MediaMoots wants to merge 7 commits into
TKMM-Team:masterfrom
MediaMoots:dev

Conversation

@MediaMoots

Copy link
Copy Markdown

Goal

Preserve resource-size values of bfres that were hand tweaked in mods instead of always replacing them with TKMM’s calculated estimate.

This supports intentionally optimized values that are smaller than TKMM’s overestimation of bfres files but are known to work correctly.

Changes

  • Read bfres sizes from the mod’s source ResourceSizeTable.
  • Store non-vanilla authored values in the existing changelog Reserved1 metadata.
  • Apply the value belonging to the winning bfres mod file during installation.
  • Support both loose and pack-contained BFRES files.
  • Cover all *.bfres resources, including *.anim.bfres.
  • Fall back to the existing calculation when no authored override is available.
  • Discard the override when a .bfres.mc file is materially changed (like when it gets repaired) and reserialized, since the original authored value may no longer describe the resulting file.
  • Continue packaging with a warning if a source resource-size table is missing, ambiguous, or invalid.

Using the existing reserved changelog metadata avoids changing the binary package format or requiring a package-version migration. Older readers can safely ignore the added metadata.

Notes

An authored size is preserved only when:

  • The mod includes the corresponding BFRES.
  • Its source resource-size table contains an entry for that BFRES.
  • The authored value differs from the target game’s vanilla value.

When multiple mods replace the same BFRES, both the file and its resource-size value come from the same winning mod.

@MediaMoots
MediaMoots marked this pull request as draft July 21, 2026 17:19
@ArchLeaders

Copy link
Copy Markdown
Member

I can see this potentially causing issues, since cross-version differences will be included, as well as accidental changes and/or previously automated changes. (Especially since a lot of older mods aren't tkcls.)

It sounds like Bubbles has already suggested making this flag-enabled in the tkproj, but it might be even better to control exactly which entries have overrides.

I propose this feature look more like defining exactly which files have overrides in the tkproj and then storing them in an RSTB changelog (to avoid using up Reserved1 unnecessarily).

This also expands the feature beyond just BFRES files.

@MediaMoots

Copy link
Copy Markdown
Author

Changed this to be fully opt-in instead of automatically retaining values from a mod’s RSTB.

Overrides are now explicitly defined by canonical path and value in the .tkproj, then packaged as a small RSTB changelog rather than using Reserved1.

So it now also works beyond BFRES and avoids carrying over unwanted RSTB changes.

The TKMM Advanced tab includes controls for manually adding values or importing selected entries from an existing RSTB. Overrides apply across all game versions.

Companion PR: TKMM-Team/Tkmm#172
image

Also, overrides are serialized in the .tkproj JSON and can be edited manually:

  "Flags": {
    "ResourceSizeOverrides": {
      "Enabled": true,
      "Entries": {
        "Model/Example.bfres": 123456
      }
    }
  }

@MediaMoots
MediaMoots marked this pull request as ready for review July 22, 2026 09:50
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.

2 participants