Skip to main content

Module table_data

Module table_data 

Source
Expand description

Assembly Kit table data parsing and conversion.

This module handles the parsing of Assembly Kit sample table data files and their conversion to RPFM’s internal table format. These files contain actual row data that can be used for testing, lookup generation, and schema validation.

§Overview

Assembly Kit provides not only table structure definitions (see the table_definition module) but also sample data files containing actual table rows. These XML files are useful for:

  • Schema validation: Verifying field types match actual data
  • Lookup generation: Extracting hardcoded enum/lookup values from descriptions
  • Testing: Ensuring RPFM can correctly parse real game data
  • Reference: Understanding what values appear in specific fields

§File Format

Table data files are XML files with the same name as their corresponding definition files (without the TWaD_ prefix). For example:

  • Definition: TWaD_units_tables.xml
  • Data: units_tables.xml

Each file contains rows of data in XML format:

<dataroot>
  <units_tables>
    <key>unit_1</key>
    <category>infantry</category>
    <is_naval>false</is_naval>
  </units_tables>
  <units_tables>
    <key>unit_2</key>
    <category>cavalry</category>
    <is_naval>false</is_naval>
  </units_tables>
</dataroot>

§Main Types

§Functionality

The primary operations are:

  1. Batch Reading: RawTable::read_all() reads all table data files from a directory
  2. Individual Reading: RawTable::read() parses a single table data file
  3. Conversion to DB: RawTable::to_db() converts to RPFM’s DB format
  4. Conversion to Table: RawTable::to_table() converts to in-memory table format

§Workarounds and Special Handling

§Missing Fields

Some games (Thrones, Attila, Rome 2, Shogun 2) omit fields from rows when the field value is empty. RPFM handles this by inserting default values for missing fields.

§Empty Field Markers

Due to XML parser limitations, empty fields are temporarily filled with placeholder text ("Frodo Best Waifu") which is removed after parsing.

§Field Renaming

The XML parser requires uniform field names, so table-specific field names are replaced with generic <datafield> tags before parsing, with the original name stored as an attribute.

Structs§

RawTable
Complete table data parsed from Assembly Kit XML files.
RawTableField
Individual field value within a table row.
RawTableRow
Single row of data from an Assembly Kit table.