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, schema) and the process-wide crate::settings::SETTINGS store, 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.

Enums§

DeltaMergeOutcome 🔒
Outcome of a delta merge attempt: either a finished file ready to insert, or the conflicts blocking it.

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.

Functions§

background_loop
The per-session command dispatcher.
cached_lua_api 🔒
This function returns the Lua scripting API of a game, rebuilding the cached one if it’s outdated.
change_encryption_flag 🔒
Sets or clears one of the encryption flags of a pack, sending the result back.
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.
container_path_from_disk_path 🔒
Rebuilds the in-pack container path of a file extracted under base_folder.
decode_and_send_file 🔒
delta_merge_files 🔒
Delta-merges the decoded DB or Loc sources (same type/table) against the vanilla/parent baseline, applying any already-known resolutions. See rpfm_extensions::merge for the merge rules.
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 🔒
pack_key_from_path 🔒
Converts a path to its string representation for use as a pack key.
plugin_script_interpreter 🔒
Returns the interpreter command for a plugin script, based on its extension.
tr 🔒
unique_pack_key 🔒
Generate an unique pack key that does not conflict with any existing open packs.

Type Aliases§

LuaApiCache 🔒
Function to simplify logic for changing game selected. Cached Lua scripting API: the docs path and dependencies build date it was built from, and the API itself.