Skip to main content

GameInfo

Struct GameInfo 

Source
pub struct GameInfo { /* private fields */ }
Expand description

Complete configuration and metadata for a supported Total War game.

This struct contains all information needed for RPFM to work with a specific Total War game, including file formats, paths, features, and game-specific behaviors.

§Organization

The struct can be organized into several logical groups:

  • Identity: Key, display name
  • File Formats: PFH versions, schema files, compression formats
  • Features: Editing support, GUID requirements, portrait settings
  • Assembly Kit: Raw DB version, lost fields list
  • Paths & Installation: Install data per platform/store
  • Localization: Language file, locale support
  • Tools: Lua autogen, tool variables
  • Restrictions: Banned files, validation logic

§Access Patterns

Most fields are accessed through getters provided by the Getters derive macro. Some methods provide computed values based on installation detection:

§Installation Detection

The struct supports multiple installation types per game and automatically detects which one is present by examining executables and DLL files in the game directory. See GameInfo::install_type() for details.

Implementations§

Source§

impl GameInfo

Source

pub fn display_name(&self) -> &&'static str

User-friendly display name (e.g., "Warhammer 3").

Shown in UI dropdowns and messages.

Source

pub fn pfh_versions(&self) -> &HashMap<PFHFileType, PFHVersion>

PackFile header versions by file type.

Maps PFHFileType (Boot, Release, Patch, Mod, Movie) to the appropriate PFHVersion for this game. If a type isn’t in the map, defaults to Mod type.

Source

pub fn schema_file_name(&self) -> &String

Schema file name for this game (e.g., "schema_wh3.ron").

Used to load table definitions for decoding DB files.

Source

pub fn dependencies_cache_file_name(&self) -> &String

Dependencies cache file name for this game.

Stores cached dependency tree for faster pack loading.

Source

pub fn raw_db_version(&self) -> &i16

Assembly Kit version for raw database files.

  • -1: No Assembly Kit available
  • 0: Empire/Napoleon format
  • 1: Shogun 2 format
  • 2: Rome 2 and later format
Source

pub fn portrait_settings_version(&self) -> &Option<u32>

Portrait settings file version for this game.

None if the game doesn’t use portrait settings files.

Source

pub fn supports_editing(&self) -> &bool

Whether PackFiles can be saved for this game.

Some very old games are read-only.

Source

pub fn db_tables_have_guid(&self) -> &bool

Whether DB table headers include GUIDs.

Newer games include a GUID in the table header for identification.

Source

pub fn locale_file_name(&self) -> &Option<String>

Language/locale file name (e.g., "language.txt").

None if the game doesn’t use a language file, or if all locales are loaded.

Source

pub fn banned_packedfiles(&self) -> &Vec<String>

Paths to files that RPFM should never edit.

Contains table names or file paths that are protected by the game’s integrity checks to prevent bypassing DLC ownership validation.

Source

pub fn icon_small(&self) -> &String

Small icon file name for UI display.

Source

pub fn icon_big(&self) -> &String

Large icon file name for UI display.

Source

pub fn vanilla_db_table_name_logic(&self) -> &VanillaDBTableNameLogic

Logic for naming vanilla DB table files.

Some games name tables after their folder, others use a default name.

Source

pub fn tool_vars(&self) -> &HashMap<String, String>

Game-specific tool variables.

Key-value pairs for tool-specific configuration.

Source

pub fn lua_autogen_folder(&self) -> &Option<String>

Subdirectory name in Lua autogen repository for this game.

None if Lua autogen doesn’t support this game.

Source

pub fn ak_lost_fields(&self) -> &Vec<String>

Assembly Kit fields that are lost during export.

List of table_name.field_name entries that exist in vanilla data but don’t appear in Assembly Kit exports because they are either unused or separated from the tables on export.

Source

pub fn compression_formats_supported(&self) -> &Vec<CompressionFormat>

Supported compression formats, newest to oldest.

Used to determine which compression to use when saving files.

