Skip to content

Commit

Permalink
addded local combat support
Browse files Browse the repository at this point in the history
  • Loading branch information
greaka committed Aug 17, 2019
1 parent f06adfd commit 29126ef
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
4 changes: 1 addition & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -21,3 +21,4 @@ crate-type = ["cdylib"]

[profile.release]
codegen-units = 1
lto = true
1 change: 1 addition & 0 deletions src/arcdps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
26 changes: 20 additions & 6 deletions src/exports/combat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> {
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<u8>,
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);
Expand All @@ -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<u8> {
Expand Down
11 changes: 11 additions & 0 deletions src/exports/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down

0 comments on commit 29126ef

Please sign in to comment.