Fix load order verification
All checks were successful
lint/clippy Checking for common mistakes and opportunities for code improvement
build/msvc Build for the target platform: msvc
build/linux Build for the target platform: linux

With `.enumerate()` after `.filter()`, the resulting indices didn't
properly map back to the overall mod list anymore. But the checks
afterwards relied on that.
Moving the `.enumerate()` before the `.filter()` makes sure that the
indices are correct.
This commit is contained in:
Lucas Schwiderski 2024-07-10 21:54:51 +02:00
parent 91651a8467
commit e6f1e7c117
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8

View file

@ -162,18 +162,20 @@ where
pub(crate) fn check_mod_order(state: &ActionState) -> Result<()> {
if tracing::enabled!(tracing::Level::DEBUG) {
let order = state.mods.iter().filter(|i| i.enabled).enumerate().fold(
String::new(),
|mut s, (i, info)| {
let order = state
.mods
.iter()
.enumerate()
.filter(|(_, i)| i.enabled)
.fold(String::new(), |mut s, (i, info)| {
s.push_str(&format!("{}: {} - {}\n", i, info.id, info.name));
s
},
);
});
tracing::debug!("Mod order:\n{}", order);
}
for (i, mod_info) in state.mods.iter().filter(|i| i.enabled).enumerate() {
for (i, mod_info) in state.mods.iter().enumerate().filter(|(_, i)| i.enabled) {
for dep in &mod_info.depends {
let dep_info = state.mods.iter().enumerate().find(|(_, m)| m.id == dep.id);