Skip to main content

Module background_thread

Module background_thread 

Source
Expand description

Per-session command dispatcher — where every Pack, schema, search, diagnostics and dependency operation actually runs.

Each Session spawns one task running background_loop. The loop pulls (reply_sender, Command) pairs off the session’s mpsc channel, handles the command synchronously against the session’s in-memory state (open packs, dependency cache, settings cache, schema), and ships every response back over the per-request reply_sender.

Running commands serially per session is what keeps state consistent across many concurrent requests in the same session: a SavePack followed by a ClosePack always sees the right Pack, even when the WebSocket multiplexer is firing requests as fast as the client sends them.

Telemetry: each dispatched command is recorded via rpfm_telemetry::record_action so usage counters reflect what the session actually did.

Constants§

DEFAULT_PACK_EXT 🔒
Extension appended to DEFAULT_PACK_STEM when materialising a new Pack’s filename.
DEFAULT_PACK_STEM 🔒
Stem used to seed names for newly created Packs (new_pack.pack, new_pack_2.pack, …).
VANILLA_FIXES_NAME
Filename prefix for community-maintained vanilla loc fix TSVs in the Total War Translation Hub repo (e.g. vanilla_fixes_es.tsv). Each one carries fixes for vanilla loc bugs in a specific language; the suffix is the language code.
VANILLA_LOC_NAME
Filename of the per-game vanilla English Loc TSV bundled in the Total War Translation Hub repo. The translator compares mod loc entries against this file to detect rows that match vanilla and can be auto-translated from the official localisation.

Functions§

background_loop
The per-session command dispatcher.
clipboard_entries_from_paths 🔒
Expand selected paths into file path entries for the clipboard.
command_name 🔒
Extracts the variant name (e.g. "NewPack") from a Command for telemetry.
decode_and_send_file 🔒
derive_new_pack_name 🔒
Derives a unique pack name for new (unsaved) packs. Appends a numeric suffix (_2, _3, etc.) to the stem if the base name is already taken. Returns a name like “new_pack.pack”, “new_pack_2.pack”, etc.
exe_path 🔒
In debug mode, this function returns the base folder of the repo. In release mode, it returns the folder where the executable of the program is.
get_pack 🔒
Looks up a pack by key. If not found, sends a “Pack not found” error and returns None.
git_update_check 🔒
Spawns an async task that checks for git updates for the given repository configuration, sending the result back through sender.
load_schema 🔒
Function to simplify logic for changing game selected.
pack_key_from_path 🔒
Converts a path to its string representation for use as a pack key.
tr 🔒