rust/lib-hedgewars-engine/src/lib.rs
changeset 15919 d52f5d8e75e6
parent 15797 95402fa4e191
child 15921 5b3beb90e1a6
--- a/rust/lib-hedgewars-engine/src/lib.rs	Sat Nov 12 15:40:20 2022 +0100
+++ b/rust/lib-hedgewars-engine/src/lib.rs	Sat Nov 12 21:12:14 2022 +0100
@@ -5,10 +5,11 @@
 mod world;
 
 use std::{
-    ffi::CString,
+    ffi::{CString, CStr},
     io::{Read, Write},
     mem::replace,
     os::raw::{c_char, c_void},
+    path::Path,
 };
 
 use integral_geometry::Point;
@@ -87,8 +88,10 @@
 }
 
 #[no_mangle]
-pub extern "C" fn start_engine() -> *mut EngineInstance {
-    let engine_state = Box::new(EngineInstance::new());
+pub extern "C" fn start_engine(data_path: *const i8) -> *mut EngineInstance {
+    let data_path: &str = unsafe { CStr::from_ptr(data_path) }.to_str().unwrap();
+
+    let engine_state = Box::new(EngineInstance::new(Path::new(&data_path)));
 
     Box::leak(engine_state)
 }