1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Make sure mod paths are always absolute

This commit is contained in:
sfan5 2025-01-09 13:15:36 +01:00
parent d0d7c11fe1
commit 903d13ffff
3 changed files with 8 additions and 4 deletions

View file

@ -47,7 +47,7 @@ void ModConfiguration::addMods(const std::vector<ModSpec> &new_mods)
} }
// Add new mods // Add new mods
for (int want_from_modpack = 1; want_from_modpack >= 0; --want_from_modpack) { for (bool want_from_modpack : {true, false}) {
// First iteration: // First iteration:
// Add all the mods that come from modpacks // Add all the mods that come from modpacks
// Second iteration: // Second iteration:
@ -56,9 +56,12 @@ void ModConfiguration::addMods(const std::vector<ModSpec> &new_mods)
std::set<std::string> seen_this_iteration; std::set<std::string> seen_this_iteration;
for (const ModSpec &mod : new_mods) { for (const ModSpec &mod : new_mods) {
if (mod.part_of_modpack != (bool)want_from_modpack) if (mod.part_of_modpack != want_from_modpack)
continue; continue;
// unrelated to this code, but we want to assert it somewhere
assert(fs::IsPathAbsolute(mod.path));
if (existing_mods.count(mod.name) == 0) { if (existing_mods.count(mod.name) == 0) {
// GOOD CASE: completely new mod. // GOOD CASE: completely new mod.
m_unsatisfied_mods.push_back(mod); m_unsatisfied_mods.push_back(mod);

View file

@ -167,6 +167,7 @@ std::map<std::string, ModSpec> getModsInPath(
mod_path.clear(); mod_path.clear();
mod_path.append(path).append(DIR_DELIM).append(modname); mod_path.append(path).append(DIR_DELIM).append(modname);
mod_path = fs::AbsolutePath(mod_path);
mod_virtual_path.clear(); mod_virtual_path.clear();
// Intentionally uses / to keep paths same on different platforms // Intentionally uses / to keep paths same on different platforms
@ -174,7 +175,7 @@ std::map<std::string, ModSpec> getModsInPath(
ModSpec spec(modname, mod_path, part_of_modpack, mod_virtual_path); ModSpec spec(modname, mod_path, part_of_modpack, mod_virtual_path);
parseModContents(spec); parseModContents(spec);
result.insert(std::make_pair(modname, spec)); result[modname] = std::move(spec);
} }
return result; return result;
} }

View file

@ -25,7 +25,7 @@ struct ModSpec
{ {
std::string name; std::string name;
std::string author; std::string author;
std::string path; std::string path; // absolute path on disk
std::string desc; std::string desc;
int release = 0; int release = 0;