Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
ModConfiguration Class Reference

ModConfiguration is a subset of installed mods. More...

#include <mod_configuration.h>

+ Collaboration diagram for ModConfiguration:

Public Member Functions

bool isConsistent () const
 
const std::vector< ModSpec > & getUnsatisfiedMods () const
 
const std::vector< ModSpec > & getMods () const
 List of mods sorted such that they can be loaded in the given order with all dependencies being fulfilled.
 
std::string getUnsatisfiedModsError () const
 
void addModsInPath (const std::string &path, const std::string &virtual_path)
 Adds all mods in the given path.
 
void addMods (const std::vector< ModSpec > &new_mods)
 Adds all mods in new_mods
 
void addGameMods (const SubgameSpec &gamespec)
 Adds game mods.
 
void addModsFromConfig (const std::string &settings_path, const std::unordered_map< std::string, std::string > &modPaths)
 Adds mods specified by a world.mt config.
 
void checkConflictsAndDeps ()
 Call this function once all mods have been added.
 

Private Member Functions

void resolveDependencies ()
 move mods from m_unsatisfied_mods to m_sorted_mods in an order that satisfies dependencies
 

Private Attributes

std::string m_first_mod
 
std::string m_last_mod
 
std::vector< ModSpecm_sorted_mods
 
std::vector< ModSpecm_unsatisfied_mods
 
std::unordered_set< std::string > m_name_conflicts
 

Detailed Description

ModConfiguration is a subset of installed mods.

This class is used to resolve dependencies and return a sorted list of mods.

This class should not be extended from, but instead used as a component in other classes.

Member Function Documentation

◆ addGameMods()

void ModConfiguration::addGameMods ( const SubgameSpec & gamespec)

Adds game mods.

References addModsInPath(), SubgameSpec::first_mod, SubgameSpec::gamemods_path, SubgameSpec::id, SubgameSpec::last_mod, m_first_mod, and m_last_mod.

Referenced by ServerModManager::ServerModManager(), and ModApiMainMenu::l_check_mod_configuration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addMods()

void ModConfiguration::addMods ( const std::vector< ModSpec > & new_mods)

Adds all mods in new_mods

References m_name_conflicts, m_unsatisfied_mods, ModSpec::path, and warningstream.

Referenced by addModsFromConfig(), addModsInPath(), and ModApiMainMenu::l_check_mod_configuration().

+ Here is the caller graph for this function:

◆ addModsFromConfig()

void ModConfiguration::addModsFromConfig ( const std::string & settings_path,
const std::unordered_map< std::string, std::string > & modPaths )

Adds mods specified by a world.mt config.

Parameters
settings_pathPath to world.mt
modPathsMap from virtual name to mod path

References addMods(), errorstream, flattenMods(), Settings::get(), getModsInPath(), Settings::getNames(), is_yes(), m_unsatisfied_mods, Settings::readConfigFile(), Settings::setBool(), and Settings::updateConfigFile().

Referenced by ServerModManager::ServerModManager(), and Client::loadMods().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addModsInPath()

void ModConfiguration::addModsInPath ( const std::string & path,
const std::string & virtual_path )

Adds all mods in the given path.

used for games, modpacks and world-specific mods (worldmods-folders)

Parameters
pathTo search, should be absolute
virtual_pathVirtual path for this directory, see comment in ModSpec

References addMods(), flattenMods(), and getModsInPath().

Referenced by ServerModManager::ServerModManager(), addGameMods(), and ModApiMainMenu::l_check_mod_configuration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkConflictsAndDeps()

void ModConfiguration::checkConflictsAndDeps ( )

Call this function once all mods have been added.

References m_name_conflicts, and resolveDependencies().

Referenced by ServerModManager::ServerModManager(), ModApiMainMenu::l_check_mod_configuration(), and Client::loadMods().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMods()

const std::vector< ModSpec > & ModConfiguration::getMods ( ) const
inline

List of mods sorted such that they can be loaded in the given order with all dependencies being fulfilled.

I.e: every mod in this list has only dependencies on mods which appear earlier in the vector.

References m_sorted_mods.

Referenced by ServerModManager::getModNames(), ServerModManager::getMods(), ServerModManager::getModsMediaPaths(), ServerModManager::getModSpec(), ModApiMainMenu::l_check_mod_configuration(), Client::loadMods(), and ServerModManager::loadMods().

+ Here is the caller graph for this function:

◆ getUnsatisfiedMods()

const std::vector< ModSpec > & ModConfiguration::getUnsatisfiedMods ( ) const
inline

References m_unsatisfied_mods.

Referenced by ServerModManager::getUnsatisfiedMods(), and ModApiMainMenu::l_check_mod_configuration().

+ Here is the caller graph for this function:

◆ getUnsatisfiedModsError()

std::string ModConfiguration::getUnsatisfiedModsError ( ) const

References fmtgettext(), and m_unsatisfied_mods.

Referenced by ServerModManager::getUnsatisfiedModsError(), and Client::loadMods().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isConsistent()

bool ModConfiguration::isConsistent ( ) const
inline
Returns
true if all dependencies are fulfilled.

References m_unsatisfied_mods.

Referenced by ServerModManager::isConsistent(), ModApiMainMenu::l_check_mod_configuration(), and Client::loadMods().

+ Here is the caller graph for this function:

◆ resolveDependencies()

void ModConfiguration::resolveDependencies ( )
private

move mods from m_unsatisfied_mods to m_sorted_mods in an order that satisfies dependencies

References g_settings, Settings::getBool(), m_first_mod, m_last_mod, m_sorted_mods, m_unsatisfied_mods, ModSpec::name, and ModSpec::unsatisfied_depends.

Referenced by checkConflictsAndDeps().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_first_mod

std::string ModConfiguration::m_first_mod
private

Referenced by addGameMods(), and resolveDependencies().

◆ m_last_mod

std::string ModConfiguration::m_last_mod
private

Referenced by addGameMods(), and resolveDependencies().

◆ m_name_conflicts

std::unordered_set<std::string> ModConfiguration::m_name_conflicts
private

Referenced by addMods(), and checkConflictsAndDeps().

◆ m_sorted_mods

std::vector<ModSpec> ModConfiguration::m_sorted_mods
private

Referenced by getMods(), and resolveDependencies().

◆ m_unsatisfied_mods

std::vector<ModSpec> ModConfiguration::m_unsatisfied_mods
private

The documentation for this class was generated from the following files: