Add support for OpenMW .omwaddon and .omwgame plugins

This commit is contained in:
Oliver Hamlet
2025-01-29 18:38:24 +00:00
parent 2852491143
commit 9e2aa0cf9c
6 changed files with 126 additions and 1 deletions
+4
View File
@@ -76,3 +76,7 @@ pub static LCI_GAME_FALLOUT_4_VR: c_int = 7;
/// Game code for Starfield. /// Game code for Starfield.
#[no_mangle] #[no_mangle]
pub static LCI_GAME_STARFIELD: c_int = 9; pub static LCI_GAME_STARFIELD: c_int = 9;
/// Game code for OpenMW.
#[no_mangle]
pub static LCI_GAME_OPENMW: c_int = 10;
+1
View File
@@ -33,6 +33,7 @@ fn map_error(err: &Error) -> c_int {
pub fn map_game_type(game_type: c_int) -> Result<GameType, c_int> { pub fn map_game_type(game_type: c_int) -> Result<GameType, c_int> {
match game_type { match game_type {
x if x == LCI_GAME_OPENMW => Ok(GameType::OpenMW),
x if x == LCI_GAME_MORROWIND => Ok(GameType::Morrowind), x if x == LCI_GAME_MORROWIND => Ok(GameType::Morrowind),
x if x == LCI_GAME_OBLIVION => Ok(GameType::Oblivion), x if x == LCI_GAME_OBLIVION => Ok(GameType::Oblivion),
x if x == LCI_GAME_SKYRIM => Ok(GameType::Skyrim), x if x == LCI_GAME_SKYRIM => Ok(GameType::Skyrim),
+1
View File
@@ -22,6 +22,7 @@ void test_game_id_values() {
assert(LCI_GAME_FALLOUT_4 == 6); assert(LCI_GAME_FALLOUT_4 == 6);
assert(LCI_GAME_FALLOUT_4_VR == 7); assert(LCI_GAME_FALLOUT_4_VR == 7);
assert(LCI_GAME_STARFIELD == 9); assert(LCI_GAME_STARFIELD == 9);
assert(LCI_GAME_OPENMW == 10);
} }
void test_lci_condition_parse() { void test_lci_condition_parse() {
+1 -1
View File
@@ -127,7 +127,7 @@ fn evaluate_is_master(state: &State, file_path: &Path) -> Result<bool, Error> {
use esplugin::GameId; use esplugin::GameId;
let game_id = match state.game_type { let game_id = match state.game_type {
GameType::Morrowind => GameId::Morrowind, GameType::Morrowind | GameType::OpenMW => GameId::Morrowind,
GameType::Oblivion => GameId::Oblivion, GameType::Oblivion => GameId::Oblivion,
GameType::Skyrim => GameId::Skyrim, GameType::Skyrim => GameId::Skyrim,
GameType::SkyrimSE | GameType::SkyrimVR => GameId::SkyrimSE, GameType::SkyrimSE | GameType::SkyrimVR => GameId::SkyrimSE,
+117
View File
@@ -12,6 +12,9 @@ fn is_unghosted_plugin_file_extension(game_type: GameType, extension: &OsStr) ->
extension.eq_ignore_ascii_case("esp") extension.eq_ignore_ascii_case("esp")
|| extension.eq_ignore_ascii_case("esm") || extension.eq_ignore_ascii_case("esm")
|| (game_type.supports_light_plugins() && extension.eq_ignore_ascii_case("esl")) || (game_type.supports_light_plugins() && extension.eq_ignore_ascii_case("esl"))
|| (game_type == GameType::OpenMW
&& (extension.eq_ignore_ascii_case("omwaddon")
|| extension.eq_ignore_ascii_case("omwgame")))
} }
fn has_unghosted_plugin_file_extension(game_type: GameType, path: &Path) -> bool { fn has_unghosted_plugin_file_extension(game_type: GameType, path: &Path) -> bool {
@@ -97,6 +100,10 @@ mod tests {
fn is_unghosted_plugin_file_extension_should_be_true_for_esp_for_all_game_types() { fn is_unghosted_plugin_file_extension_should_be_true_for_esp_for_all_game_types() {
let extension = OsStr::new("Esp"); let extension = OsStr::new("Esp");
assert!(is_unghosted_plugin_file_extension(
GameType::OpenMW,
extension
));
assert!(is_unghosted_plugin_file_extension( assert!(is_unghosted_plugin_file_extension(
GameType::Morrowind, GameType::Morrowind,
extension extension
@@ -139,6 +146,10 @@ mod tests {
fn is_unghosted_plugin_file_extension_should_be_true_for_esm_for_all_game_types() { fn is_unghosted_plugin_file_extension_should_be_true_for_esm_for_all_game_types() {
let extension = OsStr::new("Esm"); let extension = OsStr::new("Esm");
assert!(is_unghosted_plugin_file_extension(
GameType::OpenMW,
extension
));
assert!(is_unghosted_plugin_file_extension( assert!(is_unghosted_plugin_file_extension(
GameType::Morrowind, GameType::Morrowind,
extension extension
@@ -203,6 +214,10 @@ mod tests {
fn is_unghosted_plugin_file_extension_should_be_false_for_esl_for_tes3_to_5_fo3_and_fonv() { fn is_unghosted_plugin_file_extension_should_be_false_for_esl_for_tes3_to_5_fo3_and_fonv() {
let extension = OsStr::new("Esl"); let extension = OsStr::new("Esl");
assert!(!is_unghosted_plugin_file_extension(
GameType::OpenMW,
extension
));
assert!(!is_unghosted_plugin_file_extension( assert!(!is_unghosted_plugin_file_extension(
GameType::Morrowind, GameType::Morrowind,
extension extension
@@ -225,10 +240,108 @@ mod tests {
)); ));
} }
#[test]
fn is_unghosted_plugin_file_extension_should_be_true_for_omwaddon_and_only_openmw() {
let extension = OsStr::new("omwaddon");
assert!(is_unghosted_plugin_file_extension(
GameType::OpenMW,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Morrowind,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Oblivion,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Skyrim,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::SkyrimSE,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::SkyrimVR,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Fallout3,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::FalloutNV,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Fallout4,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Fallout4VR,
extension
));
}
#[test]
fn is_unghosted_plugin_file_extension_should_be_true_for_omwgame_and_only_openmw() {
let extension = OsStr::new("omwgame");
assert!(is_unghosted_plugin_file_extension(
GameType::OpenMW,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Morrowind,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Oblivion,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Skyrim,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::SkyrimSE,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::SkyrimVR,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Fallout3,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::FalloutNV,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Fallout4,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Fallout4VR,
extension
));
}
#[test] #[test]
fn is_unghosted_plugin_file_extension_should_be_false_for_ghost_for_all_game_types() { fn is_unghosted_plugin_file_extension_should_be_false_for_ghost_for_all_game_types() {
let extension = OsStr::new("Ghost"); let extension = OsStr::new("Ghost");
assert!(!is_unghosted_plugin_file_extension(
GameType::OpenMW,
extension
));
assert!(!is_unghosted_plugin_file_extension( assert!(!is_unghosted_plugin_file_extension(
GameType::Morrowind, GameType::Morrowind,
extension extension
@@ -271,6 +384,10 @@ mod tests {
fn is_unghosted_plugin_file_extension_should_be_false_for_non_esp_esm_esl_for_all_game_types() { fn is_unghosted_plugin_file_extension_should_be_false_for_non_esp_esm_esl_for_all_game_types() {
let extension = OsStr::new("txt"); let extension = OsStr::new("txt");
assert!(!is_unghosted_plugin_file_extension(
GameType::OpenMW,
extension
));
assert!(!is_unghosted_plugin_file_extension( assert!(!is_unghosted_plugin_file_extension(
GameType::Morrowind, GameType::Morrowind,
extension extension
+2
View File
@@ -36,6 +36,7 @@ pub enum GameType {
Fallout4VR, Fallout4VR,
Morrowind, Morrowind,
Starfield, Starfield,
OpenMW,
} }
impl GameType { impl GameType {
@@ -319,6 +320,7 @@ mod tests {
#[test] #[test]
fn game_type_supports_light_master_should_be_false_for_tes3_to_5_fo3_and_fonv() { fn game_type_supports_light_master_should_be_false_for_tes3_to_5_fo3_and_fonv() {
assert!(!GameType::OpenMW.supports_light_plugins());
assert!(!GameType::Morrowind.supports_light_plugins()); assert!(!GameType::Morrowind.supports_light_plugins());
assert!(!GameType::Oblivion.supports_light_plugins()); assert!(!GameType::Oblivion.supports_light_plugins());
assert!(!GameType::Skyrim.supports_light_plugins()); assert!(!GameType::Skyrim.supports_light_plugins());