diff --git a/Cargo.lock b/Cargo.lock index a0f455f..0f10072 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1322,7 +1322,8 @@ dependencies = [ [[package]] name = "sm-ext" version = "0.3.0" -source = "git+https://github.com/asherkin/sm-ext-rs.git?rev=8e8d87b#8e8d87bdd234ce6acdcd84907e319fe4b73aa8d5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcdcd9d45b7f6d92ab1fa4dc1a9090d59ccdceab4f94aa51991c3ef0d73c8fda" dependencies = [ "c_str_macro", "libc", @@ -1332,7 +1333,8 @@ dependencies = [ [[package]] name = "sm-ext-derive" version = "0.3.0" -source = "git+https://github.com/asherkin/sm-ext-rs.git?rev=8e8d87b#8e8d87bdd234ce6acdcd84907e319fe4b73aa8d5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75e96380b9fa81d50460fa1240990754e7f5766a74ffa5791f0cf43f50e56fc2" dependencies = [ "proc-macro2", "quote", @@ -1589,9 +1591,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" diff --git a/api/src/main.rs b/api/src/main.rs index cf69430..daa855f 100644 --- a/api/src/main.rs +++ b/api/src/main.rs @@ -6,7 +6,8 @@ clippy::complexity, clippy::perf, clippy::style, - clippy::suspicious + clippy::suspicious, + clippy::restriction )] use axum::{ @@ -14,16 +15,36 @@ use axum::{ Router, }; +use tokio::net::TcpListener; + #[tokio::main] async fn main() { + + let x = 5_i32; + let app = Router::new().route("/", get(root)); - let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); + let listener = match TcpListener::bind("0.0.0.0:3000").await { + Ok(x) => x, + Err(e) => { + println!("Error: {}", e); + return; + } + + }; - axum::serve(listener, app).await.unwrap(); + + + match axum::serve(listener, app).await { + Ok(x) => x, + Err(e) => { + println!("Error: {}", e); + return; + } + }; } -// basic handler that responds with a static string + async fn root() -> &'static str { "Hello, World!" } \ No newline at end of file diff --git a/shrimpstats_tf2/Cargo.toml b/shrimpstats_tf2/Cargo.toml index 71b40d7..d4d2fc9 100644 --- a/shrimpstats_tf2/Cargo.toml +++ b/shrimpstats_tf2/Cargo.toml @@ -4,13 +4,9 @@ version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -# -C target-feature=+crt-static - -# windows target -[target.'cfg(all(target_arch="x86_64", target_os="windows"))'] -rustfl = ["-Ctarget-feature=+crt-static"] +[lib] +crate-type = ["cdylib"] [dependencies] -sm-ext = { git = "https://github.com/asherkin/sm-ext-rs.git", rev = "8e8d87b"} +sm-ext = "0.3.0" \ No newline at end of file diff --git a/shrimpstats_tf2/src/lib.rs b/shrimpstats_tf2/src/lib.rs index 7e839ac..dcc5cd4 100644 --- a/shrimpstats_tf2/src/lib.rs +++ b/shrimpstats_tf2/src/lib.rs @@ -10,50 +10,30 @@ )] -use sm_ext::{forwards, native, ExecType, ICallableApi, IExtension, IExtensionInterface, IShareSys, SMExtension}; +use std::ffi::CStr; + +use sm_ext::{forwards, native, ExecType, ICallableApi, IExtension, IExtensionInterface, IForwardManager, IShareSys, SMExtension, SMInterfaceApi}; #[derive(Default, SMExtension)] #[extension(name = "shrimpstats_tf2", description = "ShrimpStats TF2 Extension")] pub struct ShrimpStatsTF2Extension; +#[forwards] +struct MyForwards { + /// ```sourcepawn + /// forward int OnRustCall(int a, int b, const char[] c); + /// ``` + #[global_forward("OnRustCall", ExecType::Hook)] + on_rust_call: fn(a: i32, b: i32, c: &CStr) -> i32, +} -// Name: player_death -// Structure: -// short userid user ID who died -// long victim_entindex -// long inflictor_entindex ent index of inflictor (a sentry, for example) -// short attacker user ID who killed -// string weapon weapon name killer used -// short weaponid ID of weapon killed used -// long damagebits bits of type of damage -// short customkill type of custom kill -// short assister user ID of assister -// string weapon_logclassname weapon name that should be printed on the log -// short stun_flags victim's stun flags at the moment of death -// short death_flags death flags. -// bool silent_kill -// short playerpenetratecount -// string assister_fallback contains a string to use if "assister" is -1 -// short kill_streak_total Kill streak count (level) -// short kill_streak_wep Kill streak for killing weapon -// short kill_streak_assist Kill streak for assister count -// short kill_streak_victim Victims kill streak -// short ducks_streaked Duck streak increment from this kill -// short duck_streak_total Duck streak count for attacker -// short duck_streak_assist Duck streak count for assister -// short duck_streak_victim (former) duck streak count for victim -// bool rocket_jump was the victim rocket jumping -// short weapon_def_index item def index of weapon killer used -// short crit_type Crit type of kill. (0: None, 1: Mini, 2: Full) - -// #[forwards] -// pub struct ShrimpStatsTF2ExtensionForward{ -// #[global_forward("player_death", ExecType::Hook)] -// pub player_death: fn(userid: i32, victim_entindex: i32, inflictor_entindex: i32, attacker: i32, weapon: , weaponid: i32, damagebits: i32, customkill: i32, assister: i32, weapon_logclassname: String, stun_flags: i32, death_flags: u8, silent_kill: bool, playerpenetratecount: u8, assister_fallback: String, kill_streak_total: u8, kill_streak_wep: u8, kill_streak_assist: u8, kill_streak_victim: u8, ducks_streaked: u8, duck_streak_total: u8, duck_streak_assist: u8, duck_streak_victim: u8, rocket_jump: bool, weapon_def_index: i32, crit_type: u8) -// } impl IExtensionInterface for ShrimpStatsTF2Extension { - fn on_extension_load(&mut self, _me: IExtension, _sys: IShareSys, _late: bool) -> Result<(), Box> { + fn on_extension_load(&mut self, me: IExtension, sys: IShareSys, late: bool) -> Result<(), Box> { + println!(">>> Rusty extension loaded! me = {:?}, sys = {:?}, late = {:?}", me, sys, late); + + let forward_manager: IForwardManager = sys.request_interface(&me)?; + println!(">>> Got interface: {:?} v{:?}", forward_manager.get_interface_name(), forward_manager.get_interface_version()); Ok(()) }