Pages

Native game settings policy

What a game's policy is, where it lives in mod.toml, and how AEX checks it.

A game's policy supplies defaults and permissions for the active game: a base match profile and the game's own match rules and presentation preferences over it. You need one when your game should start matches from other rules than TA's, or lock a setting for everyone who plays it.

The worked example

In the game's mod.toml:

[match]
base = "beta-patch"

[[match.rules]]
key = "match.maxUnits"
value = "500"
permission = "host"

[[match.rules]]
key = "match.cheats"
value = "off"
permission = "fixed"

[[match.preferences]]
key = "menu_style"
value = "aex"
permission = "fixed"

[[match.preferences]]
key = "texture_filtering"
value = "nearest"
permission = "player"

Matches start from the beta-patch profile with a 500-unit limit the host may change, cheats off for everyone, the AEX menu style locked, and nearest texture filtering as a default the player may change.

Where it lives

The policy lives in mod.toml's [match] section, whose shape is in the match profile. Identity remains the rest of mod.toml; native unit and faction content remains under content/. A game whose mod.toml has no [match] may still carry a legacy game.toml.

What each permission does depends on the setting: match rules take host or fixed; presentation preferences take player or fixed.

Checks

A missing policy keeps TA's rules. An invalid policy refuses startup. Unknown fields, unknown bases, duplicate settings, unsupported values and unknown schema versions are errors. The file is bounded to 1 MiB. creator::validateGamePolicy makes the same checks on a policy built in memory, and creator::writeMatchSection refuses to write one that fails them.

What goes wrong

The log, aex.log, says where the policy came from:

[game-policy] match profile from mod.toml [match] (base beta-patch)

An invalid policy stops AEX at start-up with Cannot initialize game policy: followed by the first problem, for example:

Unknown mod.toml [match] field: <field>
Unknown match profile base: "<base>" (expected "ta" or "beta-patch")
Duplicate setting: <key>
Unknown setting field: <field>
Setting permission must be player, host or fixed
mod.toml exceeds the 1 MiB schema limit

A mod.toml that does not parse at all leaves its [match] unread:

[game-policy] mod.toml line <n>: <message>; its [match] is not read, trying the legacy game.toml

Next