Source

pub fn max_cs2_parsed_version(&self) -> &u32

Maximum CS2.parsed format version supported.

Used for cross-game model conversion compatibility.

Source§

impl GameInfo

Implementation of GameInfo.

Source

pub fn key(&self) -> &str

Returns the game’s unique identifier key.

The key is the game name in lowercase without spaces (e.g., "warhammer_3", "troy"). This is used for configuration files, file paths, and internal identification.

§Returns

A static string slice containing the game’s key identifier.

§Example
use rpfm_lib::games::supported_games::{SupportedGames, KEY_WARHAMMER_3};

let supported_games = SupportedGames::default();
let game_info = supported_games.game(&KEY_WARHAMMER_3).unwrap();
assert_eq!(game_info.key(), KEY_WARHAMMER_3);
Source

pub fn pfh_version_by_file_type(&self, pfh_file_type: PFHFileType) -> PFHVersion

Returns the PackFile format version for a specific file type.

Different PackFile types (Boot, Release, Patch, Mod, Movie) may use different format versions within the same game. This method looks up the appropriate PFHVersion for the given PFHFileType.

§Arguments
  • pfh_file_type - The type of PackFile to look up
§Returns

The PFHVersion used for the specified file type. If no specific version is configured for the file type, returns the version used for Mod PackFiles.

§Example
use rpfm_lib::games::supported_games::{SupportedGames, KEY_WARHAMMER_3};
use rpfm_lib::games::pfh_file_type::PFHFileType;

let supported_games = SupportedGames::default();
let game_info = supported_games.game(&KEY_WARHAMMER_3).unwrap();
let mod_version = game_info.pfh_version_by_file_type(PFHFileType::Mod);
Source

pub fn install_type(&self, game_path: &Path) -> Result<InstallType>

Detects the installation type (Steam, Epic, Wargaming, etc.) for a game installation.

This method analyzes the game’s directory structure and files to determine which platform or distribution the game was installed from. The result is cached to avoid repeated filesystem scans.

§Detection Strategy
  1. Checks for platform-specific executable names
  2. For Windows installations with multiple possible types:
    • Looks for steam_api.dll or steam_api64.dll for Steam
    • Looks for EOSSDK-Win64-Shipping.dll for Epic Games Store
    • Falls back to Wargaming/Netease if neither found
  3. Assumes Linux Steam for Linux installations
§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

Returns the detected InstallType, or an error if the path is invalid.

§Performance

Results are cached internally. First call takes ~10ms, subsequent calls are instant.

§Example
use rpfm_lib::games::supported_games::{SupportedGames, KEY_WARHAMMER_3};
use std::path::Path;

let supported_games = SupportedGames::default();
let game_info = supported_games.game(&KEY_WARHAMMER_3).unwrap();
let game_path = Path::new("/path/to/game");

match game_info.install_type(game_path) {
    Ok(install_type) => println!("Detected: {:?}", install_type),
    Err(e) => eprintln!("Detection failed: {}", e),
}
Source

pub fn install_data(&self, game_path: &Path) -> Result<&InstallData>

Returns the installation-specific data for a game.

After detecting the installation type, this method retrieves the corresponding configuration data (executable names, paths, Steam IDs, etc.) for that installation.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

Returns a reference to the InstallData for the detected installation type.

§Errors

Returns an error if:

  • The installation type cannot be detected
  • The detected installation type is not supported for this game
Source

pub fn data_path(&self, game_path: &Path) -> Result<PathBuf>

Returns the path to the game’s /data directory.

The /data directory contains the game’s vanilla PackFiles and is the primary location for game content. The exact directory name may vary by game and platform.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

Absolute path to the /data directory (or platform-specific equivalent).

§Errors

Returns an error if the installation type cannot be detected or is not supported.

Source

pub fn content_path(&self, game_path: &Path) -> Result<PathBuf>

Returns the path to the downloaded mods directory.

