Skip to main content

Module diagnostics

Module diagnostics 

Source
Expand description

Pack validation and diagnostic checking system.

This module provides comprehensive validation for Total War mod packs, detecting common errors, potential issues, and best practice violations. Diagnostics help modders identify problems before they cause crashes or unexpected behavior in-game.

§Diagnostic Types

The system checks multiple aspects of a pack:

  • Table Diagnostics (table): DB and Loc table validation

    • Invalid foreign key references
    • Empty required fields (keys, values)
    • Duplicate rows
    • Orphaned localisation entries
  • Pack Diagnostics (pack): Pack-level checks

    • Files conflicting with vanilla
    • Missing declared dependencies
  • Dependency Diagnostics (dependency): Cross-pack validation

    • References to non-existent files
    • Circular dependencies
  • Portrait Settings Diagnostics (portrait_settings): Unit portrait validation

    • Invalid art set references
    • Missing variant definitions
  • Animation Fragment Diagnostics (anim_fragment_battle): Animation validation

    • Invalid animation references
    • Malformed fragment data
  • Text Diagnostics (text): Script validation

  • Config Diagnostics (config): Configuration file validation

§Diagnostic Levels

Each diagnostic has an associated severity level:

  • Error: Critical issues that will likely cause crashes or major problems
  • Warning: Issues that may cause problems or indicate mistakes
  • Info: Suggestions and informational notes

§Cell Position Encoding

For table diagnostics, the affected cells are encoded as (row, column) pairs:

  • (-1, -1): Affects the entire table
  • (row, -1): Affects all columns in a single row
  • (-1, column): Affects all rows in a single column
  • (row, column): Affects a specific cell

§Filtering

Diagnostics can be filtered by:

  • Ignored folders (skip entire directory trees)
  • Ignored files (skip specific files)
  • Ignored fields (skip specific table columns)
  • Ignored diagnostic types

§Usage Example

use rpfm_extensions::diagnostics::Diagnostics;

let mut diagnostics = Diagnostics::default();
diagnostics.check(
    &mut pack,
    &mut dependencies,
    &schema,
    &game_info,
    game_path,
    &[],  // Check all paths
    false, // Don't check AK-only references
);

for result in diagnostics.results() {
    println!("{}: {}", result.path(), result.message());
}

Modules§

anim_fragment_battle
Module with the structs and functions specific for AnimFragmentBattle diagnostics.
config
Module with the structs and functions specific for Config diagnostics.
dependency
Module with the structs and functions specific for Dependency diagnostics.
pack
Module with the structs and functions specific for Pack diagnostics.
portrait_settings
Module with the structs and functions specific for PortraitSettings diagnostics.
table
Module with the structs and functions specific for Table diagnostics.
text
Module with the structs and functions specific for Text diagnostics.

Structs§

Diagnostics
Container for diagnostic check results and configuration.

Enums§

DiagnosticLevel
Severity level of a diagnostic result.
DiagnosticType
Wrapper enum for all diagnostic result types.

Traits§

DiagnosticReport
Trait for types that can report diagnostic information.