Skip to content

Commit

Permalink
Make sure mod paths are always absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Jan 12, 2025
1 parent d0d7c11 commit 903d13f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/content/mod_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void ModConfiguration::addMods(const std::vector<ModSpec> &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:
// Add all the mods that come from modpacks
// Second iteration:
Expand All @@ -56,9 +56,12 @@ void ModConfiguration::addMods(const std::vector<ModSpec> &new_mods)
std::set<std::string> seen_this_iteration;

for (const ModSpec &mod : new_mods) {
if (mod.part_of_modpack != (bool)want_from_modpack)
if (mod.part_of_modpack != want_from_modpack)
continue;

// unrelated to this code, but we want to assert it somewhere
assert(fs::IsPathAbsolute(mod.path));

if (existing_mods.count(mod.name) == 0) {
// GOOD CASE: completely new mod.
m_unsatisfied_mods.push_back(mod);
Expand Down
3 changes: 2 additions & 1 deletion src/content/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,15 @@ std::map<std::string, ModSpec> getModsInPath(

mod_path.clear();
mod_path.append(path).append(DIR_DELIM).append(modname);
mod_path = fs::AbsolutePath(mod_path);

mod_virtual_path.clear();
// Intentionally uses / to keep paths same on different platforms
mod_virtual_path.append(virtual_path).append("/").append(modname);

ModSpec spec(modname, mod_path, part_of_modpack, mod_virtual_path);
parseModContents(spec);
result.insert(std::make_pair(modname, spec));
result[modname] = std::move(spec);
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/content/mods.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct ModSpec
{
std::string name;
std::string author;
std::string path;
std::string path; // absolute path on disk
std::string desc;
int release = 0;

Expand Down

0 comments on commit 903d13f

Please sign in to comment.