Style and Clippy fixes.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -3,22 +3,27 @@ use crate::ffi::{ExternPointer, OwnedPtr};
|
||||
use crate::static_data::{GrowthRate, LookupGrowthRate};
|
||||
use std::ptr::drop_in_place;
|
||||
|
||||
/// Instantiates a new lookup growth rate. The experience array should be the amount of experience
|
||||
/// required per level, with the first element being the experience required for level 1 (generally 0).
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn growth_rate_lookup_new(array: *const u32, length: usize) -> OwnedPtr<Box<dyn GrowthRate>> {
|
||||
let array = std::slice::from_raw_parts(array, length);
|
||||
Box::into_raw(Box::new(Box::new(LookupGrowthRate::new(array.to_vec()))))
|
||||
}
|
||||
|
||||
/// Drops the growth rate.
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn growth_rate_lookup_drop(ptr: OwnedPtr<Box<dyn GrowthRate>>) {
|
||||
drop_in_place(ptr)
|
||||
}
|
||||
|
||||
/// Calculate the level something with this growth rate would have at a certain experience.
|
||||
#[no_mangle]
|
||||
extern "C" fn growth_rate_calculate_level(ptr: ExternPointer<Box<dyn GrowthRate>>, experience: u32) -> LevelInt {
|
||||
ptr.as_ref().calculate_level(experience)
|
||||
}
|
||||
|
||||
/// Calculate the experience something with this growth rate would have at a certain level.
|
||||
#[no_mangle]
|
||||
extern "C" fn growth_rate_calculate_experience(ptr: ExternPointer<Box<dyn GrowthRate>>, level: LevelInt) -> u32 {
|
||||
ptr.as_ref().calculate_experience(level)
|
||||
|
||||
Reference in New Issue
Block a user