Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for OpenMW .omwaddon and .omwgame plugins
Browse files Browse the repository at this point in the history
Ortham committed Jan 24, 2025
1 parent 94d663b commit aa0a34a
Showing 6 changed files with 120 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ffi/src/constants.rs
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions ffi/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ fn map_error(err: &Error) -> c_int {

pub fn map_game_type(game_type: c_int) -> Result<GameType, c_int> {
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_OBLIVION => Ok(GameType::Oblivion),
x if x == LCI_GAME_SKYRIM => Ok(GameType::Skyrim),
1 change: 1 addition & 0 deletions ffi/tests/ffi.cpp
Original file line number Diff line number Diff line change
@@ -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() {
2 changes: 1 addition & 1 deletion src/function/eval.rs
Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@ fn evaluate_is_master(state: &State, file_path: &Path) -> Result<bool, Error> {
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,
111 changes: 111 additions & 0 deletions src/function/path.rs
Original file line number Diff line number Diff line change
@@ -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 {
@@ -97,6 +100,10 @@ mod tests {
fn is_unghosted_plugin_file_extension_should_be_true_for_esp_for_all_game_types() {
let extension = OsStr::new("Esp");

assert!(is_unghosted_plugin_file_extension(
GameType::OpenMW,
extension
));
assert!(is_unghosted_plugin_file_extension(
GameType::Morrowind,
extension
@@ -139,6 +146,10 @@ mod tests {
fn is_unghosted_plugin_file_extension_should_be_true_for_esm_for_all_game_types() {
let extension = OsStr::new("Esm");

assert!(is_unghosted_plugin_file_extension(
GameType::OpenMW,
extension
));
assert!(is_unghosted_plugin_file_extension(
GameType::Morrowind,
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() {
let extension = OsStr::new("Esl");

assert!(!is_unghosted_plugin_file_extension(
GameType::OpenMW,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Morrowind,
extension
@@ -225,10 +240,102 @@ 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]
fn is_unghosted_plugin_file_extension_should_be_false_for_ghost_for_all_game_types() {
let extension = OsStr::new("Ghost");

assert!(!is_unghosted_plugin_file_extension(
GameType::OpenMW,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Morrowind,
extension
@@ -271,6 +378,10 @@ mod tests {
fn is_unghosted_plugin_file_extension_should_be_false_for_non_esp_esm_esl_for_all_game_types() {
let extension = OsStr::new("txt");

assert!(!is_unghosted_plugin_file_extension(
GameType::OpenMW,
extension
));
assert!(!is_unghosted_plugin_file_extension(
GameType::Morrowind,
extension
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ pub enum GameType {
Fallout4VR,
Morrowind,
Starfield,
OpenMW,
}

impl GameType {
@@ -316,6 +317,7 @@ mod tests {

#[test]
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::Oblivion.supports_light_plugins());
assert!(!GameType::Skyrim.supports_light_plugins());

0 comments on commit aa0a34a

Please sign in to comment.