Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
mod_configuration.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013-22 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include "mods.h"
8
9
18{
19public:
23 inline bool isConsistent() const { return m_unsatisfied_mods.empty(); }
24
25 inline const std::vector<ModSpec> &getUnsatisfiedMods() const
26 {
27 return m_unsatisfied_mods;
28 }
29
37 const std::vector<ModSpec> &getMods() const { return m_sorted_mods; }
38
39 std::string getUnsatisfiedModsError() const;
40
48 void addModsInPath(const std::string &path, const std::string &virtual_path);
49
53 void addMods(const std::vector<ModSpec> &new_mods);
54
58 void addGameMods(const SubgameSpec &gamespec);
59
66 void addModsFromConfig(const std::string &settings_path,
67 const std::unordered_map<std::string, std::string> &modPaths);
68
73
74private:
75 std::string m_first_mod; // "" <=> no mod
76 std::string m_last_mod; // "" <=> no mod
77
78 std::vector<ModSpec> m_sorted_mods;
79
85
86 // mods with unmet dependencies. Before dependencies are resolved,
87 // this is where all mods are stored. Afterwards this contains
88 // only the ones with really unsatisfied dependencies.
89 std::vector<ModSpec> m_unsatisfied_mods;
90
91 // set of mod names for which an unresolved name conflict
92 // exists. A name conflict happens when two or more mods
93 // at the same level have the same name but different paths.
94 // Levels (mods in higher levels override mods in lower levels):
95 // 1. game mod in modpack; 2. game mod;
96 // 3. world mod in modpack; 4. world mod;
97 // 5. addon mod in modpack; 6. addon mod.
98 std::unordered_set<std::string> m_name_conflicts;
99};
ModConfiguration is a subset of installed mods.
Definition mod_configuration.h:18
const std::vector< ModSpec > & getUnsatisfiedMods() const
Definition mod_configuration.h:25
void addModsInPath(const std::string &path, const std::string &virtual_path)
Adds all mods in the given path.
Definition mod_configuration.cpp:35
void resolveDependencies()
move mods from m_unsatisfied_mods to m_sorted_mods in an order that satisfies dependencies
Definition mod_configuration.cpp:211
std::vector< ModSpec > m_sorted_mods
Definition mod_configuration.h:78
std::string m_first_mod
Definition mod_configuration.h:75
void checkConflictsAndDeps()
Call this function once all mods have been added.
Definition mod_configuration.cpp:189
std::vector< ModSpec > m_unsatisfied_mods
Definition mod_configuration.h:89
const std::vector< ModSpec > & getMods() const
List of mods sorted such that they can be loaded in the given order with all dependencies being fulfi...
Definition mod_configuration.h:37
std::unordered_set< std::string > m_name_conflicts
Definition mod_configuration.h:98
std::string m_last_mod
Definition mod_configuration.h:76
std::string getUnsatisfiedModsError() const
Definition mod_configuration.cpp:15
void addModsFromConfig(const std::string &settings_path, const std::unordered_map< std::string, std::string > &modPaths)
Adds mods specified by a world.mt config.
Definition mod_configuration.cpp:110
bool isConsistent() const
Definition mod_configuration.h:23
void addMods(const std::vector< ModSpec > &new_mods)
Adds all mods in new_mods
Definition mod_configuration.cpp:40
void addGameMods(const SubgameSpec &gamespec)
Adds game mods.
Definition mod_configuration.cpp:100
Definition subgames.h:15