Minetest 5.9.0-dev
 
Loading...
Searching...
No Matches
mod_configuration.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2013-22 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation; either version 2.1 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU Lesser General Public License for more details.
14
15You should have received a copy of the GNU Lesser General Public License along
16with this program; if not, write to the Free Software Foundation, Inc.,
1751 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18*/
19
20#pragma once
21
22#include "mods.h"
23
24
33{
34public:
38 inline bool isConsistent() const { return m_unsatisfied_mods.empty(); }
39
40 inline const std::vector<ModSpec> &getUnsatisfiedMods() const
41 {
42 return m_unsatisfied_mods;
43 }
44
52 const std::vector<ModSpec> &getMods() const { return m_sorted_mods; }
53
54 std::string getUnsatisfiedModsError() const;
55
63 void addModsInPath(const std::string &path, const std::string &virtual_path);
64
68 void addMods(const std::vector<ModSpec> &new_mods);
69
73 void addGameMods(const SubgameSpec &gamespec);
74
81 void addModsFromConfig(const std::string &settings_path,
82 const std::unordered_map<std::string, std::string> &modPaths);
83
88
89private:
90 std::vector<ModSpec> m_sorted_mods;
91
97
98 // mods with unmet dependencies. Before dependencies are resolved,
99 // this is where all mods are stored. Afterwards this contains
100 // only the ones with really unsatisfied dependencies.
101 std::vector<ModSpec> m_unsatisfied_mods;
102
103 // set of mod names for which an unresolved name conflict
104 // exists. A name conflict happens when two or more mods
105 // at the same level have the same name but different paths.
106 // Levels (mods in higher levels override mods in lower levels):
107 // 1. game mod in modpack; 2. game mod;
108 // 3. world mod in modpack; 4. world mod;
109 // 5. addon mod in modpack; 6. addon mod.
110 std::unordered_set<std::string> m_name_conflicts;
111};
ModConfiguration is a subset of installed mods.
Definition: mod_configuration.h:33
const std::vector< ModSpec > & getUnsatisfiedMods() const
Definition: mod_configuration.h:40
void addModsInPath(const std::string &path, const std::string &virtual_path)
Adds all mods in the given path.
Definition: mod_configuration.cpp:48
void resolveDependencies()
move mods from m_unsatisfied_mods to m_sorted_mods in an order that satisfies dependencies
Definition: mod_configuration.cpp:221
std::vector< ModSpec > m_sorted_mods
Definition: mod_configuration.h:90
void checkConflictsAndDeps()
Call this function once all mods have been added.
Definition: mod_configuration.cpp:199
std::vector< ModSpec > m_unsatisfied_mods
Definition: mod_configuration.h:101
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:52
std::unordered_set< std::string > m_name_conflicts
Definition: mod_configuration.h:110
std::string getUnsatisfiedModsError() const
Definition: mod_configuration.cpp:28
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:120
bool isConsistent() const
Definition: mod_configuration.h:38
void addMods(const std::vector< ModSpec > &new_mods)
Adds all mods in new_mods
Definition: mod_configuration.cpp:53
void addGameMods(const SubgameSpec &gamespec)
Adds game mods.
Definition: mod_configuration.cpp:113
Definition: subgames.h:30