Skip to main content

Module layout

Module layout 

Source
Expand description

Layouts of the records of a startpos, used to write new ones.

A startpos is a tree of records with dozens of fields each, most of them constant. Instead of building each record by hand, the writer starts from a layout extracted from game-built startposes: for every record path, its version, its child slots in order (leaves with their most common value, child records always present or optional) and whether its children are an array of groups. Generators then only set the fields that change.

Each campaign has its own layout, and the game has one merged from all its campaigns, so records any of them uses are known to all (and to new campaigns, see StartposLayout::with_fallback). Layout files live in the STARTPOS_LAYOUT_FOLDER folder of RPFM’s config folder (see layout_file_name).

§Field names

Leaves are named after the previous child record that’s always present and their position after it, skipping records: MORGUE+3 is the third leaf after the MORGUE record. Leaves before any record use ^ (^+1). Optional records don’t move the names and optional leaves count even when missing, so names are stable across instances. A record repeated in the same group gets its occurrence appended from the second one on (FACTION_FLAG_AND_COLOURS@2).

§Paths

A record’s path is the names of the records leading to it from the root, separated by / (CAMPAIGN_STARTPOS/CAMPAIGN_ENV/CAMPAIGN_MODEL/WORLD/FACTION_ARRAY/FACTION). Repeated records share the layout of their path, whatever their occurrence (see child_path).

§Lists

Some records store variable-length lists in a single group (the family tree, the AI pathfinding and influence maps). Records with more than MAX_LAYOUT_SLOTS slots are free-form: their layout has no slots and generators push their children directly. Their child records still have layouts.

§Variants

The AI pools (VARIANT_ARRAYS) hold objects of many types in one array, each group starting with its type code. Each type also gets its own layout, at variant_path, so its groups start from that type’s defaults.

§Defaults

A leaf’s default is its most common value. Arrays longer than a few dozen elements are generated data (vision bits, pathfinding and AI maps), not constants, so their default is an empty array of the same type.

Structs§

GroupBuilder
A group of a record being built.
GroupView
A group of an existing record, read through the layout of its path: its children by slot id (leaf name or child record key).
RecordBuilder
Builds a record from its layout: every slot starts with its default, and generators replace what they need.
RecordLayout
Layout of the records at a path.
StartposLayout
Layouts of every record path of a startpos.

Enums§

Slot
A child slot of a record group.

Constants§

MAX_LAYOUT_SLOTS
Most slots a record layout can have. Records with more are lists, kept free-form.
STARTPOS_LAYOUT_FOLDER
Folder, inside RPFM’s config folder, where the startpos layout files live.
VARIANT_ARRAYS
Names of the arrays whose groups start with a type code, which get a layout per type (see variant_path).

Functions§

child_path
Returns the path of a child record from its parent’s path and its key: the occurrence suffix is dropped, so every occurrence shares a layout.
layout_file_name
Returns the file name of a layout: the one merged from all the game’s campaigns, or a campaign’s.
variant_path
Returns the path of the layout of a type of a variant array (see VARIANT_ARRAYS).