#![allow(clippy::upper_case_acronyms)]
use std::os::raw::{c_char, c_void};
use crate::helpers::get_str_from_pc_char;
pub type LPARAM = isize;
pub type LPVOID = *mut c_void;
pub type UINT = u32;
pub type WPARAM = usize;
pub type PCCHAR = *mut c_char;
pub type LPCSTR = *const c_char;
pub type HWND = *mut c_void;
pub type HMODULE = *mut c_void;
pub type HANDLE = *mut std::os::raw::c_void;
pub const WM_KEYDOWN: u32 = 0x100;
pub const WM_KEYUP: u32 = 0x101;
pub const WM_SYSKEYDOWN: u32 = 0x104;
pub const WM_SYSKEYUP: u32 = 0x105;
extern "system" {
pub fn GetProcAddress(module: HMODULE, proc_name: LPCSTR) -> *mut c_void;
}
pub type RawWndprocCallback =
unsafe extern "C" fn(h_wnd: HWND, u_msg: UINT, w_param: WPARAM, l_param: LPARAM) -> UINT;
pub type RawCombatCallback = unsafe extern "C" fn(
ev: Option<&CombatEvent>,
src: Option<&RawAgent>,
dst: Option<&RawAgent>,
skill_name: PCCHAR,
id: u64,
revision: u64,
);
pub type RawImguiCallback = unsafe extern "C" fn(not_character_select_or_loading: u32);
pub type RawOptionsCallback = unsafe extern "C" fn();
pub type RawOptionsWindowsCallback = unsafe extern "C" fn(window_name: PCCHAR) -> bool;
pub type InitFunc = fn() -> Result<(), Box<dyn std::error::Error>>;
pub type ReleaseFunc = fn();
pub type WndProcCallback = fn(key: usize, key_down: bool, prev_key_down: bool) -> bool;
pub type ImguiCallback = fn(ui: &imgui::Ui, not_character_select_or_loading: bool);
pub type OptionsCallback = fn(ui: &imgui::Ui);
pub type OptionsWindowsCallback = fn(ui: &imgui::Ui, window_name: Option<&str>) -> bool;
pub type CombatCallback = fn(
ev: Option<&CombatEvent>,
src: Option<Agent>,
dst: Option<Agent>,
skill_name: Option<&'static str>,
id: u64,
revision: u64,
);
pub type Export0 = unsafe extern "C" fn() -> *mut u16;
pub type Export3 = unsafe extern "C" fn(*mut u8);
pub type Export5 = unsafe extern "C" fn(*mut [*mut imgui::sys::ImVec4; 5]);
pub type Export6 = unsafe extern "C" fn() -> u64;
pub type Export7 = unsafe extern "C" fn() -> u64;
pub type Export8 = Export3;
pub type Export9 = unsafe extern "C" fn(&CombatEvent, u32);
impl From<&RawAgent> for Agent<'_> {
fn from(ag: &RawAgent) -> Self {
let name = unsafe { get_str_from_pc_char(ag.name) };
Agent {
name,
id: ag.id,
prof: ag.prof,
elite: ag.elite,
self_: ag.self_,
team: ag.team,
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct Agent<'a> {
pub name: Option<&'a str>,
pub id: usize,
pub prof: u32,
pub elite: u32,
pub self_: u32,
pub team: u16,
}
#[derive(Debug, Clone)]
pub struct AgentOwned {
pub name: Option<String>,
pub id: usize,
pub prof: u32,
pub elite: u32,
pub self_: u32,
pub team: u16,
}
impl From<Agent<'_>> for AgentOwned {
fn from(ag: Agent<'_>) -> Self {
AgentOwned {
name: ag.name.map(|x| x.to_string()),
id: ag.id,
prof: ag.prof,
elite: ag.elite,
self_: ag.self_,
team: ag.team,
}
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CombatEvent {
pub time: u64,
pub src_agent: usize,
pub dst_agent: usize,
pub value: i32,
pub buff_dmg: i32,
pub overstack_value: u32,
pub skill_id: u32,
pub src_instance_id: u16,
pub dst_instance_id: u16,
pub src_master_instance_id: u16,
pub dst_master_instance_id: u16,
pub iff: u8,
pub buff: u8,
pub result: u8,
pub is_activation: u8,
pub is_buff_remove: u8,
pub is_ninety: u8,
pub is_fifty: u8,
pub is_moving: u8,
pub is_statechange: u8,
pub is_flanking: u8,
pub is_shields: u8,
pub is_off_cycle: u8,
pub pad61: u8,
pub pad62: u8,
pub pad63: u8,
pub pad64: u8,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct RawAgent {
pub name: PCCHAR,
pub id: usize,
pub prof: u32,
pub elite: u32,
pub self_: u32,
pub team: u16,
}
#[repr(C)]
pub struct ArcDpsExport {
pub size: usize,
pub sig: u32,
pub imgui_version: u32,
pub out_name: *const u8,
pub out_build: *const u8,
pub wnd_nofilter: Option<RawWndprocCallback>,
pub combat: Option<RawCombatCallback>,
pub imgui: Option<RawImguiCallback>,
pub options_end: Option<RawOptionsCallback>,
pub combat_local: Option<RawCombatCallback>,
pub wnd_filter: Option<RawWndprocCallback>,
pub options_windows: Option<RawOptionsWindowsCallback>,
}
unsafe impl Sync for ArcDpsExport {}