Expand description
Pack optimization system for reducing size and improving compatibility.
This module provides tools to clean up and optimize mod packs by removing unnecessary data, duplicate entries, and files that are identical to vanilla. Optimization helps reduce mod size, improve load times, and increase compatibility with other mods.
§Optimization Types
§Pack-Level Optimizations
- ITM File Removal: Remove files that are byte-for-byte identical to vanilla game files. These provide no benefit and can cause conflicts.
- Apply Compression: Turn on the pack’s
compressflag using the most modern compression format the active game supports (overriding whatever the pack had configured), so the next save actually compresses the files. No-op if the game supports no compression formats. Intended as a final step before release on a pack you’ve been editing uncompressed.
§Table Optimizations (DB/Loc)
- Duplicate Removal: Remove rows that appear multiple times
- ITM Row Removal: Remove rows identical to vanilla data
- ITNR Row Removal: Remove rows identical to the “new row” default
- Empty File Removal: Delete tables with no remaining rows
- Datacore Import: Generate
twad_key_deletesentries for datacored tables
§Portrait Settings Optimizations
- Unused Art Set Removal: Remove art sets not referenced by any unit
- Unused Variant Removal: Remove variants not used in any art set
- Empty Mask Removal: Remove portrait masks that are empty/transparent
- Empty File Removal: Delete portrait settings with no remaining data
§Text File Optimizations
- Unused XML Removal: Remove unused XML files in map/prefab folders
- AGF File Removal: Remove unnecessary AGF files
- Model Statistics Removal: Remove debug/statistics files
§Configuration
Use OptimizerOptions to control which optimizations are applied:
ⓘ
let mut options = OptimizerOptions::default();
options.set_pack_remove_itm_files(true);
options.set_table_remove_itm_entries(true);
options.set_pts_remove_empty_masks(true);§Usage Example
ⓘ
use rpfm_extensions::optimizer::OptimizableContainer;
let (deleted, optimized) = pack.optimize(
None, // Optimize all paths
&mut dependencies,
&schema,
&game_info,
&options,
)?;
println!("Deleted {} files, optimized {} files", deleted.len(), optimized.len());§Traits
Optimizable: For individual file types that can be optimizedOptimizableContainer: For containers (likePack) that can optimize their contents
Structs§
- Optimizer
Options - Configuration options for the pack optimizer.
Traits§
- Optimizable
- Trait for file types that can be optimized to reduce size.
- Optimizable
Container - Trait for containers (like
Pack) that can optimize their contents.