From 47ff3b8ee20290f20c8c971532eb5fda394c730f Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Tue, 14 Jan 2025 18:28:06 +0000 Subject: [PATCH] Add support for OpenMW .omwaddon and .omwgame plugins --- ffi/src/constants.rs | 4 ++++ ffi/src/helpers.rs | 1 + ffi/tests/ffi.cpp | 1 + src/function/eval.rs | 2 +- src/function/path.rs | 3 +++ src/lib.rs | 1 + 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ffi/src/constants.rs b/ffi/src/constants.rs index 8cb80a9..5c190cc 100644 --- a/ffi/src/constants.rs +++ b/ffi/src/constants.rs @@ -76,3 +76,7 @@ pub static LCI_GAME_FALLOUT_4_VR: c_int = 7; /// Game code for Starfield. #[no_mangle] pub static LCI_GAME_STARFIELD: c_int = 9; + +/// Game code for OpenMW. +#[no_mangle] +pub static LCI_GAME_OPENMW: c_int = 10; diff --git a/ffi/src/helpers.rs b/ffi/src/helpers.rs index ef5229f..cd9dfea 100644 --- a/ffi/src/helpers.rs +++ b/ffi/src/helpers.rs @@ -43,6 +43,7 @@ pub fn map_game_type(game_type: c_int) -> Result { x if x == LCI_GAME_FALLOUT_4 => Ok(GameType::Fallout4), x if x == LCI_GAME_FALLOUT_4_VR => Ok(GameType::Fallout4VR), x if x == LCI_GAME_STARFIELD => Ok(GameType::Starfield), + x if x == LCI_GAME_OPENMW => Ok(GameType::OpenMW), _ => Err(LCI_ERROR_INVALID_ARGS), } } diff --git a/ffi/tests/ffi.cpp b/ffi/tests/ffi.cpp index fadcaf8..6374f1f 100644 --- a/ffi/tests/ffi.cpp +++ b/ffi/tests/ffi.cpp @@ -22,6 +22,7 @@ void test_game_id_values() { assert(LCI_GAME_FALLOUT_4 == 6); assert(LCI_GAME_FALLOUT_4_VR == 7); assert(LCI_GAME_STARFIELD == 9); + assert(LCI_GAME_OPENMW == 10); } void test_lci_condition_parse() { diff --git a/src/function/eval.rs b/src/function/eval.rs index fcc07a9..6a84fdd 100644 --- a/src/function/eval.rs +++ b/src/function/eval.rs @@ -123,7 +123,7 @@ fn evaluate_is_master(state: &State, file_path: &Path) -> Result { use esplugin::GameId; let game_id = match state.game_type { - GameType::Morrowind => GameId::Morrowind, + GameType::Morrowind | GameType::OpenMW => GameId::Morrowind, GameType::Oblivion => GameId::Oblivion, GameType::Skyrim => GameId::Skyrim, GameType::SkyrimSE | GameType::SkyrimVR => GameId::SkyrimSE, diff --git a/src/function/path.rs b/src/function/path.rs index 6c2bace..13051ca 100644 --- a/src/function/path.rs +++ b/src/function/path.rs @@ -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("esm") || (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 { diff --git a/src/lib.rs b/src/lib.rs index c8b9c5c..e4d97f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,6 +36,7 @@ pub enum GameType { Fallout4VR, Morrowind, Starfield, + OpenMW, } impl GameType {