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
RawTable: Complete table with definition and all row dataRawTableRow: Single row of dataRawTableField: Individual field value within a row
§Functionality
The primary operations are:
- Batch Reading:
RawTable::read_all()reads all table data files from a directory - Individual Reading:
RawTable::read()parses a single table data file - Conversion to DB:
RawTable::to_db()converts to RPFM’sDBformat - 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.
- RawTable
Field - Individual field value within a table row.
- RawTable
Row - Single row of data from an Assembly Kit table.