use crate::defines::LevelInt; use crate::ffi::{ExternPointer, OwnedPtr}; use crate::static_data::{GrowthRate, LookupGrowthRate}; use std::ptr::drop_in_place; #[no_mangle] unsafe extern "C" fn growth_rate_lookup_new(array: *const u32, length: usize) -> OwnedPtr> { let array = std::slice::from_raw_parts(array, length); Box::into_raw(Box::new(Box::new(LookupGrowthRate::new(array.to_vec())))) } #[no_mangle] unsafe extern "C" fn growth_rate_lookup_drop(ptr: OwnedPtr>) { drop_in_place(ptr) } #[no_mangle] extern "C" fn growth_rate_calculate_level(ptr: ExternPointer>, experience: u32) -> LevelInt { ptr.as_ref().calculate_level(experience) } #[no_mangle] extern "C" fn growth_rate_calculate_experience(ptr: ExternPointer>, level: LevelInt) -> u32 { ptr.as_ref().calculate_experience(level) }