@@ -154,7 +154,7 @@ impl WritableLoadOrder for AsteriskBasedLoadOrder {
154154 continue ;
155155 }
156156
157- if is_blueprint_ships_plugin ( plugin. name ( ) ) || plugin. is_blueprint_plugin ( ) {
157+ if starts_with_blueprint_ships ( plugin. name ( ) ) || plugin. is_blueprint_plugin ( ) {
158158 // Skip these since they get removed from plugins.txt by the
159159 // game. This means that the load order being saved might not be
160160 // respected by the game when it loads, if the affected plugins
@@ -265,7 +265,7 @@ impl WritableLoadOrder for AsteriskBasedLoadOrder {
265265 !( self . game_settings . is_implicitly_active ( plugin. name ( ) )
266266 || plugin. is_blueprint_plugin ( )
267267 || ( self . game_settings . supports_blueprint_ships_plugins ( )
268- && is_blueprint_ships_plugin ( plugin. name ( ) ) ) )
268+ && starts_with_blueprint_ships ( plugin. name ( ) ) ) )
269269 } )
270270 . all ( |plugin| set. contains ( & UniCase :: new ( plugin. name ( ) . to_owned ( ) ) ) ) ;
271271
@@ -285,8 +285,16 @@ impl WritableLoadOrder for AsteriskBasedLoadOrder {
285285 }
286286}
287287
288- fn is_blueprint_ships_plugin ( plugin_name : & str ) -> bool {
289- blueprint_ships_base_plugin_name ( plugin_name) . is_some ( )
288+ fn starts_with_blueprint_ships ( plugin_name : & str ) -> bool {
289+ // Plugins that start with BlueprintShips- (case-insensitively compared) are
290+ // removed from plugins.txt, even if they don't have the .esm file
291+ // extension.
292+ const BLUEPRINT_SHIPS_PREFIX : & str = "BlueprintShips-" ;
293+
294+ plugin_name
295+ . get ( ..BLUEPRINT_SHIPS_PREFIX . len ( ) )
296+ . filter ( |prefix| BLUEPRINT_SHIPS_PREFIX . eq_ignore_ascii_case ( prefix) )
297+ . is_some ( )
290298}
291299
292300fn plugin_line_mapper ( line : & str ) -> Option < ( & str , bool ) > {
@@ -1101,6 +1109,31 @@ mod tests {
11011109 assert_eq ! ( "*Blank.esp\n " , contents) ;
11021110 }
11031111
1112+ #[ test]
1113+ fn save_should_not_write_plugins_that_start_with_blueprint_ships_to_plugins_txt ( ) {
1114+ let tmp_dir = tempdir ( ) . unwrap ( ) ;
1115+
1116+ let mut load_order = prepare ( GameId :: Starfield , tmp_dir. path ( ) ) ;
1117+
1118+ let plugin_name1 = "BlueprintShips-A.esp" ;
1119+ let plugin_name2 = "BlueprintShips-B.esp" ;
1120+ copy_to_test_dir ( "Blank.full.esm" , plugin_name1, & load_order. game_settings ) ;
1121+ copy_to_test_dir ( "Blank.full.esm" , plugin_name2, & load_order. game_settings ) ;
1122+ load_order. add ( plugin_name1) . unwrap ( ) ;
1123+ load_order
1124+ . find_plugin_mut ( plugin_name1)
1125+ . unwrap ( )
1126+ . activate ( )
1127+ . unwrap ( ) ;
1128+ load_order. add ( plugin_name2) . unwrap ( ) ;
1129+
1130+ load_order. save ( ) . unwrap ( ) ;
1131+
1132+ let contents =
1133+ std:: fs:: read_to_string ( load_order. game_settings . active_plugins_file ( ) ) . unwrap ( ) ;
1134+ assert_eq ! ( "*Blank.esp\n " , contents) ;
1135+ }
1136+
11041137 #[ test]
11051138 fn save_should_update_blueprint_master_timestamps_to_reflect_load_order ( ) {
11061139 let tmp_dir = tempdir ( ) . unwrap ( ) ;
0 commit comments