From 29126ef08c9d1284eaf8b29f01ba98a06f55c0d8 Mon Sep 17 00:00:00 2001 From: Greaka Date: Sat, 17 Aug 2019 19:33:35 +0200 Subject: [PATCH] addded local combat support --- Cargo.lock | 4 +--- Cargo.toml | 3 ++- src/arcdps.rs | 1 + src/exports/combat.rs | 26 ++++++++++++++++++++------ src/exports/mod.rs | 11 +++++++++++ 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5cfc70..573bb2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ name = "arcdps-bhud" version = "0.2.4" dependencies = [ - "arcdps_bindings 0.1.5 (git+https://github.com/greaka/arcdps_bindings)", + "arcdps_bindings 0.1.5", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -12,7 +12,6 @@ dependencies = [ [[package]] name = "arcdps_bindings" version = "0.1.5" -source = "git+https://github.com/greaka/arcdps_bindings#a982c4a710149caea91c9daa83d8b070f930927c" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -43,7 +42,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] -"checksum arcdps_bindings 0.1.5 (git+https://github.com/greaka/arcdps_bindings)" = "" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" diff --git a/Cargo.toml b/Cargo.toml index 87d630d..805f367 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ lazy_static = "1.3" [dependencies.arcdps_bindings] version = "0.1.5" git = "https://github.com/greaka/arcdps_bindings" -# path="../arcdps_bindings" +# path = "../arcdps_bindings" [dependencies.winapi] version = "0.3.7" @@ -21,3 +21,4 @@ crate-type = ["cdylib"] [profile.release] codegen-units = 1 +lto = true diff --git a/src/arcdps.rs b/src/arcdps.rs index 7ec7a58..e53ce74 100644 --- a/src/arcdps.rs +++ b/src/arcdps.rs @@ -6,6 +6,7 @@ pub fn gen_arcdps() -> LPVOID { arcdps_bindings::arcdps_exports::new(0x0002_0804, "BHUDrender", env!("CARGO_PKG_VERSION")) .imgui(imgui as arcdps_bindings::SafeImguiCallback) .combat(combat as arcdps_bindings::SafeCombatCallback) + .combat_local(combat_local as arcdps_bindings::SafeCombatCallback) .save() } diff --git a/src/exports/combat.rs b/src/exports/combat.rs index 9516702..edcad23 100644 --- a/src/exports/combat.rs +++ b/src/exports/combat.rs @@ -8,21 +8,36 @@ pub fn cbt( id: u64, revision: u64, ) { - let message = get_bytes(ev, src, dst, skillname, id, revision); + let mut message = Vec::new(); + message.push(2); // indicator for area combat message + add_bytes(&mut message, ev, src, dst, skillname, id, revision); socket::send(message); } -fn get_bytes( +pub fn cbt_local( ev: Option<&cbtevent>, src: Option<&Ag>, dst: Option<&Ag>, skillname: Option<&str>, id: u64, revision: u64, -) -> Vec { - let mut messages = 0; +) { let mut message = Vec::new(); - message.push(2); // indicator for combat message + message.push(3); // indicator for local combat message + add_bytes(&mut message, ev, src, dst, skillname, id, revision); + socket::send(message); +} + +fn add_bytes( + message: &mut Vec, + ev: Option<&cbtevent>, + src: Option<&Ag>, + dst: Option<&Ag>, + skillname: Option<&str>, + id: u64, + revision: u64, +) { + let mut messages = 0; if let Some(ev) = ev { messages |= 1; let mut bytes = get_ev_bytes(ev); @@ -47,7 +62,6 @@ fn get_bytes( message.insert(1, messages); message.append(&mut id.to_le_bytes().to_vec()); message.append(&mut revision.to_le_bytes().to_vec()); - message } fn get_ev_bytes(ev: &cbtevent) -> Vec { diff --git a/src/exports/mod.rs b/src/exports/mod.rs index 3063209..8f0a722 100644 --- a/src/exports/mod.rs +++ b/src/exports/mod.rs @@ -18,6 +18,17 @@ pub fn combat( combat::cbt(ev, src, dst, skillname, id, revision); } +pub fn combat_local( + ev: Option<&cbtevent>, + src: Option<&Ag>, + dst: Option<&Ag>, + skillname: Option<&str>, + id: u64, + revision: u64, +) { + combat::cbt_local(ev, src, dst, skillname, id, revision); +} + #[cfg(test)] mod tests { use super::*;