From 3e05bd826b9b8f2973a77d300534b0ac14092402 Mon Sep 17 00:00:00 2001 From: Truman Kilen Date: Fri, 7 Jun 2024 14:00:01 -0500 Subject: [PATCH] Allow getting args from kismet that don't impl Default --- hook/src/ue/kismet.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hook/src/ue/kismet.rs b/hook/src/ue/kismet.rs index 1ded4d9..33975f0 100644 --- a/hook/src/ue/kismet.rs +++ b/hook/src/ue/kismet.rs @@ -1,3 +1,5 @@ +use std::mem::MaybeUninit; + use super::*; #[derive(Debug)] @@ -19,19 +21,18 @@ pub struct FFrame { } impl FFrame { - pub fn arg(self: &mut FFrame) -> T { - let mut ret: T = Default::default(); - unsafe { - let ptr = &mut ret as *mut T as *mut _; + pub unsafe fn arg(self: &mut FFrame) -> T { + let mut value: MaybeUninit = MaybeUninit::zeroed(); + let ptr = value.as_mut_ptr() as *mut _; - if self.code.is_null() { - let cur = self.property_chain_for_compiled_in; - self.property_chain_for_compiled_in = (*cur).next; - (globals().fframe_step_explicit_property())(self, ptr, cur as *const FProperty); - } else { - (globals().fframe_step())(self, self.object, ptr); - } + if self.code.is_null() { + let cur = self.property_chain_for_compiled_in; + self.property_chain_for_compiled_in = (*cur).next; + (globals().fframe_step_explicit_property())(self, ptr, cur as *const FProperty); + } else { + (globals().fframe_step())(self, self.object, ptr); } - ret + + value.assume_init() } }