From c66307bde1bce11a2102418b8349ed67afb345ab Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 25 May 2024 10:56:27 -0400 Subject: [PATCH] Add physis_gamedata_find_offset function --- Cargo.lock | 18 +++++++++--------- src/gamedata.rs | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d350a7..3cb9d3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -75,9 +75,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" [[package]] name = "cfg-if" @@ -256,7 +256,7 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "physis" version = "0.3.0" -source = "git+https://github.com/redstrate/physis#0fbb604c737a383837ac3465e978a193accd20ab" +source = "git+https://github.com/redstrate/physis#fdf07fd25534299b7f7dd41e546b53246674371c" dependencies = [ "binrw", "bitflags 1.3.2", @@ -275,9 +275,9 @@ checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" dependencies = [ "unicode-ident", ] @@ -327,7 +327,7 @@ checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -375,9 +375,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.64" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -443,7 +443,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] diff --git a/src/gamedata.rs b/src/gamedata.rs index 470b120..6dc4135 100644 --- a/src/gamedata.rs +++ b/src/gamedata.rs @@ -58,6 +58,20 @@ pub extern "C" fn physis_gamedata_extract_file( } } +#[no_mangle] +pub extern "C" fn physis_gamedata_find_offset( + game_data: &mut GameData, + path: *const c_char, +) -> u32 { + unsafe { + if let Some(d) = game_data.find_offset(CStr::from_ptr(path).to_string_lossy().as_ref()) { + d + } else { + 0 + } + } +} + #[no_mangle] pub extern "C" fn physis_gamedata_free_sheet_header(_: *mut physis_EXH) { /*unsafe {