rust/lib-hwengine-future/src/lib.rs
changeset 16117 cb472e3d0dd4
parent 16102 5d302b12d837
equal deleted inserted replaced
16115:ee8b894272d0 16117:cb472e3d0dd4
     1 mod ai;
     1 mod ai;
     2 
     2 
     3 use integral_geometry::{Point, Size};
     3 use integral_geometry::{Point, Size};
       
     4 use core::ffi::c_char;
     4 
     5 
     5 use ai::*;
     6 use ai::*;
     6 use landgen::{
     7 use landgen::{
     7     maze::MazeTemplate, outline_template_based::outline_template::OutlineTemplate,
     8     maze::MazeTemplate, outline_template_based::outline_template::OutlineTemplate,
     8     wavefront_collapse::generator::TemplateDescription as WfcTemplate, LandGenerationParameters,
     9     wavefront_collapse::generator::TemplateDescription as WfcTemplate, LandGenerationParameters,
    48 }
    49 }
    49 
    50 
    50 #[no_mangle]
    51 #[no_mangle]
    51 pub unsafe extern "C" fn generate_outline_templated_game_field(
    52 pub unsafe extern "C" fn generate_outline_templated_game_field(
    52     feature_size: u32,
    53     feature_size: u32,
    53     seed: *const i8,
    54     seed: *const c_char,
    54     template_type: *const i8,
    55     template_type: *const c_char,
    55     data_path: *const i8,
    56     data_path: *const c_char,
    56 ) -> *mut GameField {
    57 ) -> *mut GameField {
    57     let data_path: &str = CStr::from_ptr(data_path).to_str().unwrap();
    58     let data_path: &str = CStr::from_ptr(data_path).to_str().unwrap();
    58     let data_path = Path::new(&data_path);
    59     let data_path = Path::new(&data_path);
    59 
    60 
    60     let seed: &str = CStr::from_ptr(seed).to_str().unwrap();
    61     let seed: &str = CStr::from_ptr(seed).to_str().unwrap();
    88 }
    89 }
    89 
    90 
    90 #[no_mangle]
    91 #[no_mangle]
    91 pub unsafe extern "C" fn generate_wfc_templated_game_field(
    92 pub unsafe extern "C" fn generate_wfc_templated_game_field(
    92     feature_size: u32,
    93     feature_size: u32,
    93     seed: *const i8,
    94     seed: *const c_char,
    94     template_type: *const i8,
    95     template_type: *const c_char,
    95     data_path: *const i8,
    96     data_path: *const c_char,
    96 ) -> *mut GameField {
    97 ) -> *mut GameField {
    97     let data_path: &str = CStr::from_ptr(data_path).to_str().unwrap();
    98     let data_path: &str = CStr::from_ptr(data_path).to_str().unwrap();
    98     let data_path = Path::new(&data_path);
    99     let data_path = Path::new(&data_path);
    99 
   100 
   100     let seed: &str = CStr::from_ptr(seed).to_str().unwrap();
   101     let seed: &str = CStr::from_ptr(seed).to_str().unwrap();
   133 }
   134 }
   134 
   135 
   135 #[no_mangle]
   136 #[no_mangle]
   136 pub unsafe extern "C" fn generate_maze_game_field(
   137 pub unsafe extern "C" fn generate_maze_game_field(
   137     feature_size: u32,
   138     feature_size: u32,
   138     seed: *const i8,
   139     seed: *const c_char,
   139     template_type: *const i8,
   140     template_type: *const c_char,
   140     data_path: *const i8,
   141     data_path: *const c_char,
   141 ) -> *mut GameField {
   142 ) -> *mut GameField {
   142     let data_path: &str = CStr::from_ptr(data_path).to_str().unwrap();
   143     let data_path: &str = CStr::from_ptr(data_path).to_str().unwrap();
   143     let data_path = Path::new(&data_path);
   144     let data_path = Path::new(&data_path);
   144 
   145 
   145     let seed: &str = CStr::from_ptr(seed).to_str().unwrap();
   146     let seed: &str = CStr::from_ptr(seed).to_str().unwrap();
   176 }
   177 }
   177 
   178 
   178 #[no_mangle]
   179 #[no_mangle]
   179 pub unsafe extern "C" fn apply_theme(
   180 pub unsafe extern "C" fn apply_theme(
   180     game_field: &mut GameField,
   181     game_field: &mut GameField,
   181     data_path: *const i8,
   182     data_path: *const c_char,
   182     theme_name: *const i8,
   183     theme_name: *const c_char,
   183 ) {
   184 ) {
   184     let data_path: &str = CStr::from_ptr(data_path).to_str().unwrap();
   185     let data_path: &str = CStr::from_ptr(data_path).to_str().unwrap();
   185     let data_path = Path::new(&data_path);
   186     let data_path = Path::new(&data_path);
   186 
   187 
   187     let theme_name: &str = CStr::from_ptr(theme_name).to_str().unwrap();
   188     let theme_name: &str = CStr::from_ptr(theme_name).to_str().unwrap();