mirror of
https://github.com/minetest/minetest.git
synced 2025-02-17 10:23:47 +01:00
Prevent loading a world with unresolved dependencies (#12542)
This commit is contained in:
@ -213,9 +213,10 @@ void Client::loadMods()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_mods = modconf.getMods();
|
m_mods = modconf.getMods();
|
||||||
|
|
||||||
// complain about mods with unsatisfied dependencies
|
// complain about mods with unsatisfied dependencies
|
||||||
if (!modconf.isConsistent()) {
|
if (!modconf.isConsistent()) {
|
||||||
modconf.printUnsatisfiedModsError();
|
errorstream << modconf.getUnsatisfiedModsError() << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,16 +21,27 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "filesys.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) {
|
for (const ModSpec &mod : m_unsatisfied_mods) {
|
||||||
errorstream << "mod \"" << mod.name
|
//~ Error when a mod is missing dependencies. Ex: "Mod Title is missing: mod1, mod2, mod3"
|
||||||
<< "\" has unsatisfied dependencies: ";
|
error << " - " << fmtgettext("%s is missing:", mod.name.c_str());
|
||||||
for (const std::string &unsatisfied_depend : mod.unsatisfied_depends)
|
for (const std::string &unsatisfied_depend : mod.unsatisfied_depends)
|
||||||
errorstream << " \"" << unsatisfied_depend << "\"";
|
error << " " << unsatisfied_depend;
|
||||||
errorstream << std::endl;
|
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)
|
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; }
|
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
|
* 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);
|
m_modmgr = std::make_unique<ServerModManager>(m_path_world);
|
||||||
std::vector<ModSpec> unsatisfied_mods = m_modmgr->getUnsatisfiedMods();
|
std::vector<ModSpec> unsatisfied_mods = m_modmgr->getUnsatisfiedMods();
|
||||||
|
|
||||||
// complain about mods with unsatisfied dependencies
|
// complain about mods with unsatisfied dependencies
|
||||||
if (!m_modmgr->isConsistent()) {
|
if (!m_modmgr->isConsistent()) {
|
||||||
m_modmgr->printUnsatisfiedModsError();
|
std::string error = m_modmgr->getUnsatisfiedModsError();
|
||||||
|
throw ServerError(error);
|
||||||
warningstream
|
|
||||||
<< "You have unsatisfied dependencies, loading your world anyway. "
|
|
||||||
<< "This will become a fatal error in the future." << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//lock environment
|
//lock environment
|
||||||
|
@ -57,8 +57,8 @@ public:
|
|||||||
return configuration.isConsistent();
|
return configuration.isConsistent();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void printUnsatisfiedModsError() const {
|
inline std::string getUnsatisfiedModsError() const {
|
||||||
return configuration.printUnsatisfiedModsError();
|
return configuration.getUnsatisfiedModsError();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user