mirror of
https://github.com/loot/loot-condition-interpreter.git
synced 2026-07-27 14:16:09 -07:00
Add support for OpenMW .omwaddon and .omwgame plugins
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -127,7 +127,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,
|
||||
|
||||
@@ -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,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]
|
||||
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 +384,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
|
||||
|
||||
@@ -36,6 +36,7 @@ pub enum GameType {
|
||||
Fallout4VR,
|
||||
Morrowind,
|
||||
Starfield,
|
||||
OpenMW,
|
||||
}
|
||||
|
||||
impl GameType {
|
||||
@@ -319,6 +320,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());
|
||||
|
||||
Reference in New Issue
Block a user