mirror of
https://github.com/minetest/minetest.git
synced 2024-12-23 22:52:25 +01:00
Prevent loading a world with unresolved dependencies (#12542)
This commit is contained in:
parent
8c29c4f620
commit
2d10fa7867
@ -213,9 +213,10 @@ void Client::loadMods()
|
||||
}
|
||||
|
||||
m_mods = modconf.getMods();
|
||||
|
||||
// complain about mods with unsatisfied dependencies
|
||||
if (!modconf.isConsistent()) {
|
||||
modconf.printUnsatisfiedModsError();
|
||||
errorstream << modconf.getUnsatisfiedModsError() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -21,16 +21,27 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "log.h"
|
||||
#include "settings.h"
|
||||
#include "filesys.h"
|
||||
#include "gettext.h"
|
||||
|
||||
void ModConfiguration::printUnsatisfiedModsError() const
|
||||
|
||||
std::string ModConfiguration::getUnsatisfiedModsError() const
|
||||
{
|
||||
std::ostringstream error;
|
||||
error << gettext("Some mods have unsatisfied dependencies:") << std::endl;
|
||||
|
||||
for (const ModSpec &mod : m_unsatisfied_mods) {
|
||||
errorstream << "mod \"" << mod.name
|
||||
<< "\" has unsatisfied dependencies: ";
|
||||
//~ Error when a mod is missing dependencies. Ex: "Mod Title is missing: mod1, mod2, mod3"
|
||||
error << " - " << fmtgettext("%s is missing:", mod.name.c_str());
|
||||
for (const std::string &unsatisfied_depend : mod.unsatisfied_depends)
|
||||
errorstream << " \"" << unsatisfied_depend << "\"";
|
||||
errorstream << std::endl;
|
||||
error << " " << unsatisfied_depend;
|
||||
error << "\n";
|
||||
}
|
||||
|
||||
error << "\n"
|
||||
<< gettext("Install and enable the required mods, or disable the mods causing errors.") << "\n"
|
||||
<< gettext("Note: this may be caused by a dependency cycle, in which case try updating the mods.");
|
||||
|
||||
return error.str();
|
||||
}
|
||||
|
||||
void ModConfiguration::addModsInPath(const std::string &path, const std::string &virtual_path)
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
*/
|
||||
const std::vector<ModSpec> &getMods() const { return m_sorted_mods; }
|
||||
|
||||
void printUnsatisfiedModsError() const;
|
||||
std::string getUnsatisfiedModsError() const;
|
||||
|
||||
/**
|
||||
* Adds all mods in the given path. used for games, modpacks
|
||||
|
@ -425,14 +425,10 @@ void Server::init()
|
||||
|
||||
m_modmgr = std::make_unique<ServerModManager>(m_path_world);
|
||||
std::vector<ModSpec> unsatisfied_mods = m_modmgr->getUnsatisfiedMods();
|
||||
|
||||
// complain about mods with unsatisfied dependencies
|
||||
if (!m_modmgr->isConsistent()) {
|
||||
m_modmgr->printUnsatisfiedModsError();
|
||||
|
||||
warningstream
|
||||
<< "You have unsatisfied dependencies, loading your world anyway. "
|
||||
<< "This will become a fatal error in the future." << std::endl;
|
||||
std::string error = m_modmgr->getUnsatisfiedModsError();
|
||||
throw ServerError(error);
|
||||
}
|
||||
|
||||
//lock environment
|
||||
|
@ -57,8 +57,8 @@ public:
|
||||
return configuration.isConsistent();
|
||||
}
|
||||
|
||||
inline void printUnsatisfiedModsError() const {
|
||||
return configuration.printUnsatisfiedModsError();
|
||||
inline std::string getUnsatisfiedModsError() const {
|
||||
return configuration.getUnsatisfiedModsError();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user