MCPcopy Create free account
hub / github.com/TanTanDev/runity / api_init_game_lib

Function api_init_game_lib

rust/runity/src/api.rs:29–62  ·  view source on GitHub ↗
(lib_name: *const c_char)

Source from the content-addressed store, hash-verified

27}
28
29#[no_mangle] pub extern fn api_init_game_lib(lib_name: *const c_char) {
30 info!("api init game lib...");
31 let mut api = API.lock().unwrap();
32
33 // FIREHOSE for unity editor.
34 // recreate bevy app to reset the bevy world
35 api.game.app = shared::bevy_app_syncable::App::default();
36
37 let c_str = unsafe {
38 if lib_name.is_null() {
39 error!("library name STR PTR is null! ABORTING LIBRARY LOADING");
40 return;
41 }
42 CStr::from_ptr(lib_name)
43 };
44 let lib_name = match c_str.to_str() {
45 Ok(r_str) => {
46 r_str
47 },
48 Err(utf_err) => {
49 error!("can't convert c# string to rust reason: {:?}\n ABORTING LIBRARY LOADING", utf_err);
50 return;
51 }
52 };
53 let library_creation_result = api.game.init_library(lib_name);
54 if let Err(err) = library_creation_result {
55 match err {
56 crate::game::GameCreationError::DllLoadError(err) => {
57 error!("{}", format!("failed to load library: {:?}. Reason: {:?}", lib_name, err).to_string());
58 drop(err);
59 },
60 }
61 }
62}
63
64
65#[no_mangle] pub extern fn api_init(unity_log_level: LevelFilter, writer_log_level: LevelFilter) {

Callers 1

ApiMethod · 0.85

Calls 1

init_libraryMethod · 0.80

Tested by

no test coverage detected