diff --git a/Cargo.lock b/Cargo.lock index 499b21b..0a9d0e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "bitflags" @@ -16,9 +16,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "cfg-if" @@ -28,9 +28,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "lock_api" @@ -44,9 +44,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "once_cell" @@ -79,18 +79,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -108,7 +108,7 @@ dependencies = [ name = "rrplug" version = "4.0.0" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "log", "once_cell", "parking_lot", @@ -134,15 +134,15 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "syn" -version = "2.0.48" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -151,18 +151,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", @@ -182,7 +182,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ "windows-core", - "windows-targets 0.52.0", + "windows-targets 0.52.5", ] [[package]] @@ -191,7 +191,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.5", ] [[package]] @@ -211,17 +211,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -232,9 +233,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -244,9 +245,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -256,9 +257,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -268,9 +275,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -280,9 +287,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -292,9 +299,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -304,6 +311,6 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/examples/squirrel_example.rs b/examples/squirrel_example.rs index 8d26847..4d7ab42 100644 --- a/examples/squirrel_example.rs +++ b/examples/squirrel_example.rs @@ -26,7 +26,7 @@ entry!(ExamplePlugin); fn great_person(function: SQHandle) -> Result { // non type safe way of getting a return from a function // this could be changed if the crate gets some attention - let name = call_sq_object_function(sqvm, sq_functions, function)?; + let name = call_sq_object_function(sqvm, sq_functions, function, ())?; log::info!("hello, {}", name); diff --git a/src/bindings/class_types/cplayer.rs b/src/bindings/class_types/cplayer.rs index e03dba3..f665eb1 100644 --- a/src/bindings/class_types/cplayer.rs +++ b/src/bindings/class_types/cplayer.rs @@ -92,7 +92,6 @@ offset_struct! { vec_abs_origin: Vector3 where offset(0x100490), is_performing_boost_action: bool where offset(0x25BE), zipline_valid3p_weapon_layer_anim: bool where offset(0x240C), - player_script_net_data_global: i32 where offset(0x345C), zooming: i32 where offset(0x1598), // this is like a bool but a i32. what? zoom_toggle_on: bool where offset(0x1599), zoom_base_frac: f32 where offset(0x159C), @@ -101,6 +100,9 @@ offset_struct! { camo_index: i32 where offset(0xA04), decal_index: i32 where offset(0xA08), team: i32 where offset(0x5E4), + current_command: *const c_void where offset(0x21d8), + player_script_net_data_global: i32 where offset(0x345c), + player_script_net_data_exclusive: i32 where offset(0x3460), } } diff --git a/src/bindings/squirrelclasstypes.rs b/src/bindings/squirrelclasstypes.rs index c0ca3c8..599d65e 100644 --- a/src/bindings/squirrelclasstypes.rs +++ b/src/bindings/squirrelclasstypes.rs @@ -275,7 +275,7 @@ impl TryFrom for ScriptContext { fn try_from(value: i32) -> Result { if value <= Self::UI as i32 && value >= Self::SERVER as i32 { - Ok(unsafe { std::mem::transmute(value) }) + Ok(unsafe { std::mem::transmute::(value) }) } else { Err(value) } @@ -396,3 +396,5 @@ pub type RegisterSquirrelFuncType_External = unsafe extern "C" fn( funcReg: *mut SQFuncRegistration, unknown: ::std::os::raw::c_char, ) -> i64; +pub type sq_createscriptinstanceType = + unsafe extern "C" fn(ent: *mut ::std::os::raw::c_void) -> *mut SQObject; diff --git a/src/bindings/squirreldatatypes.rs b/src/bindings/squirreldatatypes.rs index d5b3126..4f73876 100644 --- a/src/bindings/squirreldatatypes.rs +++ b/src/bindings/squirreldatatypes.rs @@ -1518,7 +1518,6 @@ fn bindgen_test_layout_SQArray() { ); } #[repr(C)] -#[derive(Copy, Clone)] pub struct HSquirrelVM { pub vftable: *mut ::std::os::raw::c_void, pub uiRef: ::std::os::raw::c_int, diff --git a/src/bindings/squirrelfunctions.rs b/src/bindings/squirrelfunctions.rs index 4d08c15..f586cc7 100644 --- a/src/bindings/squirrelfunctions.rs +++ b/src/bindings/squirrelfunctions.rs @@ -46,6 +46,7 @@ offset_functions! { sq_get_entity_constant_cbase_entity = sq_GetEntityConstantType where offset(0x418AF0); sq_getentityfrominstance = sq_getentityfrominstanceType where offset(0x1E920); + sq_create_script_instance = sq_createscriptinstanceType where offset(0x43f2f0); sq_getfunction = sq_getfunctionType where offset(0x6c80); sq_stackinfos = sq_stackinfosType where offset(0x35920); @@ -100,6 +101,7 @@ offset_functions! { sq_get_entity_constant_cbase_entity = sq_GetEntityConstantType where offset(0x3E49B0); sq_getentityfrominstance = sq_getentityfrominstanceType where offset(0x114F0); + sq_create_script_instance = sq_createscriptinstanceType where offset(0xc20e0); sq_getfunction = sq_getfunctionType where offset(0x06cb0); sq_stackinfos = sq_stackinfosType where offset(0x35970); @@ -147,6 +149,7 @@ pub struct SquirrelFunctions { pub sq_getfunction: sq_getfunctionType, pub sq_getentityfrominstance: sq_getentityfrominstanceType, pub sq_get_entity_constant_cbase_entity: sq_GetEntityConstantType, + pub sq_create_script_instance: sq_createscriptinstanceType, pub sq_pushnewstructinstance: sq_pushnewstructinstanceType, pub sq_sealstructslot: sq_sealstructslotType, } @@ -189,6 +192,7 @@ impl From<&ClientSQFunctions> for SquirrelFunctions { sq_getfunction: val.sq_getfunction, sq_getentityfrominstance: val.sq_getentityfrominstance, sq_get_entity_constant_cbase_entity: val.sq_get_entity_constant_cbase_entity, + sq_create_script_instance: val.sq_create_script_instance, sq_pushnewstructinstance: val.sq_pushnewstructinstance, sq_sealstructslot: val.sq_sealstructslot, } @@ -233,6 +237,7 @@ impl From<&ServerSQFunctions> for SquirrelFunctions { sq_getfunction: val.sq_getfunction, sq_getentityfrominstance: val.sq_getentityfrominstance, sq_get_entity_constant_cbase_entity: val.sq_get_entity_constant_cbase_entity, + sq_create_script_instance: val.sq_create_script_instance, sq_pushnewstructinstance: val.sq_pushnewstructinstance, sq_sealstructslot: val.sq_sealstructslot, } diff --git a/src/high/engine/convars.rs b/src/high/engine/convars.rs index 44e8b8c..d59395d 100644 --- a/src/high/engine/convars.rs +++ b/src/high/engine/convars.rs @@ -59,7 +59,7 @@ use std::{ alloc::{GlobalAlloc, Layout}, borrow::Cow, - ffi::{c_char, CStr}, + ffi::{c_char, c_void, CStr}, mem, ptr::addr_of_mut, }; @@ -228,7 +228,7 @@ impl ConVarStruct { .write(convar_classes.iconvar_vtable); #[allow(clippy::crosspointer_transmute)] // its what c++ this->convar_malloc is - (convar_classes.convar_malloc)(mem::transmute(addr_of_mut!((*convar).m_pMalloc)), 0, 0); // Allocate new memory for ConVar. + (convar_classes.convar_malloc)(addr_of_mut!((*convar).m_pMalloc).cast(), 0, 0); // Allocate new memory for ConVar. convar }; @@ -426,7 +426,7 @@ impl ConVarStruct { let set_value_int = vtable_array[14]; // the index for SetValue for ints; weird stuff - let func = mem::transmute::<_, fn(*const ConVar, i32)>(set_value_int); + let func = mem::transmute::<*const c_void, fn(*const ConVar, i32)>(set_value_int); func(self.inner, new_value) } @@ -449,7 +449,7 @@ impl ConVarStruct { let set_value_float = vtable_array[13]; // the index for SetValue for floats; weird stuff - let func = mem::transmute::<_, fn(*const ConVar, f32)>(set_value_float); + let func = mem::transmute::<*const c_void, fn(*const ConVar, f32)>(set_value_float); func(self.inner, new_value) } @@ -469,7 +469,8 @@ impl ConVarStruct { let set_value_string = vtable_array[12]; // the index for SetValue for strings; weird stuff - let func = mem::transmute::<_, fn(*const ConVar, *const c_char)>(set_value_string); + let func = + mem::transmute::<*const c_void, fn(*const ConVar, *const c_char)>(set_value_string); let string_value = to_cstring(new_value.as_ref()); func(self.inner, string_value.as_ptr()) diff --git a/src/high/squirrel.rs b/src/high/squirrel.rs index 6af1a7d..cb33810 100644 --- a/src/high/squirrel.rs +++ b/src/high/squirrel.rs @@ -271,10 +271,11 @@ pub fn register_sq_functions(get_info_func: FuncSQFuncInfo) { /// Ok(()) /// } /// ``` -pub fn call_sq_function( +pub fn call_sq_function( sqvm: NonNull, sqfunctions: &'static SquirrelFunctions, function_name: impl AsRef, + args: A, ) -> Result { let mut obj = std::mem::MaybeUninit::::zeroed(); let ptr = obj.as_mut_ptr(); @@ -288,9 +289,9 @@ pub fn call_sq_function( if result != 0 { Err(CallError::FunctionNotFound( function_name.to_string_lossy().into(), - )) // totaly safe :clueless: + )) } else { - _call_sq_object_function(sqvm, sqfunctions, ptr) + _call_sq_object_function(sqvm, sqfunctions, ptr, args) } } @@ -317,31 +318,38 @@ pub fn call_sq_function( /// Ok(()) /// } /// ``` -pub fn call_sq_object_function( +pub fn call_sq_object_function( sqvm: NonNull, sqfunctions: &'static SquirrelFunctions, mut obj: SQHandle, + args: A, ) -> Result { - _call_sq_object_function(sqvm, sqfunctions, obj.as_callable()) + _call_sq_object_function(sqvm, sqfunctions, obj.as_callable(), args) } #[inline] -fn _call_sq_object_function( +fn _call_sq_object_function( mut sqvm: NonNull, sqfunctions: &'static SquirrelFunctions, ptr: *mut SQObject, + args: A, ) -> Result { unsafe { - let sqvm = sqvm.as_mut(); - (sqfunctions.sq_pushobject)(sqvm, ptr); - (sqfunctions.sq_pushroottable)(sqvm); + let sqvm_ref = sqvm.as_mut(); + (sqfunctions.sq_pushobject)(sqvm_ref, ptr); + (sqfunctions.sq_pushroottable)(sqvm_ref); - if (sqfunctions.sq_call)(sqvm, 1, true as u32, true as u32) == SQRESULT::SQRESULT_ERROR { + let amount = args.into_push(sqvm, sqfunctions); + + if (sqfunctions.sq_call)(sqvm_ref, amount + 1, true as u32, true as u32) + == SQRESULT::SQRESULT_ERROR + { Err(CallError::FunctionFailedToExecute) } else { Ok(R::get_from_sqobject( - sqvm._stack - .add(sqvm._top as usize - 1) + sqvm_ref + ._stack + .add(sqvm_ref._top as usize - 1) .as_ref() .ok_or(CallError::FunctionFailedToExecute)?, )) diff --git a/src/high/squirrel_traits.rs b/src/high/squirrel_traits.rs index 0d61e19..cde5087 100644 --- a/src/high/squirrel_traits.rs +++ b/src/high/squirrel_traits.rs @@ -27,6 +27,8 @@ use crate::{ prelude::*, }; +use super::UnsafeHandle; + // Push Trait macro_rules! push_to_sqvm { @@ -81,6 +83,32 @@ impl PushToSquirrelVm for () { fn push_to_sqvm(self, _: NonNull, _: &SquirrelFunctions) {} } +impl PushToSquirrelVm for &CPlayer { + /// SAFETY: the object is stored inside the entity and the entity is not being modified + fn push_to_sqvm(self, sqvm: NonNull, sqfunctions: &SquirrelFunctions) { + unsafe { + let obj = + (sqfunctions.sq_create_script_instance)((self as *const CPlayer).cast_mut().cast()); + (sqfunctions.sq_pushobject)(sqvm.as_ptr(), obj); + } + } +} + +impl PushToSquirrelVm for [T; N] { + fn push_to_sqvm(self, sqvm: NonNull, sqfunctions: &SquirrelFunctions) { + push_sq_array(sqvm, sqfunctions, self); + } +} + +impl PushToSquirrelVm for UnsafeHandle +where + T: PushToSquirrelVm, +{ + fn push_to_sqvm(self, sqvm: NonNull, sqfunctions: &SquirrelFunctions) { + self.take().push_to_sqvm(sqvm, sqfunctions) + } +} + // Return Trait /// trait to return diffrent values to the sqvm from a native closure @@ -141,7 +169,7 @@ impl ReturnToVm for T { // IntoSquirrelArgs Trait /// closure that simplies pushing groups of items to the squirrel vm; asynchronously or immediately -pub trait IntoSquirrelArgs: Sync + Send { +pub trait IntoSquirrelArgs { /// converts a implemenator of this trait into a closure that pushes it to the squirrel stack when ran fn into_function( self, diff --git a/src/high/vector.rs b/src/high/vector.rs index f08bbe2..965dd00 100644 --- a/src/high/vector.rs +++ b/src/high/vector.rs @@ -78,7 +78,7 @@ impl From for Vector3 { impl From<*const SQObject> for Vector3 { #[inline] fn from(value: *const SQObject) -> Self { - unsafe { std::mem::transmute::<_, SQVector>(*value) }.into() + unsafe { std::mem::transmute::(*value) }.into() } } diff --git a/src/interfaces/external.rs b/src/interfaces/external.rs index 44656d9..a38e47b 100644 --- a/src/interfaces/external.rs +++ b/src/interfaces/external.rs @@ -73,6 +73,7 @@ macro_rules! create_external_interface { $func_vis unsafe fn $name( &self, $($arg_name: $arg,)* ) -> $output { use $crate::interfaces::external::SourceInterface; use std::ffi::c_void; + #[allow(clippy::missing_transmute_annotations)] unsafe { (std::mem::transmute::<_,unsafe extern "C" fn(*const c_void, $($arg),*) -> $output>(self.get_func($mod_name::Counter::$name as usize)))( self as *const Self as *const c_void, $($arg_name),* ) } @@ -106,6 +107,7 @@ pub trait SourceInterface { ) -> Result<&'static Rtrn, InterfaceGetterError<'_>> { let mut status = MaybeUninit::uninit(); unsafe { + #[allow(clippy::missing_transmute_annotations)] let create_interface = std::mem::transmute::<_, CreateInterface>( GetProcAddress(dll_ptr, PCSTR("CreateInterface\0".as_ptr())).ok_or( InterfaceGetterError::NullCreateInterface(dll_ptr.0 as usize), @@ -133,6 +135,7 @@ pub trait SourceInterface { let mut status = MaybeUninit::uninit(); unsafe { let dll_name = try_cstring(dll_name)?; + #[allow(clippy::missing_transmute_annotations)] let create_interface = std::mem::transmute::<_, CreateInterface>( GetProcAddress( GetModuleHandleA(PCSTR(dll_name.as_ptr() as *const u8))?, diff --git a/src/macros/utils.rs b/src/macros/utils.rs index ceac71b..882b5b6 100644 --- a/src/macros/utils.rs +++ b/src/macros/utils.rs @@ -49,6 +49,7 @@ macro_rules! impl_vmethod { use std::ffi::c_void; let func = (*(self.vtable as *const [usize;u32::MAX as usize]))[$offset]; + #[allow(clippy::missing_transmute_annotations)] (std::mem::transmute::<_,unsafe extern "C" fn(*const c_void, $($arg,)*) -> $output>(func)) ( self as *const _ as *const c_void, @@ -66,6 +67,7 @@ macro_rules! impl_vmethod { use std::ffi::c_void; let func = (**(self.class as *const *const [usize;u32::MAX as usize]))[$offset]; + #[allow(clippy::missing_transmute_annotations)] (std::mem::transmute::<_,unsafe extern "C" fn(*const c_void, $($arg,)*) -> $output>(func)) ( self.class as *const c_void, @@ -83,6 +85,7 @@ macro_rules! impl_vmethod { use std::ffi::c_void; let func = (*(**self.vtable as *const [usize;u32::MAX as usize]))[$offset]; + #[allow(clippy::missing_transmute_annotations)] (std::mem::transmute::<_,unsafe extern "C" fn(*const c_void, $($arg,)*) -> $output>(func)) ( self as *const _ as *const c_void, @@ -164,6 +167,7 @@ macro_rules! offset_functions { _ = static_var.set( unsafe { Self { $( + #[allow(clippy::missing_transmute_annotations)] $name: std::mem::transmute(dll.offset( $addr )), // transmute is used since it's easier but a lot more unsafe so yeah )* } diff --git a/src/mid/source_alloc.rs b/src/mid/source_alloc.rs index f7579d3..91f316d 100644 --- a/src/mid/source_alloc.rs +++ b/src/mid/source_alloc.rs @@ -26,6 +26,7 @@ pub struct SourceAlloc(OnceCell>); impl SourceAlloc { pub(crate) fn init(&self) { let create_global_mem_alloc = unsafe { + #[allow(clippy::missing_transmute_annotations)] std::mem::transmute::<_, CreateGlobalMemAlloc>( GetProcAddress( GetModuleHandleA(PCSTR("tier0.dll\0".as_ptr())).expect("couldn't find tier0"), diff --git a/src/mid/squirrel.rs b/src/mid/squirrel.rs index fb8cdcb..671ecce 100644 --- a/src/mid/squirrel.rs +++ b/src/mid/squirrel.rs @@ -173,7 +173,7 @@ pub unsafe fn sqvm_to_context(sqvm: NonNull) -> ScriptContext { pub fn push_sq_array( sqvm: NonNull, sqfunctions: &SquirrelFunctions, - arguments: Vec, + arguments: impl IntoIterator, ) where T: PushToSquirrelVm, {