Rename LCI_GAME_* constants to use fewer acronyms

A minor quality of life improvement, to break the FFI compatibility in
step with the Rust library.
This commit is contained in:
Oliver Hamlet
2019-06-30 11:25:23 +01:00
parent 52792626af
commit 860995638c
3 changed files with 41 additions and 41 deletions
+18 -18
View File
@@ -40,39 +40,39 @@ pub static LCI_ERROR_TEXT_ENCODE_FAIL: c_int = -7;
/// Game code for The Elder Scrolls III: Morrowind.
#[no_mangle]
pub static LCI_GAME_TES3: c_int = GameType::Morrowind as c_int;
pub static LCI_GAME_MORROWIND: c_int = GameType::Morrowind as c_int;
/// Game code for The Elder Scrolls IV: Oblivion.
#[no_mangle]
pub static LCI_GAME_TES4: c_int = GameType::Oblivion as c_int;
pub static LCI_GAME_OBLIVION: c_int = GameType::Oblivion as c_int;
/// Game code for The Elder Scrolls V: Skyrim.
#[no_mangle]
pub static LCI_GAME_TES5: c_int = GameType::Skyrim as c_int;
pub static LCI_GAME_SKYRIM: c_int = GameType::Skyrim as c_int;
/// Game code for Fallout 3.
#[no_mangle]
pub static LCI_GAME_FO3: c_int = GameType::Fallout3 as c_int;
pub static LCI_GAME_FALLOUT_3: c_int = GameType::Fallout3 as c_int;
/// Game code for Fallout: New Vegas.
#[no_mangle]
pub static LCI_GAME_FNV: c_int = GameType::FalloutNV as c_int;
pub static LCI_GAME_FALLOUT_NV: c_int = GameType::FalloutNV as c_int;
/// Game code for Fallout 4.
#[no_mangle]
pub static LCI_GAME_FO4: c_int = GameType::Fallout4 as c_int;
pub static LCI_GAME_FALLOUT_4: c_int = GameType::Fallout4 as c_int;
/// Game code for The Elder Scrolls V: Skyrim Special Edition.
#[no_mangle]
pub static LCI_GAME_TES5SE: c_int = GameType::SkyrimSE as c_int;
pub static LCI_GAME_SKYRIM_SE: c_int = GameType::SkyrimSE as c_int;
/// Game code for The Elder Scrolls V: Skyrim VR.
#[no_mangle]
pub static LCI_GAME_TES5VR: c_int = GameType::SkyrimVR as c_int;
pub static LCI_GAME_SKYRIM_VR: c_int = GameType::SkyrimVR as c_int;
/// Game code for Fallout 4 VR.
#[no_mangle]
pub static LCI_GAME_FO4VR: c_int = GameType::Fallout4VR as c_int;
pub static LCI_GAME_FALLOUT_4_VR: c_int = GameType::Fallout4VR as c_int;
#[cfg(test)]
mod tests {
@@ -80,14 +80,14 @@ mod tests {
#[test]
fn game_constants_should_have_expected_integer_values() {
assert_eq!(8, LCI_GAME_TES3);
assert_eq!(0, LCI_GAME_TES4);
assert_eq!(1, LCI_GAME_TES5);
assert_eq!(2, LCI_GAME_TES5SE);
assert_eq!(3, LCI_GAME_TES5VR);
assert_eq!(4, LCI_GAME_FO3);
assert_eq!(5, LCI_GAME_FNV);
assert_eq!(6, LCI_GAME_FO4);
assert_eq!(7, LCI_GAME_FO4VR);
assert_eq!(8, LCI_GAME_MORROWIND);
assert_eq!(0, LCI_GAME_OBLIVION);
assert_eq!(1, LCI_GAME_SKYRIM);
assert_eq!(2, LCI_GAME_SKYRIM_SE);
assert_eq!(3, LCI_GAME_SKYRIM_VR);
assert_eq!(4, LCI_GAME_FALLOUT_3);
assert_eq!(5, LCI_GAME_FALLOUT_NV);
assert_eq!(6, LCI_GAME_FALLOUT_4);
assert_eq!(7, LCI_GAME_FALLOUT_4_VR);
}
}
+9 -9
View File
@@ -32,15 +32,15 @@ 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_TES3 => Ok(GameType::Morrowind),
x if x == LCI_GAME_TES4 => Ok(GameType::Oblivion),
x if x == LCI_GAME_TES5 => Ok(GameType::Skyrim),
x if x == LCI_GAME_TES5SE => Ok(GameType::SkyrimSE),
x if x == LCI_GAME_TES5VR => Ok(GameType::SkyrimVR),
x if x == LCI_GAME_FO3 => Ok(GameType::Fallout3),
x if x == LCI_GAME_FNV => Ok(GameType::FalloutNV),
x if x == LCI_GAME_FO4 => Ok(GameType::Fallout4),
x if x == LCI_GAME_FO4VR => Ok(GameType::Fallout4VR),
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),
x if x == LCI_GAME_SKYRIM_SE => Ok(GameType::SkyrimSE),
x if x == LCI_GAME_SKYRIM_VR => Ok(GameType::SkyrimVR),
x if x == LCI_GAME_FALLOUT_3 => Ok(GameType::Fallout3),
x if x == LCI_GAME_FALLOUT_NV => Ok(GameType::FalloutNV),
x if x == LCI_GAME_FALLOUT_4 => Ok(GameType::Fallout4),
x if x == LCI_GAME_FALLOUT_4_VR => Ok(GameType::Fallout4VR),
_ => Err(LCI_ERROR_INVALID_ARGS),
}
}
+14 -14
View File
@@ -12,15 +12,15 @@
void test_game_id_values() {
printf("testing LCI_GAME_* values...\n");
assert(LCI_GAME_TES3 == 8);
assert(LCI_GAME_TES4 == 0);
assert(LCI_GAME_TES5 == 1);
assert(LCI_GAME_TES5SE == 2);
assert(LCI_GAME_TES5VR == 3);
assert(LCI_GAME_FO3 == 4);
assert(LCI_GAME_FNV == 5);
assert(LCI_GAME_FO4 == 6);
assert(LCI_GAME_FO4VR == 7);
assert(LCI_GAME_MORROWIND == 8);
assert(LCI_GAME_OBLIVION == 0);
assert(LCI_GAME_SKYRIM == 1);
assert(LCI_GAME_SKYRIM_SE == 2);
assert(LCI_GAME_SKYRIM_VR == 3);
assert(LCI_GAME_FALLOUT_3 == 4);
assert(LCI_GAME_FALLOUT_NV == 5);
assert(LCI_GAME_FALLOUT_4 == 6);
assert(LCI_GAME_FALLOUT_4_VR == 7);
}
void test_lci_condition_parse() {
@@ -54,7 +54,7 @@ void test_lci_state_create() {
printf("testing lci_state_create()...\n");
lci_state * state = nullptr;
int return_code = lci_state_create(&state, LCI_GAME_TES4, ".", ".");
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, ".", ".");
assert(return_code == LCI_OK);
assert(state != nullptr);
@@ -66,7 +66,7 @@ void test_lci_condition_eval() {
printf("testing lci_condition_eval()...\n");
lci_state * state = nullptr;
int return_code = lci_state_create(&state, LCI_GAME_TES4, "../../tests/testing-plugins/Oblivion/Data", ".");
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, "../../tests/testing-plugins/Oblivion/Data", ".");
assert(return_code == LCI_OK);
assert(state != nullptr);
@@ -86,7 +86,7 @@ void test_lci_state_set_active_plugins() {
printf("testing lci_state_set_active_plugins()...\n");
lci_state * state = nullptr;
int return_code = lci_state_create(&state, LCI_GAME_TES4, "../../tests/testing-plugins/Oblivion/Data", ".");
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, "../../tests/testing-plugins/Oblivion/Data", ".");
assert(return_code == LCI_OK);
assert(state != nullptr);
@@ -118,7 +118,7 @@ void test_lci_state_set_plugin_versions() {
printf("testing lci_state_set_plugin_versions()...\n");
lci_state * state = nullptr;
int return_code = lci_state_create(&state, LCI_GAME_TES4, "../../tests/testing-plugins/Oblivion/Data", ".");
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, "../../tests/testing-plugins/Oblivion/Data", ".");
assert(return_code == LCI_OK);
assert(state != nullptr);
@@ -153,7 +153,7 @@ void test_lci_state_set_crc_cache() {
printf("testing lci_state_set_crc_cache()...\n");
lci_state * state = nullptr;
int return_code = lci_state_create(&state, LCI_GAME_TES4, "../../tests/testing-plugins/Oblivion/Data", ".");
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, "../../tests/testing-plugins/Oblivion/Data", ".");
assert(return_code == LCI_OK);
assert(state != nullptr);