From aa5344ca925430190d9f68542e69054ac5912f58 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Wed, 23 Apr 2025 18:02:17 +0100 Subject: [PATCH] Replace names used for game types Use the game names rather than their acronyms (aside from suffixes, which are widely used). This also changes the CXX wrapper to use PascalCase for the game types it exposes for consistency. The outer C++ wrapper is unchanged. --- cxx/src/api/game.cpp | 44 +++--- cxx/src/game.rs | 44 +++--- cxx/src/lib.rs | 22 +-- cxx/src/tests/api/internals/main.cpp | 2 +- nodejs/src/game.rs | 36 ++--- pyo3/src/game.rs | 36 ++--- src/archive/find.rs | 31 +++-- src/database/conditions.rs | 4 +- src/database/mod.rs | 82 ++++++------ src/game.rs | 192 +++++++++++++-------------- src/plugin/mod.rs | 52 ++++---- src/tests.rs | 52 ++++---- 12 files changed, 305 insertions(+), 292 deletions(-) diff --git a/cxx/src/api/game.cpp b/cxx/src/api/game.cpp index e8d17c4e..50192171 100644 --- a/cxx/src/api/game.cpp +++ b/cxx/src/api/game.cpp @@ -7,27 +7,27 @@ namespace { loot::GameType convert(loot::rust::GameType gameType) { switch (gameType) { - case loot::rust::GameType::tes3: + case loot::rust::GameType::Morrowind: return loot::GameType::tes3; - case loot::rust::GameType::tes4: + case loot::rust::GameType::Oblivion: return loot::GameType::tes4; - case loot::rust::GameType::tes5: + case loot::rust::GameType::Skyrim: return loot::GameType::tes5; - case loot::rust::GameType::tes5se: + case loot::rust::GameType::SkyrimSE: return loot::GameType::tes5se; - case loot::rust::GameType::tes5vr: + case loot::rust::GameType::SkyrimVR: return loot::GameType::tes5vr; - case loot::rust::GameType::fo3: + case loot::rust::GameType::Fallout3: return loot::GameType::fo3; - case loot::rust::GameType::fonv: + case loot::rust::GameType::FalloutNV: return loot::GameType::fonv; - case loot::rust::GameType::fo4: + case loot::rust::GameType::Fallout4: return loot::GameType::fo4; - case loot::rust::GameType::fo4vr: + case loot::rust::GameType::Fallout4VR: return loot::GameType::fo4vr; - case loot::rust::GameType::starfield: + case loot::rust::GameType::Starfield: return loot::GameType::starfield; - case loot::rust::GameType::openmw: + case loot::rust::GameType::OpenMW: return loot::GameType::openmw; default: throw std::logic_error("Unsupported GameType value"); @@ -37,27 +37,27 @@ loot::GameType convert(loot::rust::GameType gameType) { loot::rust::GameType convert(loot::GameType gameType) { switch (gameType) { case loot::GameType::tes3: - return loot::rust::GameType::tes3; + return loot::rust::GameType::Morrowind; case loot::GameType::tes4: - return loot::rust::GameType::tes4; + return loot::rust::GameType::Oblivion; case loot::GameType::tes5: - return loot::rust::GameType::tes5; + return loot::rust::GameType::Skyrim; case loot::GameType::tes5se: - return loot::rust::GameType::tes5se; + return loot::rust::GameType::SkyrimSE; case loot::GameType::tes5vr: - return loot::rust::GameType::tes5vr; + return loot::rust::GameType::SkyrimVR; case loot::GameType::fo3: - return loot::rust::GameType::fo3; + return loot::rust::GameType::Fallout3; case loot::GameType::fonv: - return loot::rust::GameType::fonv; + return loot::rust::GameType::FalloutNV; case loot::GameType::fo4: - return loot::rust::GameType::fo4; + return loot::rust::GameType::Fallout4; case loot::GameType::fo4vr: - return loot::rust::GameType::fo4vr; + return loot::rust::GameType::Fallout4VR; case loot::GameType::starfield: - return loot::rust::GameType::starfield; + return loot::rust::GameType::Starfield; case loot::GameType::openmw: - return loot::rust::GameType::openmw; + return loot::rust::GameType::OpenMW; default: throw std::logic_error("Unsupported GameType value"); } diff --git a/cxx/src/game.rs b/cxx/src/game.rs index bf216edf..14261275 100644 --- a/cxx/src/game.rs +++ b/cxx/src/game.rs @@ -10,17 +10,17 @@ impl TryFrom for GameType { fn try_from(value: libloot::GameType) -> Result { match value { - libloot::GameType::TES4 => Ok(GameType::tes4), - libloot::GameType::TES5 => Ok(GameType::tes5), - libloot::GameType::FO3 => Ok(GameType::fo3), - libloot::GameType::FONV => Ok(GameType::fonv), - libloot::GameType::FO4 => Ok(GameType::fo4), - libloot::GameType::TES5SE => Ok(GameType::tes5se), - libloot::GameType::FO4VR => Ok(GameType::fo4vr), - libloot::GameType::TES5VR => Ok(GameType::tes5vr), - libloot::GameType::TES3 => Ok(GameType::tes3), - libloot::GameType::Starfield => Ok(GameType::starfield), - libloot::GameType::OpenMW => Ok(GameType::openmw), + libloot::GameType::Oblivion => Ok(GameType::Oblivion), + libloot::GameType::Skyrim => Ok(GameType::Skyrim), + libloot::GameType::Fallout3 => Ok(GameType::Fallout3), + libloot::GameType::FalloutNV => Ok(GameType::FalloutNV), + libloot::GameType::Fallout4 => Ok(GameType::Fallout4), + libloot::GameType::SkyrimSE => Ok(GameType::SkyrimSE), + libloot::GameType::Fallout4VR => Ok(GameType::Fallout4VR), + libloot::GameType::SkyrimVR => Ok(GameType::SkyrimVR), + libloot::GameType::Morrowind => Ok(GameType::Morrowind), + libloot::GameType::Starfield => Ok(GameType::Starfield), + libloot::GameType::OpenMW => Ok(GameType::OpenMW), _ => Err(UnsupportedEnumValueError), } } @@ -31,17 +31,17 @@ impl TryFrom for libloot::GameType { fn try_from(value: GameType) -> Result { match value { - GameType::tes4 => Ok(libloot::GameType::TES4), - GameType::tes5 => Ok(libloot::GameType::TES5), - GameType::fo3 => Ok(libloot::GameType::FO3), - GameType::fonv => Ok(libloot::GameType::FONV), - GameType::fo4 => Ok(libloot::GameType::FO4), - GameType::tes5se => Ok(libloot::GameType::TES5SE), - GameType::fo4vr => Ok(libloot::GameType::FO4VR), - GameType::tes5vr => Ok(libloot::GameType::TES5VR), - GameType::tes3 => Ok(libloot::GameType::TES3), - GameType::starfield => Ok(libloot::GameType::Starfield), - GameType::openmw => Ok(libloot::GameType::OpenMW), + GameType::Oblivion => Ok(libloot::GameType::Oblivion), + GameType::Skyrim => Ok(libloot::GameType::Skyrim), + GameType::Fallout3 => Ok(libloot::GameType::Fallout3), + GameType::FalloutNV => Ok(libloot::GameType::FalloutNV), + GameType::Fallout4 => Ok(libloot::GameType::Fallout4), + GameType::SkyrimSE => Ok(libloot::GameType::SkyrimSE), + GameType::Fallout4VR => Ok(libloot::GameType::Fallout4VR), + GameType::SkyrimVR => Ok(libloot::GameType::SkyrimVR), + GameType::Morrowind => Ok(libloot::GameType::Morrowind), + GameType::Starfield => Ok(libloot::GameType::Starfield), + GameType::OpenMW => Ok(libloot::GameType::OpenMW), _ => Err(UnsupportedEnumValueError), } } diff --git a/cxx/src/lib.rs b/cxx/src/lib.rs index c6d33867..27e64ba0 100644 --- a/cxx/src/lib.rs +++ b/cxx/src/lib.rs @@ -210,17 +210,17 @@ impl TryFrom for libloot::LogLevel { mod ffi { pub enum GameType { - tes4, - tes5, - fo3, - fonv, - fo4, - tes5se, - fo4vr, - tes5vr, - tes3, - starfield, - openmw, + Oblivion, + Skyrim, + Fallout3, + FalloutNV, + Fallout4, + SkyrimSE, + Fallout4VR, + SkyrimVR, + Morrowind, + Starfield, + OpenMW, } pub enum MessageType { diff --git a/cxx/src/tests/api/internals/main.cpp b/cxx/src/tests/api/internals/main.cpp index 9ecbe6a8..b7117d6b 100644 --- a/cxx/src/tests/api/internals/main.cpp +++ b/cxx/src/tests/api/internals/main.cpp @@ -39,7 +39,7 @@ TEST(libloot_revision, shouldReturnExpectedValue) { } TEST(new_game, shouldThrowIfGivenNonsense) { - EXPECT_THROW(new_game(GameType::fo3, "foo"), ::rust::Error); + EXPECT_THROW(new_game(GameType::Fallout3, "foo"), ::rust::Error); } TEST(Message, creation) { diff --git a/nodejs/src/game.rs b/nodejs/src/game.rs index 24e185dc..0932010f 100644 --- a/nodejs/src/game.rs +++ b/nodejs/src/game.rs @@ -26,15 +26,15 @@ impl TryFrom for GameType { fn try_from(value: libloot::GameType) -> Result { match value { - libloot::GameType::TES4 => Ok(GameType::Oblivion), - libloot::GameType::TES5 => Ok(GameType::Skyrim), - libloot::GameType::FO3 => Ok(GameType::Fallout3), - libloot::GameType::FONV => Ok(GameType::FalloutNV), - libloot::GameType::FO4 => Ok(GameType::Fallout4), - libloot::GameType::TES5SE => Ok(GameType::SkyrimSE), - libloot::GameType::FO4VR => Ok(GameType::Fallout4VR), - libloot::GameType::TES5VR => Ok(GameType::SkyrimVR), - libloot::GameType::TES3 => Ok(GameType::Morrowind), + libloot::GameType::Oblivion => Ok(GameType::Oblivion), + libloot::GameType::Skyrim => Ok(GameType::Skyrim), + libloot::GameType::Fallout3 => Ok(GameType::Fallout3), + libloot::GameType::FalloutNV => Ok(GameType::FalloutNV), + libloot::GameType::Fallout4 => Ok(GameType::Fallout4), + libloot::GameType::SkyrimSE => Ok(GameType::SkyrimSE), + libloot::GameType::Fallout4VR => Ok(GameType::Fallout4VR), + libloot::GameType::SkyrimVR => Ok(GameType::SkyrimVR), + libloot::GameType::Morrowind => Ok(GameType::Morrowind), libloot::GameType::Starfield => Ok(GameType::Starfield), libloot::GameType::OpenMW => Ok(GameType::OpenMW), _ => Err(UnsupportedEnumValueError), @@ -45,15 +45,15 @@ impl TryFrom for GameType { impl From for libloot::GameType { fn from(value: GameType) -> Self { match value { - GameType::Oblivion => libloot::GameType::TES4, - GameType::Skyrim => libloot::GameType::TES5, - GameType::Fallout3 => libloot::GameType::FO3, - GameType::FalloutNV => libloot::GameType::FONV, - GameType::Fallout4 => libloot::GameType::FO4, - GameType::SkyrimSE => libloot::GameType::TES5SE, - GameType::Fallout4VR => libloot::GameType::FO4VR, - GameType::SkyrimVR => libloot::GameType::TES5VR, - GameType::Morrowind => libloot::GameType::TES3, + GameType::Oblivion => libloot::GameType::Oblivion, + GameType::Skyrim => libloot::GameType::Skyrim, + GameType::Fallout3 => libloot::GameType::Fallout3, + GameType::FalloutNV => libloot::GameType::FalloutNV, + GameType::Fallout4 => libloot::GameType::Fallout4, + GameType::SkyrimSE => libloot::GameType::SkyrimSE, + GameType::Fallout4VR => libloot::GameType::Fallout4VR, + GameType::SkyrimVR => libloot::GameType::SkyrimVR, + GameType::Morrowind => libloot::GameType::Morrowind, GameType::Starfield => libloot::GameType::Starfield, GameType::OpenMW => libloot::GameType::OpenMW, } diff --git a/pyo3/src/game.rs b/pyo3/src/game.rs index 462e53fe..84b7699d 100644 --- a/pyo3/src/game.rs +++ b/pyo3/src/game.rs @@ -26,15 +26,15 @@ impl TryFrom for GameType { fn try_from(value: libloot::GameType) -> Result { match value { - libloot::GameType::TES4 => Ok(GameType::Oblivion), - libloot::GameType::TES5 => Ok(GameType::Skyrim), - libloot::GameType::FO3 => Ok(GameType::Fallout3), - libloot::GameType::FONV => Ok(GameType::FalloutNV), - libloot::GameType::FO4 => Ok(GameType::Fallout4), - libloot::GameType::TES5SE => Ok(GameType::SkyrimSE), - libloot::GameType::FO4VR => Ok(GameType::Fallout4VR), - libloot::GameType::TES5VR => Ok(GameType::SkyrimVR), - libloot::GameType::TES3 => Ok(GameType::Morrowind), + libloot::GameType::Oblivion => Ok(GameType::Oblivion), + libloot::GameType::Skyrim => Ok(GameType::Skyrim), + libloot::GameType::Fallout3 => Ok(GameType::Fallout3), + libloot::GameType::FalloutNV => Ok(GameType::FalloutNV), + libloot::GameType::Fallout4 => Ok(GameType::Fallout4), + libloot::GameType::SkyrimSE => Ok(GameType::SkyrimSE), + libloot::GameType::Fallout4VR => Ok(GameType::Fallout4VR), + libloot::GameType::SkyrimVR => Ok(GameType::SkyrimVR), + libloot::GameType::Morrowind => Ok(GameType::Morrowind), libloot::GameType::Starfield => Ok(GameType::Starfield), libloot::GameType::OpenMW => Ok(GameType::OpenMW), _ => Err(UnsupportedEnumValueError), @@ -47,15 +47,15 @@ impl TryFrom for libloot::GameType { fn try_from(value: GameType) -> Result { match value { - GameType::Oblivion => Ok(libloot::GameType::TES4), - GameType::Skyrim => Ok(libloot::GameType::TES5), - GameType::Fallout3 => Ok(libloot::GameType::FO3), - GameType::FalloutNV => Ok(libloot::GameType::FONV), - GameType::Fallout4 => Ok(libloot::GameType::FO4), - GameType::SkyrimSE => Ok(libloot::GameType::TES5SE), - GameType::Fallout4VR => Ok(libloot::GameType::FO4VR), - GameType::SkyrimVR => Ok(libloot::GameType::TES5VR), - GameType::Morrowind => Ok(libloot::GameType::TES3), + GameType::Oblivion => Ok(libloot::GameType::Oblivion), + GameType::Skyrim => Ok(libloot::GameType::Skyrim), + GameType::Fallout3 => Ok(libloot::GameType::Fallout3), + GameType::FalloutNV => Ok(libloot::GameType::FalloutNV), + GameType::Fallout4 => Ok(libloot::GameType::Fallout4), + GameType::SkyrimSE => Ok(libloot::GameType::SkyrimSE), + GameType::Fallout4VR => Ok(libloot::GameType::Fallout4VR), + GameType::SkyrimVR => Ok(libloot::GameType::SkyrimVR), + GameType::Morrowind => Ok(libloot::GameType::Morrowind), GameType::Starfield => Ok(libloot::GameType::Starfield), GameType::OpenMW => Ok(libloot::GameType::OpenMW), } diff --git a/src/archive/find.rs b/src/archive/find.rs index 03df9083..03c3497d 100644 --- a/src/archive/find.rs +++ b/src/archive/find.rs @@ -13,21 +13,21 @@ pub fn find_associated_archives( plugin_path: &Path, ) -> Vec { match game_type { - GameType::TES3 | GameType::OpenMW => Vec::new(), + GameType::Morrowind | GameType::OpenMW => Vec::new(), // Skyrim (non-SE) plugins can only load BSAs that have exactly the same // basename, ignoring file extensions. - GameType::TES5 => find_associated_archive(plugin_path), + GameType::Skyrim => find_associated_archive(plugin_path), // Skyrim SE can load BSAs that have exactly the same basename, ignoring // file extensions, and also BSAs with filenames of the form " // - Textures.bsa" (case-insensitively). This assumes that Skyrim VR // works the same way as Skyrim SE. - GameType::TES5SE | GameType::TES5VR => find_associated_archives_with_suffixes(plugin_path, BSA_FILE_EXTENSION, &["", " - Textures"]), + GameType::SkyrimSE | GameType::SkyrimVR => find_associated_archives_with_suffixes(plugin_path, BSA_FILE_EXTENSION, &["", " - Textures"]), // Oblivion .esp files can load archives which begin with the plugin // basename. - GameType::TES4 => { + GameType::Oblivion => { if has_ascii_extension(plugin_path, "esp") { find_associated_archives_with_arbitrary_suffixes(plugin_path, game_cache) } else { @@ -37,7 +37,7 @@ pub fn find_associated_archives( // FO3, FNV, FO4 plugins can load archives which begin with the plugin // basename. This assumes that FO4 VR works the same way as FO4. - GameType::FO3 | GameType::FONV | GameType::FO4 | GameType::FO4VR => + GameType::Fallout3 | GameType::FalloutNV | GameType::Fallout4 | GameType::Fallout4VR => find_associated_archives_with_arbitrary_suffixes(plugin_path, game_cache) , @@ -228,8 +228,8 @@ mod tests { let data_path = tmp_dir.path().to_path_buf(); match game_type { - GameType::TES3 | GameType::OpenMW => {} - GameType::FO4 | GameType::FO4VR | GameType::Starfield => { + GameType::Morrowind | GameType::OpenMW => {} + GameType::Fallout4 | GameType::Fallout4VR | GameType::Starfield => { let source = absolute("./testing-plugins/Fallout 4/Data").unwrap(); copy_file(&source, &data_path, "Blank - Main.ba2"); copy_file(&source, &data_path, "Blank - Textures.ba2"); @@ -308,7 +308,7 @@ mod tests { if matches!( game_type, - GameType::TES3 | GameType::OpenMW | GameType::TES4 + GameType::Morrowind | GameType::OpenMW | GameType::Oblivion ) { assert!(archives.is_empty()); } else { @@ -330,7 +330,7 @@ mod tests { if matches!( game_type, - GameType::TES3 | GameType::OpenMW | GameType::Starfield + GameType::Morrowind | GameType::OpenMW | GameType::Starfield ) { assert!(archives.is_empty()); } else { @@ -350,7 +350,7 @@ mod tests { &fixture.data_path.join(BLANK_ESP), ); - if matches!(game_type, GameType::TES3 | GameType::OpenMW) { + if matches!(game_type, GameType::Morrowind | GameType::OpenMW) { assert!(archives.is_empty()); } else { assert!(!archives.is_empty()); @@ -371,7 +371,10 @@ mod tests { if matches!( game_type, - GameType::FO3 | GameType::FONV | GameType::FO4 | GameType::FO4VR + GameType::Fallout3 + | GameType::FalloutNV + | GameType::Fallout4 + | GameType::Fallout4VR ) { assert!(!archives.is_empty()); } else { @@ -393,7 +396,11 @@ mod tests { if matches!( game_type, - GameType::TES4 | GameType::FO3 | GameType::FONV | GameType::FO4 | GameType::FO4VR + GameType::Oblivion + | GameType::Fallout3 + | GameType::FalloutNV + | GameType::Fallout4 + | GameType::Fallout4VR ) { assert!(!archives.is_empty()); } else { diff --git a/src/database/conditions.rs b/src/database/conditions.rs index ad43b79d..0c86d7df 100644 --- a/src/database/conditions.rs +++ b/src/database/conditions.rs @@ -157,7 +157,7 @@ mod tests { let state = loot_condition_interpreter::State::new( loot_condition_interpreter::GameType::Oblivion, - source_plugins_path(crate::GameType::TES4), + source_plugins_path(crate::GameType::Oblivion), ); let result = evaluate_all_conditions(plugin, &state).unwrap().unwrap(); @@ -183,7 +183,7 @@ mod tests { let state = loot_condition_interpreter::State::new( loot_condition_interpreter::GameType::Oblivion, - source_plugins_path(crate::GameType::TES4), + source_plugins_path(crate::GameType::Oblivion), ); assert!(evaluate_all_conditions(plugin, &state).unwrap().is_none()); } diff --git a/src/database/mod.rs b/src/database/mod.rs index ca2a6135..f132fa02 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -456,7 +456,7 @@ plugins: #[test] fn load_masterlist_should_succeed_if_given_a_valid_path() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -466,7 +466,7 @@ plugins: #[test] fn load_masterlist_with_prelude_should_succeed_if_given_valid_paths() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database @@ -478,7 +478,7 @@ plugins: #[test] fn load_userlist_should_succeed_if_given_a_valid_path() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_userlist(&fixture.metadata_path).unwrap(); @@ -499,7 +499,7 @@ plugins: #[test] fn should_write_only_user_metadata() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -518,7 +518,7 @@ plugins: #[test] fn should_succeed_if_the_path_does_not_exist() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); let output_path = fixture.inner.local_path.join("userlist.yaml"); @@ -531,7 +531,7 @@ plugins: #[test] fn should_succeed_if_the_path_does_not_exist_and_truncation_is_allowed() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); let output_path = fixture.inner.local_path.join("userlist.yaml"); @@ -544,7 +544,7 @@ plugins: #[test] fn should_succeed_if_the_path_exists_and_truncation_is_allowed() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); let output_path = fixture.inner.local_path.join("userlist.yaml"); @@ -559,7 +559,7 @@ plugins: #[test] fn should_error_if_the_parent_path_does_not_exist() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); let output_path = fixture.inner.local_path.join("missing/userlist.yaml"); @@ -572,7 +572,7 @@ plugins: #[test] fn should_error_if_the_path_is_read_only() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); let output_path = fixture.inner.local_path.join("userlist.yaml"); @@ -591,7 +591,7 @@ plugins: #[test] fn should_error_if_the_path_exists_and_truncation_is_not_allowed() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); let output_path = fixture.inner.local_path.join("userlist.yaml"); @@ -610,7 +610,7 @@ plugins: #[test] fn should_only_write_plugin_bash_tags_and_dirty_info() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); let output_path = fixture.inner.local_path.join("minimal.yaml"); @@ -656,7 +656,7 @@ plugins: #[test] fn should_succeed_if_the_path_does_not_exist() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); let output_path = fixture.inner.local_path.join("minimal.yaml"); @@ -669,7 +669,7 @@ plugins: #[test] fn should_succeed_if_the_path_does_not_exist_and_truncation_is_allowed() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); let output_path = fixture.inner.local_path.join("minimal.yaml"); @@ -682,7 +682,7 @@ plugins: #[test] fn should_succeed_if_the_path_exists_and_truncation_is_allowed() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); let output_path = fixture.inner.local_path.join("minimal.yaml"); @@ -697,7 +697,7 @@ plugins: #[test] fn should_error_if_the_parent_path_does_not_exist() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); let output_path = fixture.inner.local_path.join("missing/minimal.yaml"); @@ -710,7 +710,7 @@ plugins: #[test] fn should_error_if_the_path_is_read_only() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); let output_path = fixture.inner.local_path.join("minimal.yaml"); @@ -729,7 +729,7 @@ plugins: #[test] fn should_error_if_the_path_exists_and_truncation_is_not_allowed() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); let output_path = fixture.inner.local_path.join("minimal.yaml"); @@ -745,7 +745,7 @@ plugins: #[test] fn known_bash_tags_should_append_userlist_tags_to_masterlist_tags() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -766,7 +766,7 @@ plugins: #[test] fn should_append_userlist_messages_to_masterlist_messages() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -792,7 +792,7 @@ plugins: #[test] fn should_filter_out_messages_with_false_conditions_when_evaluating_conditions() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -818,7 +818,7 @@ plugins: #[test] fn should_return_true_if_the_condition_is_true() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); assert!(database.evaluate("file(\"Blank.esp\")").unwrap()); @@ -826,7 +826,7 @@ plugins: #[test] fn should_return_false_if_the_condition_is_false() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); assert!(!database.evaluate("file(\"missing.esp\")").unwrap()); @@ -838,7 +838,7 @@ plugins: #[test] fn should_return_default_group_before_metadata_has_been_loaded() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); assert_eq!(&[Group::default(),], database.groups(true).as_slice()); @@ -846,7 +846,7 @@ plugins: #[test] fn should_not_include_user_groups_if_param_is_false() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -872,7 +872,7 @@ plugins: #[test] fn should_merge_masterlist_and_userlist_groups() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -901,7 +901,7 @@ plugins: #[test] fn user_groups_should_not_include_masterlist_groups() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -911,7 +911,7 @@ plugins: #[test] fn set_user_groups_should_replace_existing_user_groups() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -944,7 +944,7 @@ plugins: #[test] fn groups_path_should_find_path_using_masterlist_and_user_metadata() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -970,7 +970,7 @@ plugins: #[test] fn should_return_none_if_plugin_has_no_metadata_set() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); assert!( @@ -983,7 +983,7 @@ plugins: #[test] fn should_return_none_if_plugin_metadata_has_only_name() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.set_plugin_user_metadata(PluginMetadata::new(BLANK_ESM).unwrap()); @@ -998,7 +998,7 @@ plugins: #[test] fn should_prefer_user_metadata_when_merging_metadata() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -1023,7 +1023,7 @@ plugins: #[test] fn should_return_only_masterlist_metadata_if_include_user_metadata_is_false() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -1045,7 +1045,7 @@ plugins: #[test] fn should_filter_out_metadata_with_false_conditions_when_evaluating_conditions() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -1074,7 +1074,7 @@ plugins: #[test] fn should_return_none_if_plugin_has_no_user_metadata_set() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let database = fixture.database(); assert!( @@ -1087,7 +1087,7 @@ plugins: #[test] fn should_return_none_if_plugin_user_metadata_has_only_name() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.set_plugin_user_metadata(PluginMetadata::new(BLANK_ESM).unwrap()); @@ -1102,7 +1102,7 @@ plugins: #[test] fn should_return_only_user_metadata() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -1124,7 +1124,7 @@ plugins: #[test] fn should_filter_out_metadata_with_false_conditions_when_evaluating_conditions() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -1151,7 +1151,7 @@ plugins: #[test] fn should_replace_existing_user_metadata_for_the_plugin() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -1177,7 +1177,7 @@ plugins: #[test] fn should_not_modify_masterlist_metadata_for_the_plugin() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -1203,7 +1203,7 @@ plugins: #[test] fn discard_plugin_user_metadata_should_discard_only_user_metadata_for_only_the_given_plugin() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); @@ -1242,7 +1242,7 @@ plugins: #[test] fn discard_all_user_metadata_should_not_remove_masterlist_metadata() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut database = fixture.database(); database.load_masterlist(&fixture.metadata_path).unwrap(); diff --git a/src/game.rs b/src/game.rs index 297d62b2..63ed2d04 100644 --- a/src/game.rs +++ b/src/game.rs @@ -36,23 +36,23 @@ use crate::{ #[non_exhaustive] pub enum GameType { /// The Elder Scrolls IV: Oblivion - TES4, + Oblivion, /// The Elder Scrolls V: Skyrim - TES5, + Skyrim, /// Fallout 3 - FO3, + Fallout3, /// Fallout: New Vegas - FONV, + FalloutNV, /// Fallout 4 - FO4, + Fallout4, /// The Elder Scrolls V: Skyrim Special Edition - TES5SE, + SkyrimSE, /// Fallout 4 VR - FO4VR, + Fallout4VR, /// Skyrim VR - TES5VR, + SkyrimVR, /// The Elder Scrolls III: Morrowind - TES3, + Morrowind, /// Starfield Starfield, /// OpenMW @@ -62,15 +62,15 @@ pub enum GameType { impl Display for GameType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - GameType::TES4 => write!(f, "The Elder Scrolls IV: Oblivion"), - GameType::TES5 => write!(f, "The Elder Scrolls V: Skyrim"), - GameType::FO3 => write!(f, "Fallout 3"), - GameType::FONV => write!(f, "Fallout: New Vegas"), - GameType::FO4 => write!(f, "Fallout 4"), - GameType::TES5SE => write!(f, "The Elder Scrolls V: Skyrim Special Edition"), - GameType::FO4VR => write!(f, "Fallout 4 VR"), - GameType::TES5VR => write!(f, "The Elder Scrolls V: Skyrim VR"), - GameType::TES3 => write!(f, "The Elder Scrolls III: Morrowind"), + GameType::Oblivion => write!(f, "The Elder Scrolls IV: Oblivion"), + GameType::Skyrim => write!(f, "The Elder Scrolls V: Skyrim"), + GameType::Fallout3 => write!(f, "Fallout 3"), + GameType::FalloutNV => write!(f, "Fallout: New Vegas"), + GameType::Fallout4 => write!(f, "Fallout 4"), + GameType::SkyrimSE => write!(f, "The Elder Scrolls V: Skyrim Special Edition"), + GameType::Fallout4VR => write!(f, "Fallout 4 VR"), + GameType::SkyrimVR => write!(f, "The Elder Scrolls V: Skyrim VR"), + GameType::Morrowind => write!(f, "The Elder Scrolls III: Morrowind"), GameType::Starfield => write!(f, "Starfield"), GameType::OpenMW => write!(f, "OpenMW"), } @@ -80,15 +80,15 @@ impl Display for GameType { impl From for loadorder::GameId { fn from(value: GameType) -> Self { match value { - GameType::TES4 => loadorder::GameId::Oblivion, - GameType::TES5 => loadorder::GameId::Skyrim, - GameType::FO3 => loadorder::GameId::Fallout3, - GameType::FONV => loadorder::GameId::FalloutNV, - GameType::FO4 => loadorder::GameId::Fallout4, - GameType::TES5SE => loadorder::GameId::SkyrimSE, - GameType::FO4VR => loadorder::GameId::Fallout4VR, - GameType::TES5VR => loadorder::GameId::SkyrimVR, - GameType::TES3 => loadorder::GameId::Morrowind, + GameType::Oblivion => loadorder::GameId::Oblivion, + GameType::Skyrim => loadorder::GameId::Skyrim, + GameType::Fallout3 => loadorder::GameId::Fallout3, + GameType::FalloutNV => loadorder::GameId::FalloutNV, + GameType::Fallout4 => loadorder::GameId::Fallout4, + GameType::SkyrimSE => loadorder::GameId::SkyrimSE, + GameType::Fallout4VR => loadorder::GameId::Fallout4VR, + GameType::SkyrimVR => loadorder::GameId::SkyrimVR, + GameType::Morrowind => loadorder::GameId::Morrowind, GameType::Starfield => loadorder::GameId::Starfield, GameType::OpenMW => loadorder::GameId::OpenMW, } @@ -98,15 +98,15 @@ impl From for loadorder::GameId { impl From for loot_condition_interpreter::GameType { fn from(value: GameType) -> Self { match value { - GameType::TES4 => loot_condition_interpreter::GameType::Oblivion, - GameType::TES5 => loot_condition_interpreter::GameType::Skyrim, - GameType::FO3 => loot_condition_interpreter::GameType::Fallout3, - GameType::FONV => loot_condition_interpreter::GameType::FalloutNV, - GameType::FO4 => loot_condition_interpreter::GameType::Fallout4, - GameType::TES5SE => loot_condition_interpreter::GameType::SkyrimSE, - GameType::FO4VR => loot_condition_interpreter::GameType::Fallout4VR, - GameType::TES5VR => loot_condition_interpreter::GameType::SkyrimVR, - GameType::TES3 => loot_condition_interpreter::GameType::Morrowind, + GameType::Oblivion => loot_condition_interpreter::GameType::Oblivion, + GameType::Skyrim => loot_condition_interpreter::GameType::Skyrim, + GameType::Fallout3 => loot_condition_interpreter::GameType::Fallout3, + GameType::FalloutNV => loot_condition_interpreter::GameType::FalloutNV, + GameType::Fallout4 => loot_condition_interpreter::GameType::Fallout4, + GameType::SkyrimSE => loot_condition_interpreter::GameType::SkyrimSE, + GameType::Fallout4VR => loot_condition_interpreter::GameType::Fallout4VR, + GameType::SkyrimVR => loot_condition_interpreter::GameType::SkyrimVR, + GameType::Morrowind => loot_condition_interpreter::GameType::Morrowind, GameType::Starfield => loot_condition_interpreter::GameType::Starfield, GameType::OpenMW => loot_condition_interpreter::GameType::OpenMW, } @@ -116,13 +116,13 @@ impl From for loot_condition_interpreter::GameType { impl From for esplugin::GameId { fn from(value: GameType) -> Self { match value { - GameType::TES4 => esplugin::GameId::Oblivion, - GameType::TES5 => esplugin::GameId::Skyrim, - GameType::FO3 => esplugin::GameId::Fallout3, - GameType::FONV => esplugin::GameId::FalloutNV, - GameType::FO4 | GameType::FO4VR => esplugin::GameId::Fallout4, - GameType::TES5SE | GameType::TES5VR => esplugin::GameId::SkyrimSE, - GameType::TES3 | GameType::OpenMW => esplugin::GameId::Morrowind, + GameType::Oblivion => esplugin::GameId::Oblivion, + GameType::Skyrim => esplugin::GameId::Skyrim, + GameType::Fallout3 => esplugin::GameId::Fallout3, + GameType::FalloutNV => esplugin::GameId::FalloutNV, + GameType::Fallout4 | GameType::Fallout4VR => esplugin::GameId::Fallout4, + GameType::SkyrimSE | GameType::SkyrimVR => esplugin::GameId::SkyrimSE, + GameType::Morrowind | GameType::OpenMW => esplugin::GameId::Morrowind, GameType::Starfield => esplugin::GameId::Starfield, } } @@ -329,7 +329,7 @@ impl Game { if matches!( self.game_type, - GameType::TES3 | GameType::OpenMW | GameType::Starfield + GameType::Morrowind | GameType::OpenMW | GameType::Starfield ) { let mut loaded_plugins: HashMap = self .cache @@ -552,7 +552,7 @@ fn resolve_path(path: &Path) -> PathBuf { fn data_path(game_type: GameType, game_path: &Path) -> PathBuf { match game_type { - GameType::TES3 => game_path.join("Data Files"), + GameType::Morrowind => game_path.join("Data Files"), GameType::OpenMW => game_path.join("resources/vfs"), _ => game_path.join("Data"), } @@ -632,7 +632,7 @@ fn find_archives( fn archive_file_extension(game_type: GameType) -> &'static str { match game_type { - GameType::FO4 | GameType::FO4VR | GameType::Starfield => ".ba2", + GameType::Fallout4 | GameType::Fallout4VR | GameType::Starfield => ".ba2", _ => ".bsa", } } @@ -915,7 +915,7 @@ mod tests { fn should_succeed_for_morrowind_if_given_valid_game_path(game_type: GameType) { let fixture = Fixture::new(game_type); - if matches!(game_type, GameType::TES3 | GameType::OpenMW) { + if matches!(game_type, GameType::Morrowind | GameType::OpenMW) { assert!(Game::new(fixture.game_type, &fixture.game_path).is_ok()); } else { assert!(Game::new(fixture.game_type, &fixture.game_path).is_err()); @@ -924,7 +924,7 @@ mod tests { #[test] fn should_succeed_if_given_a_relative_game_path() { - let fixture = Fixture::in_path(GameType::TES3, Path::new("target")); + let fixture = Fixture::in_path(GameType::Morrowind, Path::new("target")); let game_path = make_relative(&fixture.game_path); assert!(game_path.is_relative()); @@ -934,7 +934,7 @@ mod tests { #[test] fn should_succeed_if_given_an_absolute_game_path() { - let fixture = Fixture::new(GameType::TES3); + let fixture = Fixture::new(GameType::Morrowind); assert!(fixture.game_path.is_absolute()); assert!(Game::new(fixture.game_type, &fixture.game_path).is_ok()); @@ -942,7 +942,7 @@ mod tests { #[test] fn should_succeed_if_given_a_symlink_path() { - let fixture = Fixture::new(GameType::TES3); + let fixture = Fixture::new(GameType::Morrowind); let game_path = fixture.game_path.with_extension("symlink"); symlink_dir(&fixture.game_path, &game_path); @@ -954,7 +954,7 @@ mod tests { #[cfg(windows)] #[test] fn should_succeed_if_given_a_junction_link_path() { - let fixture = Fixture::new(GameType::TES3); + let fixture = Fixture::new(GameType::Morrowind); let game_path = fixture.game_path.with_extension("junction"); junction_link(&fixture.game_path, &game_path); @@ -965,7 +965,7 @@ mod tests { #[test] fn should_error_if_given_a_game_path_that_does_not_exist() { let game_path = Path::new("missing"); - match Game::new(GameType::TES3, game_path) { + match Game::new(GameType::Morrowind, game_path) { Err(GameHandleCreationError::NotADirectory(p)) => assert_eq!(game_path, p), _ => panic!("Expected a not-a-directory error"), } @@ -990,7 +990,7 @@ mod tests { #[test] fn should_succeed_if_given_relative_paths() { - let fixture = Fixture::in_path(GameType::TES3, Path::new("target")); + let fixture = Fixture::in_path(GameType::Morrowind, Path::new("target")); let game_path = make_relative(&fixture.game_path); assert!(game_path.is_relative()); @@ -1005,7 +1005,7 @@ mod tests { #[test] fn should_succeed_if_given_absolute_paths() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); assert!(fixture.game_path.is_absolute()); assert!(fixture.local_path.is_absolute()); @@ -1021,7 +1021,7 @@ mod tests { #[test] fn should_succeed_if_given_symlink_paths() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let game_path = fixture.game_path.with_extension("symlink"); symlink_dir(&fixture.game_path, &game_path); @@ -1039,7 +1039,7 @@ mod tests { #[cfg(windows)] #[test] fn should_succeed_if_given_junction_link_paths() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let game_path = fixture.game_path.with_extension("junction"); junction_link(&fixture.game_path, &game_path); @@ -1054,7 +1054,7 @@ mod tests { #[test] fn should_error_if_given_a_game_path_that_does_not_exist() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let game_path = Path::new("missing"); let game = Game::with_local_path(fixture.game_type, game_path, &fixture.local_path); @@ -1067,7 +1067,7 @@ mod tests { #[test] fn should_succeed_if_given_a_local_path_that_does_not_exist() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let local_path = Path::new("missing"); let game = Game::with_local_path(fixture.game_type, &fixture.game_path, local_path); @@ -1077,7 +1077,7 @@ mod tests { #[test] fn should_error_if_given_a_local_path_that_is_not_a_directory() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let local_path = Path::new("README.md"); assert!(local_path.exists()); @@ -1095,7 +1095,7 @@ mod tests { let fixture = Fixture::new(game_type); match game_type { - GameType::FO4 => { + GameType::Fallout4 => { std::fs::File::create(fixture.game_path.join("appxmanifest.xml")).unwrap(); } GameType::OpenMW => { @@ -1117,7 +1117,7 @@ mod tests { .unwrap(); match game_type { - GameType::FO4 => { + GameType::Fallout4 => { let base_path = fixture.game_path.join("../.."); assert_eq!( &[ @@ -1180,7 +1180,7 @@ mod tests { #[test] fn should_clear_the_condition_cache() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut game = Game::with_local_path( fixture.game_type, @@ -1223,7 +1223,7 @@ mod tests { #[test] fn should_update_where_load_order_plugins_are_found() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut game = Game::with_local_path( fixture.game_type, @@ -1375,7 +1375,7 @@ mod tests { #[test] fn should_resolve_relative_paths_relative_to_the_data_path() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let game = Game::with_local_path( fixture.game_type, @@ -1393,7 +1393,7 @@ mod tests { #[test] fn should_use_absolute_paths_as_given() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let game = Game::with_local_path( fixture.game_type, @@ -1441,7 +1441,7 @@ mod tests { #[test] fn should_not_modify_loaded_plugins_storage_if_given_a_non_plugin() { - let fixture = Fixture::new(GameType::TES3); + let fixture = Fixture::new(GameType::Morrowind); let mut game = Game::with_local_path( fixture.game_type, @@ -1464,7 +1464,7 @@ mod tests { #[test] fn should_not_clear_the_plugins_cache() { - let fixture = Fixture::new(GameType::TES3); + let fixture = Fixture::new(GameType::Morrowind); let mut game = Game::with_local_path( fixture.game_type, @@ -1484,7 +1484,7 @@ mod tests { #[test] fn should_replace_an_existing_cache_entry_for_the_same_plugin() { - let fixture = Fixture::new(GameType::TES3); + let fixture = Fixture::new(GameType::Morrowind); let mut game = Game::with_local_path( fixture.game_type, @@ -1542,7 +1542,7 @@ mod tests { #[test] fn should_not_clear_the_plugins_cache() { - let fixture = Fixture::new(GameType::TES3); + let fixture = Fixture::new(GameType::Morrowind); let mut game = Game::with_local_path( fixture.game_type, @@ -1562,7 +1562,7 @@ mod tests { #[test] fn should_replace_an_existing_cache_entry_for_the_same_plugin() { - let fixture = Fixture::new(GameType::TES3); + let fixture = Fixture::new(GameType::Morrowind); let mut game = Game::with_local_path( fixture.game_type, @@ -1601,7 +1601,7 @@ mod tests { if matches!( game_type, - GameType::TES3 | GameType::OpenMW | GameType::Starfield + GameType::Morrowind | GameType::OpenMW | GameType::Starfield ) { match game.load_plugins(paths) { Err(LoadPluginsError::PluginDataError(e)) => { @@ -1690,7 +1690,7 @@ mod tests { let extension = if matches!( game_type, - GameType::FO4 | GameType::FO4VR | GameType::Starfield + GameType::Fallout4 | GameType::Fallout4VR | GameType::Starfield ) { ".ba2" } else { @@ -1730,7 +1730,7 @@ mod tests { #[test] fn should_clear_the_archive_cache_before_finding_archives() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut game = Game::with_local_path( fixture.game_type, @@ -1752,7 +1752,7 @@ mod tests { #[test] fn should_not_error_if_an_installed_filename_has_non_windows_1252_encodable_characters() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut game = Game::with_local_path( fixture.game_type, @@ -1770,7 +1770,7 @@ mod tests { #[test] fn should_error_given_duplicate_filenames() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut game = Game::with_local_path( fixture.game_type, @@ -1800,7 +1800,7 @@ mod tests { #[test] fn should_resolve_relative_paths_relative_to_the_data_path() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut game = Game::with_local_path( fixture.game_type, @@ -1823,7 +1823,7 @@ mod tests { #[test] fn should_use_absolute_paths_as_given() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut game = Game::with_local_path( fixture.game_type, @@ -1844,7 +1844,7 @@ mod tests { #[test] fn should_trim_ghost_extensions_from_loaded_plugin_names() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut game = Game::with_local_path( fixture.game_type, @@ -1868,7 +1868,7 @@ mod tests { #[test] fn clear_loaded_plugins_should_clear_the_plugins_cache() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut game = Game::with_local_path(fixture.game_type, &fixture.game_path, &fixture.local_path) @@ -1899,7 +1899,7 @@ mod tests { #[test] fn should_return_an_empty_list_if_given_an_empty_list() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let game = Game::with_local_path( fixture.game_type, @@ -1913,7 +1913,7 @@ mod tests { #[test] fn should_only_sort_the_given_plugins() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut game = Game::with_local_path( fixture.game_type, @@ -1932,7 +1932,7 @@ mod tests { #[test] fn should_error_if_a_given_plugin_is_not_loaded() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let game = Game::with_local_path( fixture.game_type, @@ -1950,7 +1950,7 @@ mod tests { #[test] fn should_be_independent_of_plugins_being_loaded() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut game = Game::with_local_path( fixture.game_type, @@ -1979,7 +1979,7 @@ mod tests { #[test] fn set_load_order_should_persist_the_given_load_order() { - let fixture = Fixture::new(GameType::TES4); + let fixture = Fixture::new(GameType::Oblivion); let mut game = Game::with_local_path(fixture.game_type, &fixture.game_path, &fixture.local_path) @@ -2005,7 +2005,7 @@ mod tests { #[test] fn should_support_loading_plugins_and_metadata_in_parallel() { - let fixture = Fixture::new(GameType::TES3); + let fixture = Fixture::new(GameType::Morrowind); let mut game = Game::with_local_path(fixture.game_type, &fixture.game_path, &fixture.local_path) @@ -2030,7 +2030,7 @@ mod tests { #[test] fn to_plugin_sorting_data_should_filter_out_files_with_false_constraints() { - let game_type = GameType::TES4; + let game_type = GameType::Oblivion; let true_constraint = "file(\"Blank.esm\")"; let false_constraint = "file(\"missing.esm\")"; @@ -2095,9 +2095,9 @@ mod tests { cache.insert_plugins(vec![ Plugin::new( - GameType::TES4, + GameType::Oblivion, &cache, - &source_plugins_path(GameType::TES4).join(BLANK_ESM), + &source_plugins_path(GameType::Oblivion).join(BLANK_ESM), LoadScope::HeaderOnly, ) .unwrap(), @@ -2112,9 +2112,9 @@ mod tests { cache.insert_plugins(vec![ Plugin::new( - GameType::TES4, + GameType::Oblivion, &cache, - &source_plugins_path(GameType::TES4).join(BLANK_ESM), + &source_plugins_path(GameType::Oblivion).join(BLANK_ESM), LoadScope::HeaderOnly, ) .unwrap(), @@ -2124,9 +2124,9 @@ mod tests { cache.insert_plugins(vec![ Plugin::new( - GameType::TES4, + GameType::Oblivion, &cache, - &source_plugins_path(GameType::TES4).join(BLANK_ESM), + &source_plugins_path(GameType::Oblivion).join(BLANK_ESM), LoadScope::WholePlugin, ) .unwrap(), @@ -2145,9 +2145,9 @@ mod tests { cache.insert_plugins(vec![ Plugin::new( - GameType::TES4, + GameType::Oblivion, &cache, - &source_plugins_path(GameType::TES4).join(BLANK_ESM), + &source_plugins_path(GameType::Oblivion).join(BLANK_ESM), LoadScope::HeaderOnly, ) .unwrap(), @@ -2173,9 +2173,9 @@ mod tests { cache.insert_plugins(vec![ Plugin::new( - GameType::TES4, + GameType::Oblivion, &cache, - &source_plugins_path(GameType::TES4).join(BLANK_ESM), + &source_plugins_path(GameType::Oblivion).join(BLANK_ESM), LoadScope::HeaderOnly, ) .unwrap(), diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs index d98da511..e625bd1b 100644 --- a/src/plugin/mod.rs +++ b/src/plugin/mod.rs @@ -331,10 +331,10 @@ fn has_plugin_file_extension(game_type: GameType, plugin_path: &Path) -> bool { } else { matches!( game_type, - GameType::FO4 - | GameType::FO4VR - | GameType::TES5SE - | GameType::TES5VR + GameType::Fallout4 + | GameType::Fallout4VR + | GameType::SkyrimSE + | GameType::SkyrimVR | GameType::Starfield ) && extension.eq_ignore_ascii_case("esl") } @@ -510,7 +510,7 @@ mod tests { #[test] fn new_should_handle_non_ascii_filenames_correctly() { let tmp_dir = tempdir().unwrap(); - let source_path = source_plugins_path(GameType::TES4).join(BLANK_ESM); + let source_path = source_plugins_path(GameType::Oblivion).join(BLANK_ESM); let path = tmp_dir.path().join(NON_ASCII_ESM); std::fs::copy(source_path, &path).unwrap(); @@ -539,10 +539,10 @@ mod tests { #[expect(clippy::float_cmp, reason = "float values should be exactly equal")] match game_type { - GameType::TES3 | GameType::OpenMW => { + GameType::Morrowind | GameType::OpenMW => { assert_eq!(1.2, plugin.header_version().unwrap()); } - GameType::TES4 => assert_eq!(0.8, plugin.header_version().unwrap()), + GameType::Oblivion => assert_eq!(0.8, plugin.header_version().unwrap()), GameType::Starfield => assert_eq!(0.96, plugin.header_version().unwrap()), _ => assert_eq!(0.94, plugin.header_version().unwrap()), } @@ -610,18 +610,18 @@ mod tests { #[expect(clippy::float_cmp, reason = "float values should be exactly equal")] match game_type { - GameType::TES3 | GameType::OpenMW => { + GameType::Morrowind | GameType::OpenMW => { assert_eq!(1.2, plugin.header_version().unwrap()); } - GameType::TES4 => assert_eq!(0.8, plugin.header_version().unwrap()), + GameType::Oblivion => assert_eq!(0.8, plugin.header_version().unwrap()), GameType::Starfield => assert_eq!(0.96, plugin.header_version().unwrap()), _ => assert_eq!(0.94, plugin.header_version().unwrap()), } let expected_crc = match game_type { - GameType::TES3 | GameType::OpenMW => 3_317_676_987, + GameType::Morrowind | GameType::OpenMW => 3_317_676_987, GameType::Starfield => 1_422_425_298, - GameType::TES4 => 3_759_349_588, + GameType::Oblivion => 3_759_349_588, _ => 3_000_242_590, }; @@ -629,7 +629,7 @@ mod tests { assert!(!plugin.do_assets_overlap(&plugin)); assert_eq!(0, plugin.asset_count()); - if matches!(game_type, GameType::TES3 | GameType::OpenMW) { + if matches!(game_type, GameType::Morrowind | GameType::OpenMW) { let master = Plugin::new( game_type, &GameCache::default(), @@ -678,7 +678,7 @@ mod tests { if matches!( game_type, - GameType::TES3 | GameType::OpenMW | GameType::Starfield + GameType::Morrowind | GameType::OpenMW | GameType::Starfield ) { // The Starfield test data doesn't include a BA2 file. assert!(!plugin.loads_archive()); @@ -742,7 +742,7 @@ mod tests { assert!( Plugin::new( - GameType::TES4, + GameType::Oblivion, &GameCache::default(), path, LoadScope::HeaderOnly @@ -802,10 +802,10 @@ mod tests { if matches!( game_type, - GameType::FO4 - | GameType::FO4VR - | GameType::TES5SE - | GameType::TES5VR + GameType::Fallout4 + | GameType::Fallout4VR + | GameType::SkyrimSE + | GameType::SkyrimVR | GameType::Starfield ) { assert!(light.is_light_plugin()); @@ -948,10 +948,10 @@ mod tests { if matches!( game_type, - GameType::FO4 - | GameType::FO4VR - | GameType::TES5SE - | GameType::TES5VR + GameType::Fallout4 + | GameType::Fallout4VR + | GameType::SkyrimSE + | GameType::SkyrimVR | GameType::Starfield ) { assert!(result); @@ -1053,10 +1053,10 @@ mod tests { let result = has_plugin_file_extension(game_type, Path::new("file.esl")); if matches!( game_type, - GameType::FO4 - | GameType::TES5SE - | GameType::FO4VR - | GameType::TES5VR + GameType::Fallout4 + | GameType::SkyrimSE + | GameType::Fallout4VR + | GameType::SkyrimVR | GameType::Starfield ) { assert!(result); diff --git a/src/tests.rs b/src/tests.rs index 32e6ff44..e2af230c 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -28,10 +28,12 @@ pub const NON_ASCII_ESM: &str = "non\u{00C1}scii.esm"; pub fn source_plugins_path(game_type: GameType) -> PathBuf { match game_type { - GameType::TES3 | GameType::OpenMW => absolute("./testing-plugins/Morrowind/Data Files"), - GameType::TES4 => absolute("./testing-plugins/Oblivion/Data"), + GameType::Morrowind | GameType::OpenMW => { + absolute("./testing-plugins/Morrowind/Data Files") + } + GameType::Oblivion => absolute("./testing-plugins/Oblivion/Data"), GameType::Starfield => absolute("./testing-plugins/Starfield/Data"), - GameType::FO3 | GameType::FONV | GameType::TES5 => { + GameType::Fallout3 | GameType::FalloutNV | GameType::Skyrim => { absolute("./testing-plugins/Skyrim/Data") } _ => absolute("./testing-plugins/SkyrimSE/Data"), @@ -41,12 +43,12 @@ pub fn source_plugins_path(game_type: GameType) -> PathBuf { fn master_file(game_type: GameType) -> &'static str { match game_type { - GameType::TES3 | GameType::OpenMW => "Morrowind.esm", - GameType::TES4 => "Oblivion.esm", - GameType::TES5 | GameType::TES5SE | GameType::TES5VR => "Skyrim.esm", - GameType::FO3 => "Fallout3.esm", - GameType::FONV => "FalloutNV.esm", - GameType::FO4 | GameType::FO4VR => "Fallout4.esm", + GameType::Morrowind | GameType::OpenMW => "Morrowind.esm", + GameType::Oblivion => "Oblivion.esm", + GameType::Skyrim | GameType::SkyrimSE | GameType::SkyrimVR => "Skyrim.esm", + GameType::Fallout3 => "Fallout3.esm", + GameType::FalloutNV => "FalloutNV.esm", + GameType::Fallout4 | GameType::Fallout4VR => "Fallout4.esm", GameType::Starfield => "Starfield.esm", } } @@ -62,14 +64,18 @@ fn touch(file_path: &Path) { fn supports_light_plugins(game_type: GameType) -> bool { matches!( game_type, - GameType::TES5SE | GameType::TES5VR | GameType::FO4 | GameType::FO4VR | GameType::Starfield + GameType::SkyrimSE + | GameType::SkyrimVR + | GameType::Fallout4 + | GameType::Fallout4VR + | GameType::Starfield ) } fn is_load_order_timestamp_based(game_type: GameType) -> bool { matches!( game_type, - GameType::TES3 | GameType::TES4 | GameType::FO3 | GameType::FONV + GameType::Morrowind | GameType::Oblivion | GameType::Fallout3 | GameType::FalloutNV ) } @@ -119,7 +125,7 @@ fn set_load_order( use std::io::Write; match game_type { - GameType::TES3 | GameType::OpenMW => {} + GameType::Morrowind | GameType::OpenMW => {} _ => { let mut file = File::create(local_path.join("Plugins.txt")).unwrap(); for (plugin, is_active) in load_order { @@ -149,7 +155,7 @@ fn set_load_order( mod_time += Duration::from_secs(60); } - } else if game_type == GameType::TES5 { + } else if game_type == GameType::Skyrim { let mut file = File::create(local_path.join("loadorder.txt")).unwrap(); for (plugin, _) in load_order { writeln!(file, "{plugin}").unwrap(); @@ -160,7 +166,7 @@ fn set_load_order( fn data_path(game_type: GameType, game_path: &Path) -> PathBuf { match game_type { GameType::OpenMW => game_path.join("resources/vfs"), - GameType::TES3 => game_path.join("Data Files"), + GameType::Morrowind => game_path.join("Data Files"), _ => game_path.join("Data"), } } @@ -312,15 +318,15 @@ impl Fixture { #[rstest::rstest] pub fn all_game_types( #[values( - GameType::TES4, - GameType::TES5, - GameType::FO3, - GameType::FONV, - GameType::FO4, - GameType::TES5SE, - GameType::FO4VR, - GameType::TES5VR, - GameType::TES3, + GameType::Oblivion, + GameType::Skyrim, + GameType::Fallout3, + GameType::FalloutNV, + GameType::Fallout4, + GameType::SkyrimSE, + GameType::Fallout4VR, + GameType::SkyrimVR, + GameType::Morrowind, GameType::Starfield, GameType::OpenMW )]