oberien / refunct-tas

Tool for Tool assisted Speedruns for the game Refunct
31 stars 8 forks source link

Fix arg type in `FName::from` function #307

Closed LukeSaward1 closed 9 months ago

LukeSaward1 commented 9 months ago

Currently when it is called, it will crash due to the wrong argument type being specified. Specifically, it should be an enum called EFindName, which looks like this:

enum EFindName {
    FNAME_FIND,
    FNAME_ADD,
}

The enum value we want is EFindName::FNAME_FIND.

The function with this type will be as follows:

impl<T: Into<FString>> From<T> for FName {
    fn from(s: T) -> FName {
        let s = s.into();
        let mut name = FName::NAME_None;
        unsafe {
            let fun: extern_fn!(fn(this: *mut FName, name: *const TCHAR, find_type: EFindName) -> u64)
                = mem::transmute(FNAME_FNAME.load(Ordering::SeqCst));
            fun(&mut name as *mut FName, s.as_ptr(), EFindName::FNAME_FIND);
        }
        name
    }
}