Skip to main content

Dependencies

Struct Dependencies 

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

Central dependencies manager for all reference data relevant to a Pack.

This struct caches and manages all data needed for reference lookups, diagnostics, and other operations that require knowledge of vanilla game data or parent mods.

§Data Categories

The dependencies are organized into three persistence levels:

§Serialized to Disk (cached)

These fields are saved to .pak files and only regenerated when the game files change or RPFM is updated:

  • vanilla_files - All files from CA’s official PackFiles
  • vanilla_tables - Index of DB table paths by table name
  • vanilla_locs - Set of Loc file paths
  • vanilla_folders - Set of folder paths for existence checks
  • vanilla_paths - Case-insensitive path lookup map
  • asskit_only_db_tables - Tables only present in Assembly Kit

§Regenerated on Rebuild

These fields are rebuilt each time rebuild() is called, as they depend on the current environment:

  • vanilla_loose_* - Files from the game’s /data folder (not in packs)
  • parent_* - Files from parent mods the current pack depends on

§Runtime Cache

Built on-demand during editing and not persisted:

  • local_tables_references - Cached reference data for edited tables
  • localisation_data - Merged Loc data for quick lookups

Implementations§

Source§

impl Dependencies

Source

pub fn build_date(&self) -> &u64

Date of the generation of this dependencies cache. For checking if it needs an update.

Source

pub fn version(&self) -> &String

Version of the program used to generate the dependencies, so they’re properly invalidated on update.

Source

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

Data to quickly load loose files as part of the dependencies.

Not serialized, regenerated on rebuild because these can frequently change.

Source

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

Data to quickly load CA dependencies from disk.

Source

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

Data to quickly load dependencies from parent mods from disk.

Not serialized, regenerated from parent Packs on rebuild.

Source

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

List of DB tables on the CA loose files. Not really used, but just in case.

Source

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

List of DB tables on the CA files.

Source

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

List of DB tables on the parent files.

Not serialized, regenerated from parent Packs on rebuild.

Source

pub fn vanilla_loose_locs(&self) -> &HashSet<String>

List of Loc tables on the CA loose files. Not really used, but just in case.

Source

pub fn vanilla_locs(&self) -> &HashSet<String>

List of Loc tables on the CA files.

Source

pub fn parent_locs(&self) -> &HashSet<String>

List of Loc tables on the parent files.

Not serialized, regenerated from parent Packs on rebuild.

Source

pub fn vanilla_loose_folders(&self) -> &HashSet<String>

Data to quickly check if a path exists in the vanilla loose files.

Source

pub fn vanilla_folders(&self) -> &HashSet<String>

Data to quickly check if a path exists in the vanilla files.

Source

pub fn parent_folders(&self) -> &HashSet<String>

Data to quickly check if a path exists in the parent mod files.

Source

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

List of vanilla loose paths lowercased, with their casing counterparts. To quickly find files.

Source

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

List of vanilla paths lowercased, with their casing counterparts. To quickly find files.

Source

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

List of parent paths lowercased, with their casing counterparts. To quickly find files.

Not serialized, regenerated from parent Packs on rebuild.

Source

pub fn local_tables_references( &self, ) -> &HashMap<String, HashMap<i32, TableReferences>>

Cached data for local tables.

This is for runtime caching, and it must not be serialized to disk.

Source

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

Data from all the locs, so we can quickly search for a loc entry.

Source

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

DB Files only available on the assembly kit. Usable only for references. Do not use them as the base for new tables.

Source§

impl Dependencies

Source

pub fn rebuild( &mut self, schema: &Option<Schema>, parent_pack_names: &[String], file_path: Option<&Path>, game_info: &GameInfo, game_path: &Path, secondary_path: &Path, ) -> Result<()>

This function takes care of rebuilding the whole dependencies cache to be used with a new Pack.

If a file path is passed, the dependencies cache at that path will be used, replacing the currently loaded dependencies cache. If a schema is not passed, no tables/locs will be pre-decoded. Make sure to decode them later with Dependencies::decode_tables.

Source

pub fn generate_dependencies_cache( schema: &Option<Schema>, game_info: &GameInfo, game_path: &Path, asskit_path: &Option<PathBuf>, ignore_game_files_in_ak: bool, ) -> Result<Self>

This function generates the dependencies cache for the game provided and returns it.

Source

pub fn generate_local_db_references( &mut self, schema: &Schema, packs: &BTreeMap<String, Pack>, table_names: &[String], )

This function builds the local db references data for the tables you pass to it from the Packs provided.

Table names must be provided as full names (with _tables at the end).

NOTE: This function, like many others, assumes the tables are already decoded in the Packs. If they’re not, they’ll be ignored.

Source

pub fn generate_local_definition_references( &mut self, schema: &Schema, table_name: &str, definition: &Definition, )