This is the directory where Steam Workshop or other platform mods are downloaded to. Not all games support downloaded mods through official platforms.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

Absolute path to the downloaded mods directory.

§Errors

Returns an error if the installation type cannot be detected or is not supported.

Source

pub fn language_path(&self, game_path: &Path) -> Result<PathBuf>

Returns the directory containing the game’s language configuration file.

The language configuration file (typically language.txt or similar) stores the player’s selected interface language. The file location varies by game and may be nested inside a language-specific subdirectory.

§Behavior

If the language file is in the base directory, returns that directory. Otherwise, searches through language-specific subdirectories (brazilian, chinese, english, etc.) and returns the first one found.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

Absolute path to the directory containing the language file.

§Errors

Returns an error if the installation type cannot be detected or is not supported.

Source

pub fn local_mods_path(&self, game_path: &Path) -> Result<PathBuf>

Returns the path to the local mods directory.

This is where locally-installed mods are loaded from by the game. The location varies by game:

  • Troy: A separate directory from /data to avoid polluting the data folder
  • Other games: Points to the /data directory

Mods placed in this directory are loaded by the game without requiring workshop or platform distribution.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

Absolute path to the local mods directory.

§Errors

Returns an error if the installation type cannot be detected or is not supported.

Source

pub fn content_packs_paths(&self, game_path: &Path) -> Option<Vec<PathBuf>>

Returns paths to all PackFiles in the downloaded mods directory.

Recursively scans the downloaded mods directory (Steam Workshop, etc.) and returns paths to all .pack and .bin files found. Returns None if the game doesn’t support downloaded mods or the directory doesn’t exist.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

A sorted vector of absolute paths to PackFiles, or None if not applicable.

§File Extensions

Searches for both .pack and .bin extensions as some games use .bin for certain mod types.

Source

pub fn secondary_packs_paths( &self, secondary_path: &Path, ) -> Option<Vec<PathBuf>>

Returns paths to all PackFiles in a secondary mods directory.

Some users keep additional mod collections in custom directories outside the game installation. This method scans a user-specified secondary path for PackFiles.

The secondary path should contain a subdirectory named after the game’s key (e.g., secondary_path/warhammer_3/), which is then scanned for .pack files.

§Arguments
  • secondary_path - Absolute path to the base secondary mods directory
§Returns

A sorted vector of absolute paths to PackFiles, or None if:

  • The path is not absolute, doesn’t exist, or isn’t a directory
  • The game-specific subdirectory doesn’t exist
  • No .pack files are found
§Path Structure

