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_cancel_academy_recruit_order(
306 request_id: RequestId,
307 json_req: *const c_char,
308) {
309 send!(request_id, cancel_academy_recruit_order, json_req);
310}
311
312#[unsafe(no_mangle)]
314pub unsafe extern "C" fn nil_cancel_maneuver(request_id: RequestId, json_req: *const c_char) {
315 send!(request_id, cancel_maneuver, json_req);
316}
317
318#[unsafe(no_mangle)]
320pub unsafe extern "C" fn nil_cancel_prefecture_build_order(
321 request_id: RequestId,
322 json_req: *const c_char,
323) {
324 send!(request_id, cancel_prefecture_build_order, json_req);
325}
326
327#[unsafe(no_mangle)]
329pub unsafe extern "C" fn nil_cancel_stable_recruit_order(
330 request_id: RequestId,
331 json_req: *const c_char,
332) {
333 send!(request_id, cancel_stable_recruit_order, json_req);
334}
335
336#[unsafe(no_mangle)]
338pub unsafe extern "C" fn nil_cancel_workshop_recruit_order(
339 request_id: RequestId,
340 json_req: *const c_char,
341) {
342 send!(request_id, cancel_workshop_recruit_order, json_req);
343}
344
345#[unsafe(no_mangle)]
347pub unsafe extern "C" fn nil_cheat_fill_world(request_id: RequestId, json_req: *const c_char) {
348 send!(request_id, cheat_fill_world, json_req);
349}
350
351#[unsafe(no_mangle)]
353pub unsafe extern "C" fn nil_cheat_get_academy_recruit_queue(
354 request_id: RequestId,
355 json_req: *const c_char,
356) {
357 send!(request_id, cheat_get_academy_recruit_queue, json_req);
358}
359
360#[unsafe(no_mangle)]
362pub unsafe extern "C" fn nil_cheat_get_academy_recruit_queues(
363 request_id: RequestId,
364 json_req: *const c_char,
365) {
366 send!(request_id, cheat_get_academy_recruit_queues, json_req);
367}
368
369#[unsafe(no_mangle)]
371pub unsafe extern "C" fn nil_cheat_get_all_academy_recruit_queues(
372 request_id: RequestId,
373 json_req: *const c_char,
374) {
375 send!(request_id, cheat_get_all_academy_recruit_queues, json_req);
376}
377
378#[unsafe(no_mangle)]
380pub unsafe extern "C" fn nil_cheat_get_all_prefecture_build_queues(
381 request_id: RequestId,
382 json_req: *const c_char,
383) {
384 send!(request_id, cheat_get_all_prefecture_build_queues, json_req);
385}
386
387#[unsafe(no_mangle)]
389pub unsafe extern "C" fn nil_cheat_get_all_stable_recruit_queues(
390 request_id: RequestId,
391 json_req: *const c_char,
392) {
393 send!(request_id, cheat_get_all_stable_recruit_queues, json_req);
394}
395
396#[unsafe(no_mangle)]
398pub unsafe extern "C" fn nil_cheat_get_build_steps(request_id: RequestId, json_req: *const c_char) {
399 send!(request_id, cheat_get_build_steps, json_req);
400}
401
402#[unsafe(no_mangle)]
404pub unsafe extern "C" fn nil_cheat_get_cities(request_id: RequestId, json_req: *const c_char) {
405 send!(request_id, cheat_get_cities, json_req);
406}
407
408#[unsafe(no_mangle)]
410pub unsafe extern "C" fn nil_cheat_get_city(request_id: RequestId, json_req: *const c_char) {
411 send!(request_id, cheat_get_city, json_req);
412}
413
414#[unsafe(no_mangle)]
416pub unsafe extern "C" fn nil_cheat_get_ethics(request_id: RequestId, json_req: *const c_char) {
417 send!(request_id, cheat_get_ethics, json_req);
418}
419
420#[unsafe(no_mangle)]
422pub unsafe extern "C" fn nil_cheat_get_idle_armies_at(
423 request_id: RequestId,
424 json_req: *const c_char,
425) {
426 send!(request_id, cheat_get_idle_armies_at, json_req);
427}
428
429#[unsafe(no_mangle)]
431pub unsafe extern "C" fn nil_cheat_get_idle_personnel_at(
432 request_id: RequestId,
433 json_req: *const c_char,
434) {
435 send!(request_id, cheat_get_idle_personnel_at, json_req);
436}
437
438#[unsafe(no_mangle)]
440pub unsafe extern "C" fn nil_cheat_get_infrastructure(
441 request_id: RequestId,
442 json_req: *const c_char,
443) {
444 send!(request_id, cheat_get_infrastructure, json_req);
445}
446
447#[unsafe(no_mangle)]
449pub unsafe extern "C" fn nil_cheat_get_maneuvers(request_id: RequestId, json_req: *const c_char) {
450 send!(request_id, cheat_get_maneuvers, json_req);
451}
452
453#[unsafe(no_mangle)]
455pub unsafe extern "C" fn nil_cheat_get_maneuvers_of(
456 request_id: RequestId,
457 json_req: *const c_char,
458) {
459 send!(request_id, cheat_get_maneuvers_of, json_req);
460}
461
462#[unsafe(no_mangle)]
464pub unsafe extern "C" fn nil_cheat_get_player(request_id: RequestId, json_req: *const c_char) {
465 send!(request_id, cheat_get_player, json_req);
466}
467
468#[unsafe(no_mangle)]
470pub unsafe extern "C" fn nil_cheat_get_players(request_id: RequestId, json_req: *const c_char) {
471 send!(request_id, cheat_get_players, json_req);
472}
473
474#[unsafe(no_mangle)]
476pub unsafe extern "C" fn nil_cheat_get_prefecture_build_queue(
477 request_id: RequestId,
478 json_req: *const c_char,
479) {
480 send!(request_id, cheat_get_prefecture_build_queue, json_req);
481}
482
483#[unsafe(no_mangle)]
485pub unsafe extern "C" fn nil_cheat_get_prefecture_build_queues(
486 request_id: RequestId,
487 json_req: *const c_char,
488) {
489 send!(request_id, cheat_get_prefecture_build_queues, json_req);
490}
491
492#[unsafe(no_mangle)]
494pub unsafe extern "C" fn nil_cheat_get_resources(request_id: RequestId, json_req: *const c_char) {
495 send!(request_id, cheat_get_resources, json_req);
496}
497
498#[unsafe(no_mangle)]
500pub unsafe extern "C" fn nil_cheat_get_stable_recruit_queue(
501 request_id: RequestId,
502 json_req: *const c_char,
503) {
504 send!(request_id, cheat_get_stable_recruit_queue, json_req);
505}
506
507#[unsafe(no_mangle)]
509pub unsafe extern "C" fn nil_cheat_get_stable_recruit_queues(
510 request_id: RequestId,
511 json_req: *const c_char,
512) {
513 send!(request_id, cheat_get_stable_recruit_queues, json_req);
514}
515
516#[unsafe(no_mangle)]
518pub unsafe extern "C" fn nil_cheat_get_storage_capacity(
519 request_id: RequestId,
520 json_req: *const c_char,
521) {
522 send!(request_id, cheat_get_storage_capacity, json_req);
523}
524
525#[unsafe(no_mangle)]
527pub unsafe extern "C" fn nil_cheat_set_bot_ethics(request_id: RequestId, json_req: *const c_char) {
528 send!(request_id, cheat_set_bot_ethics, json_req);
529}
530
531#[unsafe(no_mangle)]
533pub unsafe extern "C" fn nil_cheat_set_building_level(
534 request_id: RequestId,
535 json_req: *const c_char,
536) {
537 send!(request_id, cheat_set_building_level, json_req);
538}
539
540#[unsafe(no_mangle)]
542pub unsafe extern "C" fn nil_cheat_set_food(request_id: RequestId, json_req: *const c_char) {
543 send!(request_id, cheat_set_food, json_req);
544}
545
546#[unsafe(no_mangle)]
548pub unsafe extern "C" fn nil_cheat_set_iron(request_id: RequestId, json_req: *const c_char) {
549 send!(request_id, cheat_set_iron, json_req);
550}
551
552#[unsafe(no_mangle)]
554pub unsafe extern "C" fn nil_cheat_set_market_fee(request_id: RequestId, json_req: *const c_char) {
555 send!(request_id, cheat_set_market_fee, json_req);
556}
557
558#[unsafe(no_mangle)]
560pub unsafe extern "C" fn nil_cheat_set_max_food(request_id: RequestId, json_req: *const c_char) {
561 send!(request_id, cheat_set_max_food, json_req);
562}
563
564#[unsafe(no_mangle)]
566pub unsafe extern "C" fn nil_cheat_set_max_infrastructure(
567 request_id: RequestId,
568 json_req: *const c_char,
569) {
570 send!(request_id, cheat_set_max_infrastructure, json_req);
571}
572
573#[unsafe(no_mangle)]
575pub unsafe extern "C" fn nil_cheat_set_max_iron(request_id: RequestId, json_req: *const c_char) {
576 send!(request_id, cheat_set_max_iron, json_req);
577}
578
579#[unsafe(no_mangle)]
581pub unsafe extern "C" fn nil_cheat_set_max_resources(
582 request_id: RequestId,
583 json_req: *const c_char,
584) {
585 send!(request_id, cheat_set_max_resources, json_req);
586}
587
588#[unsafe(no_mangle)]
590pub unsafe extern "C" fn nil_cheat_set_max_silo_resources(
591 request_id: RequestId,
592 json_req: *const c_char,
593) {
594 send!(request_id, cheat_set_max_silo_resources, json_req);
595}
596
597#[unsafe(no_mangle)]
599pub unsafe extern "C" fn nil_cheat_set_max_stone(request_id: RequestId, json_req: *const c_char) {
600 send!(request_id, cheat_set_max_stone, json_req);
601}
602
603#[unsafe(no_mangle)]
605pub unsafe extern "C" fn nil_cheat_set_max_warehouse_resources(
606 request_id: RequestId,
607 json_req: *const c_char,
608) {
609 send!(request_id, cheat_set_max_warehouse_resources, json_req);
610}
611
612#[unsafe(no_mangle)]
614pub unsafe extern "C" fn nil_cheat_set_max_wood(request_id: RequestId, json_req: *const c_char) {
615 send!(request_id, cheat_set_max_wood, json_req);
616}
617
618#[unsafe(no_mangle)]
620pub unsafe extern "C" fn nil_cheat_set_resources(request_id: RequestId, json_req: *const c_char) {
621 send!(request_id, cheat_set_resources, json_req);
622}
623
624#[unsafe(no_mangle)]
626pub unsafe extern "C" fn nil_cheat_set_stability(request_id: RequestId, json_req: *const c_char) {
627 send!(request_id, cheat_set_stability, json_req);
628}
629
630#[unsafe(no_mangle)]
632pub unsafe extern "C" fn nil_cheat_set_stone(request_id: RequestId, json_req: *const c_char) {
633 send!(request_id, cheat_set_stone, json_req);
634}
635
636#[unsafe(no_mangle)]
638pub unsafe extern "C" fn nil_cheat_set_wood(request_id: RequestId, json_req: *const c_char) {
639 send!(request_id, cheat_set_wood, json_req);
640}
641
642#[unsafe(no_mangle)]
644pub unsafe extern "C" fn nil_cheat_skip_round(request_id: RequestId, json_req: *const c_char) {
645 send!(request_id, cheat_skip_round, json_req);
646}
647
648#[unsafe(no_mangle)]
650pub unsafe extern "C" fn nil_cheat_spawn_bot(request_id: RequestId, json_req: *const c_char) {
651 send!(request_id, cheat_spawn_bot, json_req);
652}
653
654#[unsafe(no_mangle)]
656pub unsafe extern "C" fn nil_cheat_spawn_city(request_id: RequestId, json_req: *const c_char) {
657 send!(request_id, cheat_spawn_city, json_req);
658}
659
660#[unsafe(no_mangle)]
662pub unsafe extern "C" fn nil_cheat_spawn_personnel(request_id: RequestId, json_req: *const c_char) {
663 send!(request_id, cheat_spawn_personnel, json_req);
664}
665
666#[unsafe(no_mangle)]
668pub unsafe extern "C" fn nil_create_remote_world(request_id: RequestId, json_req: *const c_char) {
669 send!(request_id, create_remote_world, json_req);
670}
671
672#[unsafe(no_mangle)]
674pub unsafe extern "C" fn nil_create_user(request_id: RequestId, json_req: *const c_char) {
675 send!(request_id, create_user, json_req);
676}
677
678#[unsafe(no_mangle)]
680pub unsafe extern "C" fn nil_delete_remote_world(request_id: RequestId, json_req: *const c_char) {
681 send!(request_id, delete_remote_world, json_req);
682}
683
684#[unsafe(no_mangle)]
686pub unsafe extern "C" fn nil_forward_report(request_id: RequestId, json_req: *const c_char) {
687 send!(request_id, forward_report, json_req);
688}
689
690#[unsafe(no_mangle)]
692pub unsafe extern "C" fn nil_get_academy_recruit_catalog(
693 request_id: RequestId,
694 json_req: *const c_char,
695) {
696 send!(request_id, get_academy_recruit_catalog, json_req);
697}
698
699#[unsafe(no_mangle)]
701pub unsafe extern "C" fn nil_get_armies(request_id: RequestId, json_req: *const c_char) {
702 send!(request_id, get_armies, json_req);
703}
704
705#[unsafe(no_mangle)]
707pub unsafe extern "C" fn nil_get_army(request_id: RequestId, json_req: *const c_char) {
708 send!(request_id, get_army, json_req);
709}
710
711#[unsafe(no_mangle)]
713pub unsafe extern "C" fn nil_get_army_owner(request_id: RequestId, json_req: *const c_char) {
714 send!(request_id, get_army_owner, json_req);
715}
716
717#[unsafe(no_mangle)]
719pub unsafe extern "C" fn nil_get_bot_coords(request_id: RequestId, json_req: *const c_char) {
720 send!(request_id, get_bot_coords, json_req);
721}
722
723#[unsafe(no_mangle)]
725pub unsafe extern "C" fn nil_get_chat_history(request_id: RequestId, json_req: *const c_char) {
726 send!(request_id, get_chat_history, json_req);
727}
728
729#[unsafe(no_mangle)]
731pub unsafe extern "C" fn nil_get_cities(request_id: RequestId, json_req: *const c_char) {
732 send!(request_id, get_cities, json_req);
733}
734
735#[unsafe(no_mangle)]
737pub unsafe extern "C" fn nil_get_city(request_id: RequestId, json_req: *const c_char) {
738 send!(request_id, get_city, json_req);
739}
740
741#[unsafe(no_mangle)]
743pub unsafe extern "C" fn nil_get_city_score(request_id: RequestId, json_req: *const c_char) {
744 send!(request_id, get_city_score, json_req);
745}
746
747#[unsafe(no_mangle)]
749pub unsafe extern "C" fn nil_get_continent_size(request_id: RequestId, json_req: *const c_char) {
750 send!(request_id, get_continent_size, json_req);
751}
752
753#[unsafe(no_mangle)]
755pub unsafe extern "C" fn nil_get_idle_armies_at(request_id: RequestId, json_req: *const c_char) {
756 send!(request_id, get_idle_armies_at, json_req);
757}
758
759#[unsafe(no_mangle)]
761pub unsafe extern "C" fn nil_get_idle_armies_coords(
762 request_id: RequestId,
763 json_req: *const c_char,
764) {
765 send!(request_id, get_idle_armies_coords, json_req);
766}
767
768#[unsafe(no_mangle)]
770pub unsafe extern "C" fn nil_get_maneuver(request_id: RequestId, json_req: *const c_char) {
771 send!(request_id, get_maneuver, json_req);
772}
773
774#[unsafe(no_mangle)]
776pub unsafe extern "C" fn nil_get_market(request_id: RequestId, json_req: *const c_char) {
777 send!(request_id, get_market, json_req);
778}
779
780#[unsafe(no_mangle)]
782pub unsafe extern "C" fn nil_get_market_fee(request_id: RequestId, json_req: *const c_char) {
783 send!(request_id, get_market_fee, json_req);
784}
785
786#[unsafe(no_mangle)]
788pub unsafe extern "C" fn nil_get_player(request_id: RequestId, json_req: *const c_char) {
789 send!(request_id, get_player, json_req);
790}
791
792#[unsafe(no_mangle)]
794pub unsafe extern "C" fn nil_get_player_coords(request_id: RequestId, json_req: *const c_char) {
795 send!(request_id, get_player_coords, json_req);
796}
797
798#[unsafe(no_mangle)]
800pub unsafe extern "C" fn nil_get_player_ids(request_id: RequestId, json_req: *const c_char) {
801 send!(request_id, get_player_ids, json_req);
802}
803
804#[unsafe(no_mangle)]
806pub unsafe extern "C" fn nil_get_player_maintenance(
807 request_id: RequestId,
808 json_req: *const c_char,
809) {
810 send!(request_id, get_player_maintenance, json_req);
811}
812
813#[unsafe(no_mangle)]
815pub unsafe extern "C" fn nil_get_player_military(request_id: RequestId, json_req: *const c_char) {
816 send!(request_id, get_player_military, json_req);
817}
818
819#[unsafe(no_mangle)]
821pub unsafe extern "C" fn nil_get_player_status(request_id: RequestId, json_req: *const c_char) {
822 send!(request_id, get_player_status, json_req);
823}
824
825#[unsafe(no_mangle)]
827pub unsafe extern "C" fn nil_get_player_storage_capacity(
828 request_id: RequestId,
829 json_req: *const c_char,
830) {
831 send!(request_id, get_player_storage_capacity, json_req);
832}
833
834#[unsafe(no_mangle)]
836pub unsafe extern "C" fn nil_get_player_worlds(request_id: RequestId, json_req: *const c_char) {
837 send!(request_id, get_player_worlds, json_req);
838}
839
840#[unsafe(no_mangle)]
842pub unsafe extern "C" fn nil_get_precursor_coords(request_id: RequestId, json_req: *const c_char) {
843 send!(request_id, get_precursor_coords, json_req);
844}
845
846#[unsafe(no_mangle)]
848pub unsafe extern "C" fn nil_get_prefecture_build_catalog(
849 request_id: RequestId,
850 json_req: *const c_char,
851) {
852 send!(request_id, get_prefecture_build_catalog, json_req);
853}
854
855#[unsafe(no_mangle)]
857pub unsafe extern "C" fn nil_get_public_bot(request_id: RequestId, json_req: *const c_char) {
858 send!(request_id, get_public_bot, json_req);
859}
860
861#[unsafe(no_mangle)]
863pub unsafe extern "C" fn nil_get_public_bots(request_id: RequestId, json_req: *const c_char) {
864 send!(request_id, get_public_bots, json_req);
865}
866
867#[unsafe(no_mangle)]
869pub unsafe extern "C" fn nil_get_public_cities(request_id: RequestId, json_req: *const c_char) {
870 send!(request_id, get_public_cities, json_req);
871}
872
873#[unsafe(no_mangle)]
875pub unsafe extern "C" fn nil_get_public_city(request_id: RequestId, json_req: *const c_char) {
876 send!(request_id, get_public_city, json_req);
877}
878
879#[unsafe(no_mangle)]
881pub unsafe extern "C" fn nil_get_public_field(request_id: RequestId, json_req: *const c_char) {
882 send!(request_id, get_public_field, json_req);
883}
884
885#[unsafe(no_mangle)]
887pub unsafe extern "C" fn nil_get_public_fields(request_id: RequestId, json_req: *const c_char) {
888 send!(request_id, get_public_fields, json_req);
889}
890
891#[unsafe(no_mangle)]
893pub unsafe extern "C" fn nil_get_public_player(request_id: RequestId, json_req: *const c_char) {
894 send!(request_id, get_public_player, json_req);
895}
896
897#[unsafe(no_mangle)]
899pub unsafe extern "C" fn nil_get_public_players(request_id: RequestId, json_req: *const c_char) {
900 send!(request_id, get_public_players, json_req);
901}
902
903#[unsafe(no_mangle)]
905pub unsafe extern "C" fn nil_get_public_precursor(request_id: RequestId, json_req: *const c_char) {
906 send!(request_id, get_public_precursor, json_req);
907}
908
909#[unsafe(no_mangle)]
911pub unsafe extern "C" fn nil_get_public_precursors(request_id: RequestId, json_req: *const c_char) {
912 send!(request_id, get_public_precursors, json_req);
913}
914
915#[unsafe(no_mangle)]
917pub unsafe extern "C" fn nil_get_rank(request_id: RequestId, json_req: *const c_char) {
918 send!(request_id, get_rank, json_req);
919}
920
921#[unsafe(no_mangle)]
923pub unsafe extern "C" fn nil_get_ranking(request_id: RequestId, json_req: *const c_char) {
924 send!(request_id, get_ranking, json_req);
925}
926
927#[unsafe(no_mangle)]
929pub unsafe extern "C" fn nil_get_remote_world(request_id: RequestId, json_req: *const c_char) {
930 send!(request_id, get_remote_world, json_req);
931}
932
933#[unsafe(no_mangle)]
935pub unsafe extern "C" fn nil_get_remote_world_limit(request_id: RequestId) {
936 send!(request_id, get_remote_world_limit);
937}
938
939#[unsafe(no_mangle)]
941pub unsafe extern "C" fn nil_get_remote_world_limit_per_user(request_id: RequestId) {
942 send!(request_id, get_remote_world_limit_per_user);
943}
944
945#[unsafe(no_mangle)]
947pub unsafe extern "C" fn nil_get_remote_worlds(request_id: RequestId) {
948 send!(request_id, get_remote_worlds);
949}
950
951#[unsafe(no_mangle)]
953pub unsafe extern "C" fn nil_get_round(request_id: RequestId, json_req: *const c_char) {
954 send!(request_id, get_round, json_req);
955}
956
957#[unsafe(no_mangle)]
959pub unsafe extern "C" fn nil_get_server_kind(request_id: RequestId) {
960 send!(request_id, get_server_kind);
961}
962
963#[unsafe(no_mangle)]
965pub unsafe extern "C" fn nil_get_stable_recruit_catalog(
966 request_id: RequestId,
967 json_req: *const c_char,
968) {
969 send!(request_id, get_stable_recruit_catalog, json_req);
970}
971
972#[unsafe(no_mangle)]
974pub unsafe extern "C" fn nil_get_workshop_recruit_catalog(
975 request_id: RequestId,
976 json_req: *const c_char,
977) {
978 send!(request_id, get_workshop_recruit_catalog, json_req);
979}
980
981#[unsafe(no_mangle)]
983pub unsafe extern "C" fn nil_get_world_bots(request_id: RequestId, json_req: *const c_char) {
984 send!(request_id, get_world_bots, json_req);
985}
986
987#[unsafe(no_mangle)]
989pub unsafe extern "C" fn nil_get_world_config(request_id: RequestId, json_req: *const c_char) {
990 send!(request_id, get_world_config, json_req);
991}
992
993#[unsafe(no_mangle)]
995pub unsafe extern "C" fn nil_get_world_personnel(request_id: RequestId, json_req: *const c_char) {
996 send!(request_id, get_world_personnel, json_req);
997}
998
999#[unsafe(no_mangle)]
1001pub unsafe extern "C" fn nil_get_world_players(request_id: RequestId, json_req: *const c_char) {
1002 send!(request_id, get_world_players, json_req);
1003}
1004
1005#[unsafe(no_mangle)]
1007pub unsafe extern "C" fn nil_get_world_precursors(request_id: RequestId, json_req: *const c_char) {
1008 send!(request_id, get_world_precursors, json_req);
1009}
1010
1011#[unsafe(no_mangle)]
1013pub unsafe extern "C" fn nil_get_world_rulers(request_id: RequestId, json_req: *const c_char) {
1014 send!(request_id, get_world_rulers, json_req);
1015}
1016
1017#[unsafe(no_mangle)]
1019pub unsafe extern "C" fn nil_get_world_stats(request_id: RequestId, json_req: *const c_char) {
1020 send!(request_id, get_world_stats, json_req);
1021}
1022
1023#[unsafe(no_mangle)]
1025pub unsafe extern "C" fn nil_player_exists(request_id: RequestId, json_req: *const c_char) {
1026 send!(request_id, player_exists, json_req);
1027}
1028
1029#[unsafe(no_mangle)]
1031pub unsafe extern "C" fn nil_push_chat_message(request_id: RequestId, json_req: *const c_char) {
1032 send!(request_id, push_chat_message, json_req);
1033}
1034
1035#[unsafe(no_mangle)]
1037pub unsafe extern "C" fn nil_rename_city(request_id: RequestId, json_req: *const c_char) {
1038 send!(request_id, rename_city, json_req);
1039}
1040
1041#[unsafe(no_mangle)]
1043pub unsafe extern "C" fn nil_request_maneuver(request_id: RequestId, json_req: *const c_char) {
1044 send!(request_id, request_maneuver, json_req);
1045}
1046
1047#[unsafe(no_mangle)]
1049pub unsafe extern "C" fn nil_save_local_world(request_id: RequestId, json_req: *const c_char) {
1050 send!(request_id, save_local_world, json_req);
1051}
1052
1053#[unsafe(no_mangle)]
1055pub unsafe extern "C" fn nil_search_city(request_id: RequestId, json_req: *const c_char) {
1056 send!(request_id, search_city, json_req);
1057}
1058
1059#[unsafe(no_mangle)]
1061pub unsafe extern "C" fn nil_search_public_city(request_id: RequestId, json_req: *const c_char) {
1062 send!(request_id, search_public_city, json_req);
1063}
1064
1065#[unsafe(no_mangle)]
1067pub unsafe extern "C" fn nil_send_resources(request_id: RequestId, json_req: *const c_char) {
1068 send!(request_id, send_resources, json_req);
1069}
1070
1071#[unsafe(no_mangle)]
1073pub unsafe extern "C" fn nil_server_version(request_id: RequestId) {
1074 send!(request_id, version);
1075}
1076
1077#[unsafe(no_mangle)]
1079pub unsafe extern "C" fn nil_set_player_ready(request_id: RequestId, json_req: *const c_char) {
1080 send!(request_id, set_player_ready, json_req);
1081}
1082
1083#[unsafe(no_mangle)]
1085pub unsafe extern "C" fn nil_set_player_status(request_id: RequestId, json_req: *const c_char) {
1086 send!(request_id, set_player_status, json_req);
1087}
1088
1089#[unsafe(no_mangle)]
1091pub unsafe extern "C" fn nil_simulate_battle(request_id: RequestId, json_req: *const c_char) {
1092 send!(request_id, simulate_battle, json_req);
1093}
1094
1095#[unsafe(no_mangle)]
1097pub unsafe extern "C" fn nil_spawn_player(request_id: RequestId, json_req: *const c_char) {
1098 send!(request_id, spawn_player, json_req);
1099}
1100
1101#[unsafe(no_mangle)]
1103pub unsafe extern "C" fn nil_start_round(request_id: RequestId, json_req: *const c_char) {
1104 send!(request_id, start_round, json_req);
1105}
1106
1107#[unsafe(no_mangle)]
1109pub unsafe extern "C" fn nil_toggle_building(request_id: RequestId, json_req: *const c_char) {
1110 send!(request_id, toggle_building, json_req);
1111}
1112
1113#[unsafe(no_mangle)]
1115pub unsafe extern "C" fn nil_user_exists(request_id: RequestId, json_req: *const c_char) {
1116 send!(request_id, user_exists, json_req);
1117}
1118
1119#[unsafe(no_mangle)]
1121pub unsafe extern "C" fn nil_validate_token(request_id: RequestId, json_req: *const c_char) {
1122 send!(request_id, validate_token, json_req);
1123}