1#![feature(nonpoison_mutex, sync_nonpoison)]
5#![expect(clippy::missing_safety_doc)]
6
7mod client;
8mod json;
9mod macros;
10mod queue;
11mod request;
12mod response;
13mod runtime;
14mod server;
15mod status;
16
17use crate::runtime::RUNTIME;
18use crate::server::SERVER;
19use client::CLIENT;
20use futures::future::BoxFuture;
21use json::serialize;
22use nil_core::event::Event;
23use std::ffi::{CString, c_char};
24use std::ptr;
25use tap::TryConv;
26
27pub use request::RequestId;
28pub use response::{Response, Result};
29pub use status::Status;
30
31#[unsafe(no_mangle)]
36pub unsafe extern "C" fn nil_ffi_free_str(ptr: *mut c_char) {
37 if !ptr.is_null() {
38 drop(unsafe { CString::from_raw(ptr) });
39 }
40}
41
42#[unsafe(no_mangle)]
43pub unsafe extern "C" fn nil_ffi_poll(json_out: *mut *mut c_char) -> Status {
44 if json_out.is_null() {
45 return Status::ERR_NULL_POINTER;
46 }
47
48 unsafe { *json_out = ptr::null_mut() };
49
50 match queue::poll() {
51 Some(entry) => {
52 match serialize(&entry) {
53 Ok(json) => {
54 let json = CString::new(json).unwrap();
55 unsafe { *json_out = json.into_raw() };
56 Status::OK
57 }
58 Err(_) => Status::ERR_SERIALIZATION,
59 }
60 }
61 None => Status::ERR_NOTHING_TO_POLL,
62 }
63}
64
65#[unsafe(no_mangle)]
66pub unsafe extern "C" fn nil_ffi_shutdown() {
67 queue::clear();
68}
69
70#[unsafe(no_mangle)]
71pub unsafe extern "C" fn nil_ffi_version(request_id: RequestId) {
72 push_ok!(request_id, env!("CARGO_PKG_VERSION"));
73}
74
75#[unsafe(no_mangle)]
80pub unsafe extern "C" fn nil_is_host(request_id: RequestId) {
81 async_push_ok!(request_id, SERVER.read().await.is_some());
82}
83
84#[unsafe(no_mangle)]
86pub unsafe extern "C" fn nil_start_server(request_id: RequestId, json_options: *const c_char) {
87 let f = |options| {
88 RUNTIME.spawn(async move {
89 let result = server::start_with_options(options).await;
90 queue::push_result(request_id, Result::from(result));
91 });
92 };
93
94 unsafe { json::with_ptr(request_id, json_options, f) };
95}
96
97#[unsafe(no_mangle)]
99pub unsafe extern "C" fn nil_start_server_with_savedata(
100 request_id: RequestId,
101 json_path: *const c_char,
102) {
103 let f = |path| {
104 RUNTIME.spawn(async move {
105 let result = server::start_with_savedata(path).await;
106 queue::push_result(request_id, Result::from(result));
107 });
108 };
109
110 unsafe { json::with_ptr(request_id, json_path, f) };
111}
112
113#[unsafe(no_mangle)]
115pub unsafe extern "C" fn nil_stop_server(request_id: RequestId) {
116 RUNTIME.spawn(async move {
117 server::stop().await;
118 queue::push_ok(request_id, ());
119 });
120}
121
122#[unsafe(no_mangle)]
127pub unsafe extern "C" fn nil_client_version(request_id: RequestId) {
128 push_ok!(request_id, nil_client::VERSION);
129}
130
131#[unsafe(no_mangle)]
133pub unsafe extern "C" fn nil_is_local(request_id: RequestId) {
134 async_push_ok!(request_id, CLIENT.read().await.is_local());
135}
136
137#[unsafe(no_mangle)]
139pub unsafe extern "C" fn nil_is_ready(request_id: RequestId) {
140 async_push_ok!(request_id, CLIENT.read().await.is_ready().await);
141}
142
143#[unsafe(no_mangle)]
145pub unsafe extern "C" fn nil_is_remote(request_id: RequestId) {
146 async_push_ok!(request_id, CLIENT.read().await.is_remote());
147}
148
149#[unsafe(no_mangle)]
151pub unsafe extern "C" fn nil_server_addr(request_id: RequestId) {
152 async_push_ok!(request_id, CLIENT.read().await.server_addr());
153}
154
155#[unsafe(no_mangle)]
157pub unsafe extern "C" fn nil_set_user_agent(request_id: RequestId, json_user_agent: *const c_char) {
158 let f = |user_agent: String| {
159 RUNTIME.spawn(async move {
160 CLIENT
161 .write()
162 .await
163 .set_user_agent(&user_agent);
164
165 queue::push_ok(request_id, ());
166 });
167 };
168
169 unsafe { json::with_ptr(request_id, json_user_agent, f) };
170}
171
172#[unsafe(no_mangle)]
174pub unsafe extern "C" fn nil_stop_client(request_id: RequestId) {
175 RUNTIME.spawn(async move {
176 CLIENT.write().await.stop().await;
177 queue::push_ok(request_id, ());
178 });
179}
180
181#[unsafe(no_mangle)]
183pub unsafe extern "C" fn nil_update_client(request_id: RequestId, json_options: *const c_char) {
184 let f = |options| {
185 type OnEvent = fn(Event) -> BoxFuture<'static, ()>;
186 RUNTIME.spawn(async move {
187 let result = CLIENT
188 .write()
189 .await
190 .update(options, None::<OnEvent>)
191 .await;
192
193 queue::push_result(request_id, Result::from(result));
194 });
195 };
196
197 unsafe { json::with_ptr(request_id, json_options, f) };
198}
199
200#[unsafe(no_mangle)]
202pub unsafe extern "C" fn nil_user_agent(request_id: RequestId) {
203 async_push_ok!(request_id, CLIENT.read().await.user_agent().to_owned());
204}
205
206#[unsafe(no_mangle)]
208pub unsafe extern "C" fn nil_world(request_id: RequestId) {
209 RUNTIME.spawn(async move {
210 match CLIENT.read().await.world() {
211 Some(world) => queue::push_ok(request_id, world),
212 None => queue::push_ok(request_id, None::<&str>),
213 }
214 });
215}
216
217#[unsafe(no_mangle)]
223pub unsafe extern "C" fn nil_runtime_global_queue_depth(request_id: RequestId) {
224 push_result!(
225 request_id,
226 RUNTIME
227 .metrics()
228 .global_queue_depth()
229 .try_conv::<u32>()
230 );
231}
232
233#[unsafe(no_mangle)]
235pub unsafe extern "C" fn nil_runtime_num_alive_tasks(request_id: RequestId) {
236 push_result!(
237 request_id,
238 RUNTIME
239 .metrics()
240 .num_alive_tasks()
241 .try_conv::<u32>()
242 );
243}
244
245#[unsafe(no_mangle)]
247pub unsafe extern "C" fn nil_runtime_num_workers(request_id: RequestId) {
248 push_result!(
249 request_id,
250 RUNTIME
251 .metrics()
252 .num_workers()
253 .try_conv::<u32>()
254 );
255}
256
257#[unsafe(no_mangle)]
263pub unsafe extern "C" fn nil_add_academy_recruit_order(
264 request_id: RequestId,
265 json_req: *const c_char,
266) {
267 send!(request_id, add_academy_recruit_order, json_req);
268}
269
270#[unsafe(no_mangle)]
272pub unsafe extern "C" fn nil_add_prefecture_build_order(
273 request_id: RequestId,
274 json_req: *const c_char,
275) {
276 send!(request_id, add_prefecture_build_order, json_req);
277}
278
279#[unsafe(no_mangle)]
281pub unsafe extern "C" fn nil_add_stable_recruit_order(
282 request_id: RequestId,
283 json_req: *const c_char,
284) {
285 send!(request_id, add_stable_recruit_order, json_req);
286}
287
288#[unsafe(no_mangle)]
290pub unsafe extern "C" fn nil_add_workshop_recruit_order(
291 request_id: RequestId,
292 json_req: *const c_char,
293) {
294 send!(request_id, add_workshop_recruit_order, json_req);
295}
296
297#[unsafe(no_mangle)]
299pub unsafe extern "C" fn nil_authorize(request_id: RequestId, json_req: *const c_char) {
300 send!(request_id, authorize, json_req);
301}
302
303#[unsafe(no_mangle)]
305pub unsafe extern "C" fn nil_buy_resources(request_id: RequestId, json_req: *const c_char) {
306 send!(request_id, buy_resources, json_req);
307}
308
309#[unsafe(no_mangle)]
311pub unsafe extern "C" fn nil_cancel_academy_recruit_order(
312 request_id: RequestId,
313 json_req: *const c_char,
314) {
315 send!(request_id, cancel_academy_recruit_order, json_req);
316}
317
318#[unsafe(no_mangle)]
320pub unsafe extern "C" fn nil_cancel_maneuver(request_id: RequestId, json_req: *const c_char) {
321 send!(request_id, cancel_maneuver, json_req);
322}
323
324#[unsafe(no_mangle)]
326pub unsafe extern "C" fn nil_cancel_prefecture_build_order(
327 request_id: RequestId,
328 json_req: *const c_char,
329) {
330 send!(request_id, cancel_prefecture_build_order, json_req);
331}
332
333#[unsafe(no_mangle)]
335pub unsafe extern "C" fn nil_cancel_stable_recruit_order(
336 request_id: RequestId,
337 json_req: *const c_char,
338) {
339 send!(request_id, cancel_stable_recruit_order, json_req);
340}
341
342#[unsafe(no_mangle)]
344pub unsafe extern "C" fn nil_cancel_workshop_recruit_order(
345 request_id: RequestId,
346 json_req: *const c_char,
347) {
348 send!(request_id, cancel_workshop_recruit_order, json_req);
349}
350
351#[unsafe(no_mangle)]
353pub unsafe extern "C" fn nil_cheat_fill_world(request_id: RequestId, json_req: *const c_char) {
354 send!(request_id, cheat_fill_world, json_req);
355}
356
357#[unsafe(no_mangle)]
359pub unsafe extern "C" fn nil_cheat_get_academy_recruit_queue(
360 request_id: RequestId,
361 json_req: *const c_char,
362) {
363 send!(request_id, cheat_get_academy_recruit_queue, json_req);
364}
365
366#[unsafe(no_mangle)]
368pub unsafe extern "C" fn nil_cheat_get_academy_recruit_queues(
369 request_id: RequestId,
370 json_req: *const c_char,
371) {
372 send!(request_id, cheat_get_academy_recruit_queues, json_req);
373}
374
375#[unsafe(no_mangle)]
377pub unsafe extern "C" fn nil_cheat_get_all_academy_recruit_queues(
378 request_id: RequestId,
379 json_req: *const c_char,
380) {
381 send!(request_id, cheat_get_all_academy_recruit_queues, json_req);
382}
383
384#[unsafe(no_mangle)]
386pub unsafe extern "C" fn nil_cheat_get_all_prefecture_build_queues(
387 request_id: RequestId,
388 json_req: *const c_char,
389) {
390 send!(request_id, cheat_get_all_prefecture_build_queues, json_req);
391}
392
393#[unsafe(no_mangle)]
395pub unsafe extern "C" fn nil_cheat_get_all_stable_recruit_queues(
396 request_id: RequestId,
397 json_req: *const c_char,
398) {
399 send!(request_id, cheat_get_all_stable_recruit_queues, json_req);
400}
401
402#[unsafe(no_mangle)]
404pub unsafe extern "C" fn nil_cheat_get_build_steps(request_id: RequestId, json_req: *const c_char) {
405 send!(request_id, cheat_get_build_steps, json_req);
406}
407
408#[unsafe(no_mangle)]
410pub unsafe extern "C" fn nil_cheat_get_cities(request_id: RequestId, json_req: *const c_char) {
411 send!(request_id, cheat_get_cities, json_req);
412}
413
414#[unsafe(no_mangle)]
416pub unsafe extern "C" fn nil_cheat_get_city(request_id: RequestId, json_req: *const c_char) {
417 send!(request_id, cheat_get_city, json_req);
418}
419
420#[unsafe(no_mangle)]
422pub unsafe extern "C" fn nil_cheat_get_ethics(request_id: RequestId, json_req: *const c_char) {
423 send!(request_id, cheat_get_ethics, json_req);
424}
425
426#[unsafe(no_mangle)]
428pub unsafe extern "C" fn nil_cheat_get_idle_armies_at(
429 request_id: RequestId,
430 json_req: *const c_char,
431) {
432 send!(request_id, cheat_get_idle_armies_at, json_req);
433}
434
435#[unsafe(no_mangle)]
437pub unsafe extern "C" fn nil_cheat_get_idle_personnel_at(
438 request_id: RequestId,
439 json_req: *const c_char,
440) {
441 send!(request_id, cheat_get_idle_personnel_at, json_req);
442}
443
444#[unsafe(no_mangle)]
446pub unsafe extern "C" fn nil_cheat_get_infrastructure(
447 request_id: RequestId,
448 json_req: *const c_char,
449) {
450 send!(request_id, cheat_get_infrastructure, json_req);
451}
452
453#[unsafe(no_mangle)]
455pub unsafe extern "C" fn nil_cheat_get_maneuvers(request_id: RequestId, json_req: *const c_char) {
456 send!(request_id, cheat_get_maneuvers, json_req);
457}
458
459#[unsafe(no_mangle)]
461pub unsafe extern "C" fn nil_cheat_get_maneuvers_of(
462 request_id: RequestId,
463 json_req: *const c_char,
464) {
465 send!(request_id, cheat_get_maneuvers_of, json_req);
466}
467
468#[unsafe(no_mangle)]
470pub unsafe extern "C" fn nil_cheat_get_player(request_id: RequestId, json_req: *const c_char) {
471 send!(request_id, cheat_get_player, json_req);
472}
473
474#[unsafe(no_mangle)]
476pub unsafe extern "C" fn nil_cheat_get_players(request_id: RequestId, json_req: *const c_char) {
477 send!(request_id, cheat_get_players, json_req);
478}
479
480#[unsafe(no_mangle)]
482pub unsafe extern "C" fn nil_cheat_get_prefecture_build_queue(
483 request_id: RequestId,
484 json_req: *const c_char,
485) {
486 send!(request_id, cheat_get_prefecture_build_queue, json_req);
487}
488
489#[unsafe(no_mangle)]
491pub unsafe extern "C" fn nil_cheat_get_prefecture_build_queues(
492 request_id: RequestId,
493 json_req: *const c_char,
494) {
495 send!(request_id, cheat_get_prefecture_build_queues, json_req);
496}
497
498#[unsafe(no_mangle)]
500pub unsafe extern "C" fn nil_cheat_get_resources(request_id: RequestId, json_req: *const c_char) {
501 send!(request_id, cheat_get_resources, json_req);
502}
503
504#[unsafe(no_mangle)]
506pub unsafe extern "C" fn nil_cheat_get_stable_recruit_queue(
507 request_id: RequestId,
508 json_req: *const c_char,
509) {
510 send!(request_id, cheat_get_stable_recruit_queue, json_req);
511}
512
513#[unsafe(no_mangle)]
515pub unsafe extern "C" fn nil_cheat_get_stable_recruit_queues(
516 request_id: RequestId,
517 json_req: *const c_char,
518) {
519 send!(request_id, cheat_get_stable_recruit_queues, json_req);
520}
521
522#[unsafe(no_mangle)]
524pub unsafe extern "C" fn nil_cheat_get_storage_capacity(
525 request_id: RequestId,
526 json_req: *const c_char,
527) {
528 send!(request_id, cheat_get_storage_capacity, json_req);
529}
530
531#[unsafe(no_mangle)]
533pub unsafe extern "C" fn nil_cheat_set_bot_ethics(request_id: RequestId, json_req: *const c_char) {
534 send!(request_id, cheat_set_bot_ethics, json_req);
535}
536
537#[unsafe(no_mangle)]
539pub unsafe extern "C" fn nil_cheat_set_building_level(
540 request_id: RequestId,
541 json_req: *const c_char,
542) {
543 send!(request_id, cheat_set_building_level, json_req);
544}
545
546#[unsafe(no_mangle)]
548pub unsafe extern "C" fn nil_cheat_set_food(request_id: RequestId, json_req: *const c_char) {
549 send!(request_id, cheat_set_food, json_req);
550}
551
552#[unsafe(no_mangle)]
554pub unsafe extern "C" fn nil_cheat_set_iron(request_id: RequestId, json_req: *const c_char) {
555 send!(request_id, cheat_set_iron, json_req);
556}
557
558#[unsafe(no_mangle)]
560pub unsafe extern "C" fn nil_cheat_set_market_fee(request_id: RequestId, json_req: *const c_char) {
561 send!(request_id, cheat_set_market_fee, json_req);
562}
563
564#[unsafe(no_mangle)]
566pub unsafe extern "C" fn nil_cheat_set_market_vault_resources(
567 request_id: RequestId,
568 json_req: *const c_char,
569) {
570 send!(request_id, cheat_set_market_vault_resources, json_req);
571}
572
573#[unsafe(no_mangle)]
575pub unsafe extern "C" fn nil_cheat_set_max_food(request_id: RequestId, json_req: *const c_char) {
576 send!(request_id, cheat_set_max_food, json_req);
577}
578
579#[unsafe(no_mangle)]
581pub unsafe extern "C" fn nil_cheat_set_max_infrastructure(
582 request_id: RequestId,
583 json_req: *const c_char,
584) {
585 send!(request_id, cheat_set_max_infrastructure, json_req);
586}
587
588#[unsafe(no_mangle)]
590pub unsafe extern "C" fn nil_cheat_set_max_iron(request_id: RequestId, json_req: *const c_char) {
591 send!(request_id, cheat_set_max_iron, json_req);
592}
593
594#[unsafe(no_mangle)]
596pub unsafe extern "C" fn nil_cheat_set_max_resources(
597 request_id: RequestId,
598 json_req: *const c_char,
599) {
600 send!(request_id, cheat_set_max_resources, json_req);
601}
602
603#[unsafe(no_mangle)]
605pub unsafe extern "C" fn nil_cheat_set_max_silo_resources(
606 request_id: RequestId,
607 json_req: *const c_char,
608) {
609 send!(request_id, cheat_set_max_silo_resources, json_req);
610}
611
612#[unsafe(no_mangle)]
614pub unsafe extern "C" fn nil_cheat_set_max_stone(request_id: RequestId, json_req: *const c_char) {
615 send!(request_id, cheat_set_max_stone, json_req);
616}
617
618#[unsafe(no_mangle)]
620pub unsafe extern "C" fn nil_cheat_set_max_warehouse_resources(
621 request_id: RequestId,
622 json_req: *const c_char,
623) {
624 send!(request_id, cheat_set_max_warehouse_resources, json_req);
625}
626
627#[unsafe(no_mangle)]
629pub unsafe extern "C" fn nil_cheat_set_max_wood(request_id: RequestId, json_req: *const c_char) {
630 send!(request_id, cheat_set_max_wood, json_req);
631}
632
633#[unsafe(no_mangle)]
635pub unsafe extern "C" fn nil_cheat_set_resources(request_id: RequestId, json_req: *const c_char) {
636 send!(request_id, cheat_set_resources, json_req);
637}
638
639#[unsafe(no_mangle)]
641pub unsafe extern "C" fn nil_cheat_set_stability(request_id: RequestId, json_req: *const c_char) {
642 send!(request_id, cheat_set_stability, json_req);
643}
644
645#[unsafe(no_mangle)]
647pub unsafe extern "C" fn nil_cheat_set_stone(request_id: RequestId, json_req: *const c_char) {
648 send!(request_id, cheat_set_stone, json_req);
649}
650
651#[unsafe(no_mangle)]
653pub unsafe extern "C" fn nil_cheat_set_wood(request_id: RequestId, json_req: *const c_char) {
654 send!(request_id, cheat_set_wood, json_req);
655}
656
657#[unsafe(no_mangle)]
659pub unsafe extern "C" fn nil_cheat_skip_round(request_id: RequestId, json_req: *const c_char) {
660 send!(request_id, cheat_skip_round, json_req);
661}
662
663#[unsafe(no_mangle)]
665pub unsafe extern "C" fn nil_cheat_spawn_bot(request_id: RequestId, json_req: *const c_char) {
666 send!(request_id, cheat_spawn_bot, json_req);
667}
668
669#[unsafe(no_mangle)]
671pub unsafe extern "C" fn nil_cheat_spawn_city(request_id: RequestId, json_req: *const c_char) {
672 send!(request_id, cheat_spawn_city, json_req);
673}
674
675#[unsafe(no_mangle)]
677pub unsafe extern "C" fn nil_cheat_spawn_personnel(request_id: RequestId, json_req: *const c_char) {
678 send!(request_id, cheat_spawn_personnel, json_req);
679}
680
681#[unsafe(no_mangle)]
683pub unsafe extern "C" fn nil_create_remote_world(request_id: RequestId, json_req: *const c_char) {
684 send!(request_id, create_remote_world, json_req);
685}
686
687#[unsafe(no_mangle)]
689pub unsafe extern "C" fn nil_create_user(request_id: RequestId, json_req: *const c_char) {
690 send!(request_id, create_user, json_req);
691}
692
693#[unsafe(no_mangle)]
695pub unsafe extern "C" fn nil_delete_remote_world(request_id: RequestId, json_req: *const c_char) {
696 send!(request_id, delete_remote_world, json_req);
697}
698
699#[unsafe(no_mangle)]
701pub unsafe extern "C" fn nil_forward_report(request_id: RequestId, json_req: *const c_char) {
702 send!(request_id, forward_report, json_req);
703}
704
705#[unsafe(no_mangle)]
707pub unsafe extern "C" fn nil_get_academy_recruit_catalog(
708 request_id: RequestId,
709 json_req: *const c_char,
710) {
711 send!(request_id, get_academy_recruit_catalog, json_req);
712}
713
714#[unsafe(no_mangle)]
716pub unsafe extern "C" fn nil_get_armies(request_id: RequestId, json_req: *const c_char) {
717 send!(request_id, get_armies, json_req);
718}
719
720#[unsafe(no_mangle)]
722pub unsafe extern "C" fn nil_get_army(request_id: RequestId, json_req: *const c_char) {
723 send!(request_id, get_army, json_req);
724}
725
726#[unsafe(no_mangle)]
728pub unsafe extern "C" fn nil_get_army_owner(request_id: RequestId, json_req: *const c_char) {
729 send!(request_id, get_army_owner, json_req);
730}
731
732#[unsafe(no_mangle)]
734pub unsafe extern "C" fn nil_get_bot_coords(request_id: RequestId, json_req: *const c_char) {
735 send!(request_id, get_bot_coords, json_req);
736}
737
738#[unsafe(no_mangle)]
740pub unsafe extern "C" fn nil_get_chat_history(request_id: RequestId, json_req: *const c_char) {
741 send!(request_id, get_chat_history, json_req);
742}
743
744#[unsafe(no_mangle)]
746pub unsafe extern "C" fn nil_get_cities(request_id: RequestId, json_req: *const c_char) {
747 send!(request_id, get_cities, json_req);
748}
749
750#[unsafe(no_mangle)]
752pub unsafe extern "C" fn nil_get_city(request_id: RequestId, json_req: *const c_char) {
753 send!(request_id, get_city, json_req);
754}
755
756#[unsafe(no_mangle)]
758pub unsafe extern "C" fn nil_get_city_score(request_id: RequestId, json_req: *const c_char) {
759 send!(request_id, get_city_score, json_req);
760}
761
762#[unsafe(no_mangle)]
764pub unsafe extern "C" fn nil_get_continent_size(request_id: RequestId, json_req: *const c_char) {
765 send!(request_id, get_continent_size, json_req);
766}
767
768#[unsafe(no_mangle)]
770pub unsafe extern "C" fn nil_get_idle_armies_at(request_id: RequestId, json_req: *const c_char) {
771 send!(request_id, get_idle_armies_at, json_req);
772}
773
774#[unsafe(no_mangle)]
776pub unsafe extern "C" fn nil_get_idle_armies_coords(
777 request_id: RequestId,
778 json_req: *const c_char,
779) {
780 send!(request_id, get_idle_armies_coords, json_req);
781}
782
783#[unsafe(no_mangle)]
785pub unsafe extern "C" fn nil_get_maneuver(request_id: RequestId, json_req: *const c_char) {
786 send!(request_id, get_maneuver, json_req);
787}
788
789#[unsafe(no_mangle)]
791pub unsafe extern "C" fn nil_get_market(request_id: RequestId, json_req: *const c_char) {
792 send!(request_id, get_market, json_req);
793}
794
795#[unsafe(no_mangle)]
797pub unsafe extern "C" fn nil_get_market_fee(request_id: RequestId, json_req: *const c_char) {
798 send!(request_id, get_market_fee, json_req);
799}
800
801#[unsafe(no_mangle)]
803pub unsafe extern "C" fn nil_get_player(request_id: RequestId, json_req: *const c_char) {
804 send!(request_id, get_player, json_req);
805}
806
807#[unsafe(no_mangle)]
809pub unsafe extern "C" fn nil_get_player_coords(request_id: RequestId, json_req: *const c_char) {
810 send!(request_id, get_player_coords, json_req);
811}
812
813#[unsafe(no_mangle)]
815pub unsafe extern "C" fn nil_get_player_ids(request_id: RequestId, json_req: *const c_char) {
816 send!(request_id, get_player_ids, json_req);
817}
818
819#[unsafe(no_mangle)]
821pub unsafe extern "C" fn nil_get_player_maintenance(
822 request_id: RequestId,
823 json_req: *const c_char,
824) {
825 send!(request_id, get_player_maintenance, json_req);
826}
827
828#[unsafe(no_mangle)]
830pub unsafe extern "C" fn nil_get_player_military(request_id: RequestId, json_req: *const c_char) {
831 send!(request_id, get_player_military, json_req);
832}
833
834#[unsafe(no_mangle)]
836pub unsafe extern "C" fn nil_get_player_status(request_id: RequestId, json_req: *const c_char) {
837 send!(request_id, get_player_status, json_req);
838}
839
840#[unsafe(no_mangle)]
842pub unsafe extern "C" fn nil_get_player_storage_capacity(
843 request_id: RequestId,
844 json_req: *const c_char,
845) {
846 send!(request_id, get_player_storage_capacity, json_req);
847}
848
849#[unsafe(no_mangle)]
851pub unsafe extern "C" fn nil_get_player_worlds(request_id: RequestId, json_req: *const c_char) {
852 send!(request_id, get_player_worlds, json_req);
853}
854
855#[unsafe(no_mangle)]
857pub unsafe extern "C" fn nil_get_precursor_coords(request_id: RequestId, json_req: *const c_char) {
858 send!(request_id, get_precursor_coords, json_req);
859}
860
861#[unsafe(no_mangle)]
863pub unsafe extern "C" fn nil_get_prefecture_build_catalog(
864 request_id: RequestId,
865 json_req: *const c_char,
866) {
867 send!(request_id, get_prefecture_build_catalog, json_req);
868}
869
870#[unsafe(no_mangle)]
872pub unsafe extern "C" fn nil_get_public_bot(request_id: RequestId, json_req: *const c_char) {
873 send!(request_id, get_public_bot, json_req);
874}
875
876#[unsafe(no_mangle)]
878pub unsafe extern "C" fn nil_get_public_bots(request_id: RequestId, json_req: *const c_char) {
879 send!(request_id, get_public_bots, json_req);
880}
881
882#[unsafe(no_mangle)]
884pub unsafe extern "C" fn nil_get_public_cities(request_id: RequestId, json_req: *const c_char) {
885 send!(request_id, get_public_cities, json_req);
886}
887
888#[unsafe(no_mangle)]
890pub unsafe extern "C" fn nil_get_public_city(request_id: RequestId, json_req: *const c_char) {
891 send!(request_id, get_public_city, json_req);
892}
893
894#[unsafe(no_mangle)]
896pub unsafe extern "C" fn nil_get_public_field(request_id: RequestId, json_req: *const c_char) {
897 send!(request_id, get_public_field, json_req);
898}
899
900#[unsafe(no_mangle)]
902pub unsafe extern "C" fn nil_get_public_fields(request_id: RequestId, json_req: *const c_char) {
903 send!(request_id, get_public_fields, json_req);
904}
905
906#[unsafe(no_mangle)]
908pub unsafe extern "C" fn nil_get_public_player(request_id: RequestId, json_req: *const c_char) {
909 send!(request_id, get_public_player, json_req);
910}
911
912#[unsafe(no_mangle)]
914pub unsafe extern "C" fn nil_get_public_players(request_id: RequestId, json_req: *const c_char) {
915 send!(request_id, get_public_players, json_req);
916}
917
918#[unsafe(no_mangle)]
920pub unsafe extern "C" fn nil_get_public_precursor(request_id: RequestId, json_req: *const c_char) {
921 send!(request_id, get_public_precursor, json_req);
922}
923
924#[unsafe(no_mangle)]
926pub unsafe extern "C" fn nil_get_public_precursors(request_id: RequestId, json_req: *const c_char) {
927 send!(request_id, get_public_precursors, json_req);
928}
929
930#[unsafe(no_mangle)]
932pub unsafe extern "C" fn nil_get_rank(request_id: RequestId, json_req: *const c_char) {
933 send!(request_id, get_rank, json_req);
934}
935
936#[unsafe(no_mangle)]
938pub unsafe extern "C" fn nil_get_ranking(request_id: RequestId, json_req: *const c_char) {
939 send!(request_id, get_ranking, json_req);
940}
941
942#[unsafe(no_mangle)]
944pub unsafe extern "C" fn nil_get_remote_world(request_id: RequestId, json_req: *const c_char) {
945 send!(request_id, get_remote_world, json_req);
946}
947
948#[unsafe(no_mangle)]
950pub unsafe extern "C" fn nil_get_remote_world_limit(request_id: RequestId) {
951 send!(request_id, get_remote_world_limit);
952}
953
954#[unsafe(no_mangle)]
956pub unsafe extern "C" fn nil_get_remote_world_limit_per_user(request_id: RequestId) {
957 send!(request_id, get_remote_world_limit_per_user);
958}
959
960#[unsafe(no_mangle)]
962pub unsafe extern "C" fn nil_get_remote_worlds(request_id: RequestId) {
963 send!(request_id, get_remote_worlds);
964}
965
966#[unsafe(no_mangle)]
968pub unsafe extern "C" fn nil_get_round(request_id: RequestId, json_req: *const c_char) {
969 send!(request_id, get_round, json_req);
970}
971
972#[unsafe(no_mangle)]
974pub unsafe extern "C" fn nil_get_server_kind(request_id: RequestId) {
975 send!(request_id, get_server_kind);
976}
977
978#[unsafe(no_mangle)]
980pub unsafe extern "C" fn nil_get_stable_recruit_catalog(
981 request_id: RequestId,
982 json_req: *const c_char,
983) {
984 send!(request_id, get_stable_recruit_catalog, json_req);
985}
986
987#[unsafe(no_mangle)]
989pub unsafe extern "C" fn nil_get_workshop_recruit_catalog(
990 request_id: RequestId,
991 json_req: *const c_char,
992) {
993 send!(request_id, get_workshop_recruit_catalog, json_req);
994}
995
996#[unsafe(no_mangle)]
998pub unsafe extern "C" fn nil_get_world_bots(request_id: RequestId, json_req: *const c_char) {
999 send!(request_id, get_world_bots, json_req);
1000}
1001
1002#[unsafe(no_mangle)]
1004pub unsafe extern "C" fn nil_get_world_config(request_id: RequestId, json_req: *const c_char) {
1005 send!(request_id, get_world_config, json_req);
1006}
1007
1008#[unsafe(no_mangle)]
1010pub unsafe extern "C" fn nil_get_world_personnel(request_id: RequestId, json_req: *const c_char) {
1011 send!(request_id, get_world_personnel, json_req);
1012}
1013
1014#[unsafe(no_mangle)]
1016pub unsafe extern "C" fn nil_get_world_players(request_id: RequestId, json_req: *const c_char) {
1017 send!(request_id, get_world_players, json_req);
1018}
1019
1020#[unsafe(no_mangle)]
1022pub unsafe extern "C" fn nil_get_world_precursors(request_id: RequestId, json_req: *const c_char) {
1023 send!(request_id, get_world_precursors, json_req);
1024}
1025
1026#[unsafe(no_mangle)]
1028pub unsafe extern "C" fn nil_get_world_rulers(request_id: RequestId, json_req: *const c_char) {
1029 send!(request_id, get_world_rulers, json_req);
1030}
1031
1032#[unsafe(no_mangle)]
1034pub unsafe extern "C" fn nil_get_world_stats(request_id: RequestId, json_req: *const c_char) {
1035 send!(request_id, get_world_stats, json_req);
1036}
1037
1038#[unsafe(no_mangle)]
1040pub unsafe extern "C" fn nil_player_exists(request_id: RequestId, json_req: *const c_char) {
1041 send!(request_id, player_exists, json_req);
1042}
1043
1044#[unsafe(no_mangle)]
1046pub unsafe extern "C" fn nil_push_chat_message(request_id: RequestId, json_req: *const c_char) {
1047 send!(request_id, push_chat_message, json_req);
1048}
1049
1050#[unsafe(no_mangle)]
1052pub unsafe extern "C" fn nil_rename_city(request_id: RequestId, json_req: *const c_char) {
1053 send!(request_id, rename_city, json_req);
1054}
1055
1056#[unsafe(no_mangle)]
1058pub unsafe extern "C" fn nil_request_maneuver(request_id: RequestId, json_req: *const c_char) {
1059 send!(request_id, request_maneuver, json_req);
1060}
1061
1062#[unsafe(no_mangle)]
1064pub unsafe extern "C" fn nil_save_local_world(request_id: RequestId, json_req: *const c_char) {
1065 send!(request_id, save_local_world, json_req);
1066}
1067
1068#[unsafe(no_mangle)]
1070pub unsafe extern "C" fn nil_search_city(request_id: RequestId, json_req: *const c_char) {
1071 send!(request_id, search_city, json_req);
1072}
1073
1074#[unsafe(no_mangle)]
1076pub unsafe extern "C" fn nil_search_public_city(request_id: RequestId, json_req: *const c_char) {
1077 send!(request_id, search_public_city, json_req);
1078}
1079
1080#[unsafe(no_mangle)]
1082pub unsafe extern "C" fn nil_sell_resources(request_id: RequestId, json_req: *const c_char) {
1083 send!(request_id, sell_resources, json_req);
1084}
1085
1086#[unsafe(no_mangle)]
1088pub unsafe extern "C" fn nil_send_resources(request_id: RequestId, json_req: *const c_char) {
1089 send!(request_id, send_resources, json_req);
1090}
1091
1092#[unsafe(no_mangle)]
1094pub unsafe extern "C" fn nil_server_version(request_id: RequestId) {
1095 send!(request_id, version);
1096}
1097
1098#[unsafe(no_mangle)]
1100pub unsafe extern "C" fn nil_set_player_ready(request_id: RequestId, json_req: *const c_char) {
1101 send!(request_id, set_player_ready, json_req);
1102}
1103
1104#[unsafe(no_mangle)]
1106pub unsafe extern "C" fn nil_set_player_status(request_id: RequestId, json_req: *const c_char) {
1107 send!(request_id, set_player_status, json_req);
1108}
1109
1110#[unsafe(no_mangle)]
1112pub unsafe extern "C" fn nil_simulate_battle(request_id: RequestId, json_req: *const c_char) {
1113 send!(request_id, simulate_battle, json_req);
1114}
1115
1116#[unsafe(no_mangle)]
1118pub unsafe extern "C" fn nil_spawn_player(request_id: RequestId, json_req: *const c_char) {
1119 send!(request_id, spawn_player, json_req);
1120}
1121
1122#[unsafe(no_mangle)]
1124pub unsafe extern "C" fn nil_start_round(request_id: RequestId, json_req: *const c_char) {
1125 send!(request_id, start_round, json_req);
1126}
1127
1128#[unsafe(no_mangle)]
1130pub unsafe extern "C" fn nil_toggle_building(request_id: RequestId, json_req: *const c_char) {
1131 send!(request_id, toggle_building, json_req);
1132}
1133
1134#[unsafe(no_mangle)]
1136pub unsafe extern "C" fn nil_user_exists(request_id: RequestId, json_req: *const c_char) {
1137 send!(request_id, user_exists, json_req);
1138}
1139
1140#[unsafe(no_mangle)]
1142pub unsafe extern "C" fn nil_validate_token(request_id: RequestId, json_req: *const c_char) {
1143 send!(request_id, validate_token, json_req);
1144}