This function builds the local db references data for the table with the definition you pass to and stores it in the cache.

Source

pub fn generate_references( &self, schema: &Schema, local_table_name: &str, definition: &Definition, ) -> HashMap<i32, TableReferences>

This function builds the local db references data for the table with the definition you pass to, and returns it.

Source

pub fn load(file_path: &Path, schema: &Option<Schema>) -> Result<Self>

This function tries to load dependencies from the path provided.

Source

pub fn save(&mut self, file_path: &Path) -> Result<()>

This function saves a dependencies cache to the provided path.

Source

pub fn needs_updating( &self, game_info: &GameInfo, game_path: &Path, ) -> Result<bool>

This function is used to check if the game files used to generate the dependencies cache have changed, requiring an update.

Source

pub fn decode_tables(&mut self, schema: &Option<Schema>)

Function to force-decode all tables/locs in the dependencies.

Many operations require them to be decoded, so if you did not decoded them on load, make sure to call this to decode them after load.

Source

pub fn file( &self, file_path: &str, include_vanilla: bool, include_parent: bool, case_insensitive: bool, ) -> Result<&RFile>

This function returns a reference to a specific file from the cache, if exists.

Source

pub fn file_mut( &mut self, file_path: &str, include_vanilla: bool, include_parent: bool, ) -> Result<&mut RFile>

This function returns a mutable reference to a specific file from the cache, if exists.

Source

pub fn files_mut_by_paths( &mut self, paths: &HashSet<String>, include_vanilla: bool, include_parent: bool, ) -> HashMap<String, &mut RFile>

Batch variant of Dependencies::file_mut that returns one &mut RFile per matching path.

Source

pub fn files_by_path( &self, file_paths: &[ContainerPath], include_vanilla: bool, include_parent: bool, case_insensitive: bool, ) -> HashMap<String, &RFile>

This function returns a reference to all files corresponding to the provided paths.

Source

pub fn files_by_types( &self, file_types: &[FileType], include_vanilla: bool, include_parent: bool, ) -> HashMap<String, &RFile>

This function returns a reference to all files of the specified FileTypes from the cache, if any, along with their path.

Source

pub fn files_by_types_mut( &mut self, file_types: &[FileType], include_vanilla: bool, include_parent: bool, ) -> HashMap<String, &mut RFile>

This function returns a mutable reference to all files of the specified FileTypes from the cache, if any, along with their path.

Source

pub fn loc_data( &self, include_vanilla: bool, include_parent: bool, ) -> Result<Vec<&RFile>>

This function returns the vanilla/parent locs from the cache, according to the params you pass it.

It returns them in the order the game will load them.

Source

pub fn db_data( &self, table_name: &str, include_vanilla: bool, include_parent: bool, ) -> Result<Vec<&RFile>>

This function returns the vanilla/parent db tables from the cache, according to the params you pass it.

It returns them in the order the game will load them.

NOTE: table_name is expected to be the table’s folder name, with “_tables” at the end.

Source

pub fn db_data_datacored<'a>( &'a self, table_name: &str, packs: &'a BTreeMap<String, Pack>, include_vanilla: bool, include_parent: bool, ) -> Result<Vec<&'a RFile>>

This function returns the vanilla/parent db tables from the cache, according to the params you pass it, applying to them any datacore from the provided Pack.

It returns them in the order the game will load them.

NOTE: table_name is expected to be the table’s folder name, with “_tables” at the end.

Source

pub fn db_and_loc_data( &self, include_db: bool, include_loc: bool, include_vanilla: bool, include_parent: bool, ) -> Result<Vec<&RFile>>

This function returns the vanilla/parent DB and Loc tables from the cache, according to the params you pass it.

It returns them in the order the game will load them.

Source

pub fn db_reference_data( &self, schema: &Schema, packs: &BTreeMap<String, Pack>, table_name: &str, definition: &Definition, loc_data: &Option<HashMap<Cow<'_, str>, Cow<'_, str>>>, ) -> HashMap<i32, TableReferences>

This function returns the reference/lookup data of all relevant columns of a DB Table.

NOTE: This assumes you’ve populated the runtime references before this. If not, it’ll fail.

Source

pub fn loc_key_source(&self, key: &str) -> Option<(String, String, Vec<String>)>

This function returns the table/column/key from the provided loc key.

We return the table without “_tables”. Keep that in mind if you use this.

Source

pub fn file_exists( &self, file_path: &str, include_vanilla: bool, include_parent: bool, case_insensitive: bool, ) -> bool

This function returns if a specific file exists in the dependencies cache.

Source

pub fn folder_exists( &self, folder_path: &str, include_vanilla: bool, include_parent: bool, case_insensitive: bool, ) -> bool