Expected structure: secondary_path/{game_key}/*.pack

Source

pub fn data_packs_paths(&self, game_path: &Path) -> Option<Vec<PathBuf>>

Returns paths to all PackFiles in the game’s /data directory.

Scans the game’s main data directory (non-recursively) for all .pack files. This typically includes vanilla game PackFiles and any mods installed directly in the data directory.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

A sorted vector of absolute paths to PackFiles, or None if:

  • The data directory cannot be determined
  • The directory doesn’t exist or cannot be read
  • No .pack files are found
Source

pub fn mymod_install_path(&self, game_path: &Path) -> Option<PathBuf>

Returns the installation path for “MyMod” PackFiles.

Returns the directory where mods created with RPFM’s “MyMod” feature should be installed. This is typically the local mods directory. Creates the directory if it doesn’t exist.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

Absolute path to the MyMod installation directory, or None if:

  • The installation type cannot be detected
  • The directory cannot be created
Source

pub fn use_manifest(&self, game_path: &Path) -> Result<bool>

Returns whether to use the game’s manifest file for discovering vanilla PackFiles.

Some games have a manifest.txt file that lists all official PackFiles. This method determines whether RPFM should use that manifest or fall back to a hardcoded list of PackFile names.

§Decision Logic

Returns false (don’t use manifest) if:

  • The installation is Linux (manifests may be unreliable)
  • A hardcoded PackFile list exists for this game/install type
§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

true if the manifest should be used, false if the hardcoded list should be used.

§Errors

Returns an error if the installation type cannot be detected or is not supported.

Source

pub fn steam_id(&self, game_path: &Path) -> Result<u64>

Returns the Steam App ID for the game installation.

The Steam App ID is used for launching games via Steam, checking workshop content, and other Steam-specific integrations.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

The Steam App ID as a 64-bit unsigned integer.

§Errors

Returns an error if:

  • The installation type cannot be detected
  • The installation is not a Steam installation (Windows or Linux)
  • The installation type is not supported for this game
Source

pub fn ca_packs_paths(&self, game_path: &Path) -> Result<Vec<PathBuf>>

Returns paths to all Creative Assembly (vanilla) PackFiles.

Discovers all official game PackFiles in the data directory. Uses the game’s manifest file if available and configured, otherwise falls back to a hardcoded list or scanning all PackFiles.

§Language Filtering

For games with multiple language packs (e.g., Warhammer 3), only returns PackFiles matching the configured game language. This prevents loading multiple language localizations simultaneously.

Language-specific PackFiles typically have local_{language} in their names (e.g., local_en.pack, local_es.pack).

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

A sorted vector of absolute paths to vanilla PackFiles.

§Errors

Returns an error if:

  • The game language cannot be determined
  • The data directory cannot be accessed
  • The installation type is not supported
§Fallback Behavior

If manifest reading fails, automatically falls back to ca_packs_paths_no_manifest().

Source

pub fn game_launch_command(&self, game_path: &Path) -> Result<String>

Returns the launch URI for starting the game.

Generates a platform-specific URI or command that can be used to launch the game from external applications or scripts.

§Platform Support

Currently only supports Steam installations (Windows and Linux), which use Steam URIs in the format steam://rungameid/{app_id}.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

A string containing the launch URI or command.

§Errors

Returns an error if:

  • The installation type cannot be detected
  • The installation platform doesn’t support programmatic launching (e.g., Epic, Wargaming)
  • The installation type is not supported for this game
Source

pub fn executable_path(&self, game_path: &Path) -> Option<PathBuf>

Returns the path to the game’s executable file.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

Absolute path to the game executable, or None if:

  • The installation type cannot be detected
  • The installation type is not supported
Source

pub fn config_path(&self, game_path: &Path) -> Option<PathBuf>

Returns the path to the game’s configuration directory.

Total War games store user configuration, preferences, and save files in a platform-specific configuration directory (e.g., AppData on Windows, ~/.config on Linux).

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

Absolute path to the game’s configuration directory, or None if:

  • The installation type cannot be detected
  • The game doesn’t have a defined configuration folder
  • The platform-specific configuration path cannot be determined
Source

pub fn is_file_banned(&self, path: &str) -> bool

Checks if a file path is banned from modification.

Some game files are protected by integrity checks to prevent bypassing DLC ownership validation. This method checks if a file path matches any banned path prefixes.

§Arguments
  • path - The file path to check (typically a PackFile-relative path)
§Returns

true if the file is banned and should not be modified, false otherwise.

§Comparison

The comparison is case-insensitive and uses prefix matching.

Source

pub fn tool_var(&self, var: &str) -> Option<&String>

Retrieves a game-specific tool variable.

Tool variables are key-value pairs used to configure tool behavior for specific games. Examples might include special file paths, version numbers, or feature flags.

§Arguments
  • var - The variable name to look up
§Returns

The variable value if found, or None if the variable is not defined for this game.

Source

pub fn game_locale_from_file(&self, game_path: &Path) -> Result<Option<String>>

Reads the game’s configured language from its configuration file.

Attempts to read the game’s language setting from its language.txt or equivalent configuration file. This determines which localization PackFiles should be loaded.

§Language Codes

The file typically contains a 2-letter code (e.g., “EN”, “ES”, “DE”) which is mapped to the full language name used in PackFile names.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns
  • Ok(Some(language)) - Language successfully read and mapped
  • Ok(Some("english")) - File missing/unreadable, defaulted to English
  • Ok(None) - Game doesn’t use a language configuration file
§Errors

Returns an error if the language file path cannot be determined due to installation type detection failures.

Source

pub fn game_version_number(&self, game_path: &Path) -> Option<u32>

Extracts the version number from the game’s executable.

Reads version information embedded in the game’s executable file. Currently only implemented for Troy; returns None for other games.

§Version Encoding

The version is encoded as a 32-bit integer:

  • Bits 24-31: Major version
  • Bits 16-23: Minor version
  • Bits 8-15: Patch version
  • Bits 0-7: Build number

For example, version 1.3.0.5 would be encoded as 0x01030005.

§Arguments
  • game_path - Absolute path to the game’s installation directory
§Returns

The encoded version number, or None if:

  • Version extraction is not implemented for this game
  • The executable doesn’t exist
  • The executable version info cannot be read
Source

pub fn find_game_install_location(&self) -> Result<Option<PathBuf>>

Automatically discovers the game’s installation directory.

Searches for the game installation using platform-specific methods. Currently only supports Steam installations via the Steam library folders system.

§Platform Support
  • Windows Steam: Searches via Steam library folders
  • Linux Steam: Searches via Steam library folders
  • Other platforms: Not supported (returns Ok(None))
§Arguments

None - uses the game’s configured Steam App ID

§Returns
  • Ok(Some(path)) - Game installation found at the returned path
  • Ok(None) - Game not found or platform not supported
§Errors

Returns an error if Steam library folder parsing fails.

Source

pub fn find_assembly_kit_install_location(&self) -> Result<Option<PathBuf>>

Automatically discovers the Assembly Kit installation directory.

Assembly Kits are official modding tools distributed separately from the games. This method searches for the Assembly Kit using platform-specific methods, currently only supporting Steam installations.

§Platform Support
  • Windows Steam: Searches via Steam library folders
  • Linux Steam: Searches via Steam library folders
  • Other platforms: Not supported (returns Ok(None))
§Arguments

None - uses the game’s configured Assembly Kit Steam App ID

§Returns
  • Ok(Some(path)) - Assembly Kit found at the returned path
  • Ok(None) - Assembly Kit not found, not available for this game, or platform not supported
§Errors

Returns an error if Steam library folder parsing fails.

Source

pub fn steam_workshop_tags(&self) -> Result<Vec<String>>

Returns the list of Steam Workshop tags available for this game.

Steam Workshop allows mod creators to tag their mods with categories like “graphical”, “campaign”, “units”, etc. This method returns the official list of tags recognized by the Steam Workshop for this specific game.

§Tag Categories

Common tags across games include:

  • Content types: “graphical”, “campaign”, “units”, “battle”
  • Scope: “overhaul”, “ui”, “maps”
  • Collections: “compilation”, “mod manager”
  • Languages: “English”, “Spanish”, etc. (in some games)
§Returns

A vector of tag strings recognized by Steam Workshop for this game.

§Errors

Returns an error if the game doesn’t support Steam Workshop.

Source

pub fn game_by_steam_id(steam_id: u64) -> Result<Self>

Looks up a game by its Steam App ID.

Given a Steam App ID, searches through all supported games to find the matching game. This is useful when you have a Steam App ID (e.g., from Steam library or launch parameters) and need to identify which Total War game it corresponds to.

§Arguments
  • steam_id - The Steam App ID to search for
§Returns

The GameInfo for the matching game.

§Errors

Returns an error if no known game matches the provided Steam App ID.

§Example
use rpfm_lib::games::GameInfo;

// Look up Warhammer 3 by its Steam App ID
let game_info = GameInfo::game_by_steam_id(1142710).unwrap();
assert_eq!(game_info.key(), "warhammer_3");

Trait Implementations§

Source§

impl Clone for GameInfo

Source§

fn clone(&self) -> GameInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GameInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.