Skip to main content

fromsoftware_shared/
steam.rs

1use vtable_rs::VPtr;
2
3#[vtable_rs::vtable]
4pub trait CCallbackBaseVmt<P> {
5    /// Called when the callback is triggered
6    fn run(&mut self, pv_param: *mut P);
7
8    /// Called when the callback is triggered as a result of a specific API call
9    fn run_call(&mut self, pv_param: *mut P, io_failure: bool, api_call: u64);
10
11    /// Returns the size of the parameter struct (P)
12    fn get_callback_size_bytes(&mut self) -> i32;
13
14    fn destructor(&mut self, should_free: bool);
15}
16
17#[repr(C)]
18pub struct CCallbackBase<P: 'static> {
19    pub vftable: VPtr<dyn CCallbackBaseVmt<P>, Self>,
20    /// Internal Steam flags
21    pub callback_flags: CallbackFlags,
22    /// The unique ID for the callback type
23    /// (e.g., 1101 for UserStatsReceived_t)
24    pub callback_id: i32,
25}
26
27#[repr(C)]
28pub struct CCallback<T, P: 'static> {
29    pub base: CCallbackBase<P>,
30    pub obj: *mut T,
31    pub func: extern "C" fn(&mut T, *mut P),
32}
33
34bitflags::bitflags! {
35    #[repr(C)]
36    #[derive(Debug, Clone, Copy)]
37    pub struct CallbackFlags: u8 {
38        const REGISTERED = 0x01;
39        const GAME_SERVER = 0x02;
40    }
41}