This function returns if a specific folder exists in the dependencies cache.

Source

pub fn are_dependencies_generated(file_path: &Path) -> bool

This function checks if the dependencies cache file exists on disk.

Source

pub fn is_vanilla_data_loaded(&self, include_asskit: bool) -> bool

This function checks if there is vanilla data loaded in the provided cache.

Source

pub fn is_asskit_data_loaded(&self) -> bool

This function checks if there is assembly kit data loaded in the provided cache.

Source

pub fn is_db_outdated(&self, rfile: &RFileDecoded) -> bool

This function is used to check if a table is outdated or not.

Source

pub fn db_version(&self, table_name: &str) -> Option<i32>

This function is used to get the version of a table in the game files, if said table is in the game files.

Source

pub fn db_values_from_table_name_and_column_name( &self, packs: Option<&BTreeMap<String, Pack>>, table_name: &str, column_name: &str, include_vanilla: bool, include_parent: bool, ) -> HashSet<String>

This function returns the list of values a column of a table has, across all instances of said table in the dependencies and the provided Packs.

Source

pub fn db_values_from_table_name_and_column_name_for_value( &self, packs: Option<&BTreeMap<String, Pack>>, table_name: &str, key_column_name: &str, desired_column_name: &str, include_vanilla: bool, include_parent: bool, ) -> HashMap<String, String>

This function returns the value a table has in the row it has a specific value in a specific column.

Source

pub fn update_db( &mut self, rfile: &mut RFileDecoded, ) -> Result<(i32, i32, Vec<String>, Vec<String>)>

This function updates a DB Table to its latest valid version, being the latest valid version the one in the vanilla files.

It returns both, old and new versions, or an error.

Source

pub fn generate_missing_loc_data( &self, packs: &mut BTreeMap<String, Pack>, ) -> Result<Vec<ContainerPath>>

Function to generate the missing loc entries in a pack.

Source

pub fn bruteforce_loc_key_order( &self, schema: &mut Schema, locs: Option<HashMap<String, Vec<String>>>, local_packs: Option<&BTreeMap<String, Pack>>, ak_files: Option<&mut HashMap<String, DB>>, ) -> Result<()>

This function bruteforces the order in which multikeyed tables get their keys together for loc entries.

Source

pub fn generate_automatic_patches( &self, schema: &mut Schema, packs: &BTreeMap<String, Pack>, ) -> Result<()>

This function generates automatic schema patches based mainly on bruteforcing and some clever logic.

Source

pub fn add_tile_maps_and_tiles( &mut self, packs: &mut BTreeMap<String, Pack>, pack_key: Option<&str>, game: &GameInfo, schema: &Schema, options: OptimizerOptions, tile_maps: Vec<PathBuf>, tiles: Vec<(PathBuf, String)>, ) -> Result<(Vec<ContainerPath>, Vec<ContainerPath>)>

Function to add tiles and tile maps to the provided pack.

Only for Warhammer 3.

Source

pub fn build_starpos_pre( &self, packs: &mut BTreeMap<String, Pack>, pack_key: Option<&str>, game: &GameInfo, game_path: &Path, campaign_id: &str, process_hlp_spd_data: bool, sub_start_pos: &str, ) -> Result<()>

Source

pub fn build_starpos_post( &self, packs: &mut BTreeMap<String, Pack>, pack_key: Option<&str>, game: &GameInfo, game_path: &Path, asskit_path: Option<PathBuf>, campaign_id: &str, process_hlp_spd_data: bool, cleanup_mode: bool, sub_start_pos: &[String], ) -> Result<Vec<ContainerPath>>

Function to trigger the second part of the startpos build process, which involves importing the startpos file into the provided pack.

Call this when the game closes after the pre function launched it.

NOTE: The assembly kit path is only needed for Rome 2.

Source

pub fn import_from_ak(&self, table_name: &str, schema: &Schema) -> Result<DB>

This function imports a specific table from the data it has in the AK.

Tables generated with this are VALID.

Source

pub fn insert_loc_as_vanilla_loc(&mut self, rfile: RFile)

This function manually inserts a loc file from this into the dependencies as a vanilla loc.

THIS IS DANGEROUS. DO NOT USE IT UNLESS YOU KNOW WHAT YOU’RE DOING.

Source

pub fn add_recursive_lookups_to_definition( &self, schema: &Schema, definition: &mut Definition, table_name: &str, )

This function manipulates a definition to recursively add reference lookups if found.

THIS IS DANGEROUS IF WE FIND A CYCLIC DEPENDENCY.

Trait Implementations§

Source§

impl Clone for Dependencies

Source§

fn clone(&self) -> Dependencies

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 Dependencies

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Dependencies

Source§

fn default() -> Dependencies

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Dependencies

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Dependencies

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,