Skip to content

Commit

Permalink
Rename esp_plugin_is_light_master() to esp_plugin_is_light_plugin()
Browse files Browse the repository at this point in the history
This was missed in b40962e. The old
function name has been kept for backwards compatibility.
  • Loading branch information
Ortham committed May 4, 2021
1 parent b2cf71b commit b11fec5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ffi/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,28 @@ pub unsafe extern "C" fn esp_plugin_is_master(
.unwrap_or(ESP_ERROR_PANICKED)
}


#[no_mangle]
#[deprecated = "This has been renamed to esp_plugin_is_light_plugin() for clarity."]
pub unsafe extern "C" fn esp_plugin_is_light_master(
plugin_ptr: *const Plugin,
is_light_master: *mut bool,
) -> u32 {
esp_plugin_is_light_plugin(plugin_ptr, is_light_master)
}

#[no_mangle]
pub unsafe extern "C" fn esp_plugin_is_light_plugin(
plugin_ptr: *const Plugin,
is_light_plugin: *mut bool,
) -> u32 {
panic::catch_unwind(|| {
if plugin_ptr.is_null() || is_light_master.is_null() {
if plugin_ptr.is_null() || is_light_plugin.is_null() {
ESP_ERROR_NULL_POINTER
} else {
let plugin = &*plugin_ptr;

*is_light_master = plugin.is_light_plugin();
*is_light_plugin = plugin.is_light_plugin();

ESP_OK
}
Expand Down
15 changes: 15 additions & 0 deletions ffi/tests/ffi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ void test_esp_plugin_is_light_master() {
esp_plugin_free(plugin);
}

void test_esp_plugin_is_light_plugin() {
printf("testing esp_plugin_is_light_plugin()...\n");
Plugin * plugin;
auto return_code = esp_plugin_new(&plugin, ESP_GAME_FALLOUT4, "../../testing-plugins/Skyrim/Data/Blank.esl");
assert(return_code == ESP_OK);

bool is_light_plugin;
return_code = esp_plugin_is_light_plugin(plugin, &is_light_plugin);
assert(return_code == ESP_OK);
assert(is_light_plugin);

esp_plugin_free(plugin);
}

void test_esp_plugin_is_valid() {
bool is_valid;
auto return_code = esp_plugin_is_valid(ESP_GAME_SKYRIM, "../../testing-plugins/Skyrim/Data/Blank.esm", true, &is_valid);
Expand Down Expand Up @@ -273,6 +287,7 @@ int main() {
test_esp_plugin_masters();
test_esp_plugin_is_master();
test_esp_plugin_is_light_master();
test_esp_plugin_is_light_plugin();
test_esp_plugin_is_valid();
test_esp_plugin_description();
test_esp_plugin_header_version();
Expand Down

0 comments on commit b11fec5

Please sign in to comment.