Skip to content

Commit 23a4fe8

Browse files
committed
[WIP] Preserve implicitly active state when saving load order
Don't record implicitly active plugins as explicitly active when saving the load order. WIP because there's a failing test, and I'm not sure this is a beneficial change overall.
1 parent 27aa19a commit 23a4fe8

5 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/load_order/asterisk_based.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl WritableLoadOrder for AsteriskBasedLoadOrder {
154154
continue;
155155
}
156156

157-
if plugin.is_active() {
157+
if plugin.is_explicitly_active() {
158158
write!(writer, "*").map_err(|e| Error::IoError(path.clone(), e))?;
159159
}
160160
writer

src/load_order/openmw.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,11 @@ impl WritableLoadOrder for OpenMWLoadOrder {
261261
.collect();
262262

263263
let cfg_path = self.game_settings.active_plugins_file();
264-
write_openmw_cfg(cfg_path, &data_paths, &self.active_plugin_names())?;
264+
write_openmw_cfg(
265+
cfg_path,
266+
&data_paths,
267+
&self.explicitly_active_plugin_names(),
268+
)?;
265269

266270
Ok(())
267271
}

src/load_order/readable.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ pub trait ReadableLoadOrderBase {
3434
.enumerate()
3535
.find(|(_, p)| p.name_matches(plugin_name))
3636
}
37+
38+
fn explicitly_active_plugin_names(&self) -> Vec<&str> {
39+
self.plugins()
40+
.iter()
41+
.filter(|p| p.is_explicitly_active())
42+
.map(Plugin::name)
43+
.collect()
44+
}
3745
}
3846

3947
pub trait ReadableLoadOrder {

src/load_order/textfile_based.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl TextfileBasedLoadOrder {
8686
let file = File::create(path).map_err(|e| Error::IoError(path.clone(), e))?;
8787
let mut writer = BufWriter::new(file);
8888

89-
for plugin_name in self.active_plugin_names() {
89+
for plugin_name in self.explicitly_active_plugin_names() {
9090
writer
9191
.write_all(&strict_encode(plugin_name)?)
9292
.map_err(|e| Error::IoError(path.clone(), e))?;

src/load_order/timestamp_based.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl TimestampBasedLoadOrder {
8888
.write_all(&prelude)
8989
.map_err(|e| Error::IoError(path.clone(), e))?;
9090

91-
for (index, plugin_name) in self.active_plugin_names().iter().enumerate() {
91+
for (index, plugin_name) in self.explicitly_active_plugin_names().iter().enumerate() {
9292
if self.game_settings().id() == GameId::Morrowind {
9393
write!(writer, "GameFile{index}=").map_err(|e| Error::IoError(path.clone(), e))?;
9494
}

0 commit comments

Comments
 (0)