Expand description
Database table files for Total War game data.
DB files are the primary data storage format in Total War games, containing game data organized into tables similar to relational database tables. Each table stores structured data like units, buildings, technologies, and campaign settings.
§Overview
DB tables are binary files with a sequential format requiring a schema definition to decode. The definition specifies the column types and order, and tables can be versioned to handle format changes across game updates.
Key characteristics:
- Schema-dependent: Requires a definition from the schema to decode
- Versioned: Optional version number in header for format evolution
- Fragmented: Tables can be split across multiple files
- Binary: Tightly packed binary format for efficient storage
§Table Structure
Each DB file consists of a header followed by row data. The header contains metadata like version, GUID (for some games), and row count. The data section is a sequence of rows matching the table definition.
§Schema Definitions
To decode a DB table, you need:
- Table name: Identifies which definition to use (e.g.,
"units_tables") - Schema: Contains definitions for all known table versions
- Version: Optional version number from the header (defaults to 0)
See the Schema module for details on definitions and the
Table module for the table data structure.
§DB Structure
§Header
| Bytes | Type | Data |
|---|---|---|
| 4 | &[u8] | GUID Marker. Optional. |
| 2 + 72 | Sized StringU16 | GUID. Only present if GUID Marker is present too. |
| 4 | &[u8] | Version Marker. Optional. |
| 4 | u32 | Version of the table. Only present if Version Marker is too. |
| 1 | bool | Unknown. Probably a bool because it’s always either 0 or 1. |
| 4 | u32 | Amount of entries on the table. |
§Data
The data structure depends on the definition of the table.
Structs§
- DB
- In-memory representation of a decoded DB table.