Skip to main content

nil_ffi/
lib.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4#![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 server;
14mod status;
15
16use client::CLIENT;
17use futures::future::BoxFuture;
18use json::serialize;
19use nil_core::event::Event;
20use std::ffi::{CString, c_char};
21use std::ptr;
22use std::sync::LazyLock;
23use tokio::runtime::{Builder as RuntimeBuilder, Runtime};
24
25pub use client::UpdateClient;
26pub use request::RequestId;
27pub use response::{Response, Result};
28pub use status::Status;
29
30use crate::server::SERVER;
31
32static RUNTIME: LazyLock<Runtime> = LazyLock::new(|| {
33  RuntimeBuilder::new_multi_thread()
34    .enable_all()
35    .thread_name("libnil-worker")
36    .build()
37    .expect("failed to initialize tokio runtime")
38});
39
40///////////////////////////////
41//////////// FFI //////////////
42///////////////////////////////
43
44#[unsafe(no_mangle)]
45pub unsafe extern "C" fn nil_ffi_free_str(ptr: *mut c_char) {
46  if !ptr.is_null() {
47    drop(unsafe { CString::from_raw(ptr) });
48  }
49}
50
51#[unsafe(no_mangle)]
52pub unsafe extern "C" fn nil_ffi_poll(json_out: *mut *mut c_char) -> Status {
53  if json_out.is_null() {
54    return Status::ERR_NULL_POINTER;
55  }
56
57  unsafe { *json_out = ptr::null_mut() };
58
59  match queue::poll() {
60    Some(entry) => {
61      match serialize(&entry) {
62        Ok(json) => {
63          let json = CString::new(json).unwrap();
64          unsafe { *json_out = json.into_raw() };
65          Status::OK
66        }
67        Err(_) => Status::ERR_SERIALIZATION,
68      }
69    }
70    None => Status::ERR_NOTHING_TO_POLL,
71  }
72}
73
74#[unsafe(no_mangle)]
75pub unsafe extern "C" fn nil_ffi_shutdown() {
76  queue::clear();
77}
78
79#[unsafe(no_mangle)]
80pub unsafe extern "C" fn nil_ffi_version(request_id: RequestId) {
81  push_ok!(request_id, env!("CARGO_PKG_VERSION"))
82}
83
84///////////////////////////////
85//////////// SERVER ///////////
86///////////////////////////////
87
88#[unsafe(no_mangle)]
89pub unsafe extern "C" fn nil_is_host(request_id: RequestId) {
90  async_push_ok!(request_id, SERVER.read().await.is_some())
91}
92
93#[unsafe(no_mangle)]
94pub unsafe extern "C" fn nil_start_server(request_id: RequestId, json_options: *const c_char) {
95  let f = |options| {
96    RUNTIME.spawn(async move {
97      let result = server::start_with_options(options).await;
98      queue::push_result(request_id, Result::from(result));
99    });
100  };
101
102  unsafe { json::with_ptr(request_id, json_options, f) };
103}
104
105#[unsafe(no_mangle)]
106pub unsafe extern "C" fn nil_start_server_with_savedata(
107  request_id: RequestId,
108  json_path: *const c_char,
109) {
110  let f = |path| {
111    RUNTIME.spawn(async move {
112      let result = server::start_with_savedata(path).await;
113      queue::push_result(request_id, Result::from(result));
114    });
115  };
116
117  unsafe { json::with_ptr(request_id, json_path, f) };
118}
119
120#[unsafe(no_mangle)]
121pub unsafe extern "C" fn nil_stop_server(request_id: RequestId) {
122  RUNTIME.spawn(async move {
123    server::stop().await;
124    queue::push_ok(request_id, ());
125  });
126}
127
128///////////////////////////////
129//////////// CLIENT ///////////
130///////////////////////////////
131
132#[unsafe(no_mangle)]
133pub unsafe extern "C" fn nil_client_version(request_id: RequestId) {
134  push_ok!(request_id, nil_client::VERSION)
135}
136
137#[unsafe(no_mangle)]
138pub unsafe extern "C" fn nil_is_local(request_id: RequestId) {
139  async_push_ok!(request_id, CLIENT.read().await.is_local())
140}
141
142#[unsafe(no_mangle)]
143pub unsafe extern "C" fn nil_is_ready(request_id: RequestId) {
144  async_push_ok!(request_id, CLIENT.read().await.is_ready().await)
145}
146
147#[unsafe(no_mangle)]
148pub unsafe extern "C" fn nil_is_remote(request_id: RequestId) {
149  async_push_ok!(request_id, CLIENT.read().await.is_remote())
150}
151
152#[unsafe(no_mangle)]
153pub unsafe extern "C" fn nil_server_addr(request_id: RequestId) {
154  async_push_ok!(request_id, CLIENT.read().await.server_addr())
155}
156
157#[unsafe(no_mangle)]
158pub unsafe extern "C" fn nil_set_user_agent(request_id: RequestId, json_user_agent: *const c_char) {
159  let f = |user_agent: String| {
160    RUNTIME.spawn(async move {
161      CLIENT
162        .write()
163        .await
164        .set_user_agent(&user_agent);
165
166      queue::push_ok(request_id, ());
167    });
168  };
169
170  unsafe { json::with_ptr(request_id, json_user_agent, f) };
171}
172
173#[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)]
182pub unsafe extern "C" fn nil_update_client(request_id: RequestId, json_options: *const c_char) {
183  let f = |options: UpdateClient| {
184    type OnEvent = fn(Event) -> BoxFuture<'static, ()>;
185    RUNTIME.spawn(async move {
186      let result = CLIENT
187        .write()
188        .await
189        .update::<OnEvent>(options.server)
190        .maybe_world_id(options.world_id)
191        .maybe_world_password(options.world_password)
192        .maybe_player_id(options.player_id)
193        .maybe_player_password(options.player_password)
194        .maybe_authorization_token(options.authorization_token)
195        .call()
196        .await;
197
198      queue::push_result(request_id, Result::from(result));
199    });
200  };
201
202  unsafe { json::with_ptr(request_id, json_options, f) };
203}
204
205#[unsafe(no_mangle)]
206pub unsafe extern "C" fn nil_user_agent(request_id: RequestId) {
207  async_push_ok!(request_id, CLIENT.read().await.user_agent().to_owned())
208}
209
210#[unsafe(no_mangle)]
211pub unsafe extern "C" fn nil_world(request_id: RequestId) {
212  RUNTIME.spawn(async move {
213    match CLIENT.read().await.world() {
214      Some(world) => queue::push_ok(request_id, world),
215      None => queue::push_ok(request_id, None::<&str>),
216    }
217  });
218}
219
220///////////////////////////////
221/////////// SERVER ////////////
222///////////////////////////////
223
224#[unsafe(no_mangle)]
225pub unsafe extern "C" fn nil_add_academy_recruit_order(
226  request_id: RequestId,
227  json_req: *const c_char,
228) {
229  send!(request_id, add_academy_recruit_order, json_req)
230}
231
232#[unsafe(no_mangle)]
233pub unsafe extern "C" fn nil_add_prefecture_build_order(
234  request_id: RequestId,
235  json_req: *const c_char,
236) {
237  send!(request_id, add_prefecture_build_order, json_req)
238}
239
240#[unsafe(no_mangle)]
241pub unsafe extern "C" fn nil_add_stable_recruit_order(
242  request_id: RequestId,
243  json_req: *const c_char,
244) {
245  send!(request_id, add_stable_recruit_order, json_req)
246}
247
248#[unsafe(no_mangle)]
249pub unsafe extern "C" fn nil_add_workshop_recruit_order(
250  request_id: RequestId,
251  json_req: *const c_char,
252) {
253  send!(request_id, add_workshop_recruit_order, json_req)
254}
255
256#[unsafe(no_mangle)]
257pub unsafe extern "C" fn nil_authorize(request_id: RequestId, json_req: *const c_char) {
258  send!(request_id, authorize, json_req)
259}
260
261#[unsafe(no_mangle)]
262pub unsafe extern "C" fn nil_cancel_academy_recruit_order(
263  request_id: RequestId,
264  json_req: *const c_char,
265) {
266  send!(request_id, cancel_academy_recruit_order, json_req)
267}
268
269#[unsafe(no_mangle)]
270pub unsafe extern "C" fn nil_cancel_maneuver(request_id: RequestId, json_req: *const c_char) {
271  send!(request_id, cancel_maneuver, json_req)
272}
273
274#[unsafe(no_mangle)]
275pub unsafe extern "C" fn nil_cancel_prefecture_build_order(
276  request_id: RequestId,
277  json_req: *const c_char,
278) {
279  send!(request_id, cancel_prefecture_build_order, json_req)
280}
281
282#[unsafe(no_mangle)]
283pub unsafe extern "C" fn nil_cancel_stable_recruit_order(
284  request_id: RequestId,
285  json_req: *const c_char,
286) {
287  send!(request_id, cancel_stable_recruit_order, json_req)
288}
289
290#[unsafe(no_mangle)]
291pub unsafe extern "C" fn nil_cancel_workshop_recruit_order(
292  request_id: RequestId,
293  json_req: *const c_char,
294) {
295  send!(request_id, cancel_workshop_recruit_order, json_req)
296}
297
298#[unsafe(no_mangle)]
299pub unsafe extern "C" fn nil_cheat_fill_world(request_id: RequestId, json_req: *const c_char) {
300  send!(request_id, cheat_fill_world, json_req)
301}
302
303#[unsafe(no_mangle)]
304pub unsafe extern "C" fn nil_cheat_get_academy_recruit_queue(
305  request_id: RequestId,
306  json_req: *const c_char,
307) {
308  send!(request_id, cheat_get_academy_recruit_queue, json_req)
309}
310
311#[unsafe(no_mangle)]
312pub unsafe extern "C" fn nil_cheat_get_academy_recruit_queues(
313  request_id: RequestId,
314  json_req: *const c_char,
315) {
316  send!(request_id, cheat_get_academy_recruit_queues, json_req)
317}
318
319#[unsafe(no_mangle)]
320pub unsafe extern "C" fn nil_cheat_get_all_academy_recruit_queues(
321  request_id: RequestId,
322  json_req: *const c_char,
323) {
324  send!(request_id, cheat_get_all_academy_recruit_queues, json_req)
325}
326
327#[unsafe(no_mangle)]
328pub unsafe extern "C" fn nil_cheat_get_all_prefecture_build_queues(
329  request_id: RequestId,
330  json_req: *const c_char,
331) {
332  send!(request_id, cheat_get_all_prefecture_build_queues, json_req)
333}
334
335#[unsafe(no_mangle)]
336pub unsafe extern "C" fn nil_cheat_get_all_stable_recruit_queues(
337  request_id: RequestId,
338  json_req: *const c_char,
339) {
340  send!(request_id, cheat_get_all_stable_recruit_queues, json_req)
341}
342
343#[unsafe(no_mangle)]
344pub unsafe extern "C" fn nil_cheat_get_build_steps(request_id: RequestId, json_req: *const c_char) {
345  send!(request_id, cheat_get_build_steps, json_req)
346}
347
348#[unsafe(no_mangle)]
349pub unsafe extern "C" fn nil_cheat_get_cities(request_id: RequestId, json_req: *const c_char) {
350  send!(request_id, cheat_get_cities, json_req)
351}
352
353#[unsafe(no_mangle)]
354pub unsafe extern "C" fn nil_cheat_get_city(request_id: RequestId, json_req: *const c_char) {
355  send!(request_id, cheat_get_city, json_req)
356}
357
358#[unsafe(no_mangle)]
359pub unsafe extern "C" fn nil_cheat_get_ethics(request_id: RequestId, json_req: *const c_char) {
360  send!(request_id, cheat_get_ethics, json_req)
361}
362
363#[unsafe(no_mangle)]
364pub unsafe extern "C" fn nil_cheat_get_idle_armies_at(
365  request_id: RequestId,
366  json_req: *const c_char,
367) {
368  send!(request_id, cheat_get_idle_armies_at, json_req)
369}
370
371#[unsafe(no_mangle)]
372pub unsafe extern "C" fn nil_cheat_get_idle_personnel_at(
373  request_id: RequestId,
374  json_req: *const c_char,
375) {
376  send!(request_id, cheat_get_idle_personnel_at, json_req)
377}
378
379#[unsafe(no_mangle)]
380pub unsafe extern "C" fn nil_cheat_get_infrastructure(
381  request_id: RequestId,
382  json_req: *const c_char,
383) {
384  send!(request_id, cheat_get_infrastructure, json_req)
385}
386
387#[unsafe(no_mangle)]
388pub unsafe extern "C" fn nil_cheat_get_maneuvers(request_id: RequestId, json_req: *const c_char) {
389  send!(request_id, cheat_get_maneuvers, json_req)
390}
391
392#[unsafe(no_mangle)]
393pub unsafe extern "C" fn nil_cheat_get_maneuvers_of(
394  request_id: RequestId,
395  json_req: *const c_char,
396) {
397  send!(request_id, cheat_get_maneuvers_of, json_req)
398}
399
400#[unsafe(no_mangle)]
401pub unsafe extern "C" fn nil_cheat_get_player(request_id: RequestId, json_req: *const c_char) {
402  send!(request_id, cheat_get_player, json_req)
403}
404
405#[unsafe(no_mangle)]
406pub unsafe extern "C" fn nil_cheat_get_players(request_id: RequestId, json_req: *const c_char) {
407  send!(request_id, cheat_get_players, json_req)
408}
409
410#[unsafe(no_mangle)]
411pub unsafe extern "C" fn nil_cheat_get_prefecture_build_queue(
412  request_id: RequestId,
413  json_req: *const c_char,
414) {
415  send!(request_id, cheat_get_prefecture_build_queue, json_req)
416}
417
418#[unsafe(no_mangle)]
419pub unsafe extern "C" fn nil_cheat_get_prefecture_build_queues(
420  request_id: RequestId,
421  json_req: *const c_char,
422) {
423  send!(request_id, cheat_get_prefecture_build_queues, json_req)
424}
425
426#[unsafe(no_mangle)]
427pub unsafe extern "C" fn nil_cheat_get_resources(request_id: RequestId, json_req: *const c_char) {
428  send!(request_id, cheat_get_resources, json_req)
429}
430
431#[unsafe(no_mangle)]
432pub unsafe extern "C" fn nil_cheat_get_stable_recruit_queue(
433  request_id: RequestId,
434  json_req: *const c_char,
435) {
436  send!(request_id, cheat_get_stable_recruit_queue, json_req)
437}
438
439#[unsafe(no_mangle)]
440pub unsafe extern "C" fn nil_cheat_get_stable_recruit_queues(
441  request_id: RequestId,
442  json_req: *const c_char,
443) {
444  send!(request_id, cheat_get_stable_recruit_queues, json_req)
445}
446
447#[unsafe(no_mangle)]
448pub unsafe extern "C" fn nil_cheat_get_storage_capacity(
449  request_id: RequestId,
450  json_req: *const c_char,
451) {
452  send!(request_id, cheat_get_storage_capacity, json_req)
453}
454
455#[unsafe(no_mangle)]
456pub unsafe extern "C" fn nil_cheat_set_bot_ethics(request_id: RequestId, json_req: *const c_char) {
457  send!(request_id, cheat_set_bot_ethics, json_req)
458}
459
460#[unsafe(no_mangle)]
461pub unsafe extern "C" fn nil_cheat_set_building_level(
462  request_id: RequestId,
463  json_req: *const c_char,
464) {
465  send!(request_id, cheat_set_building_level, json_req)
466}
467
468#[unsafe(no_mangle)]
469pub unsafe extern "C" fn nil_cheat_set_food(request_id: RequestId, json_req: *const c_char) {
470  send!(request_id, cheat_set_food, json_req)
471}
472
473#[unsafe(no_mangle)]
474pub unsafe extern "C" fn nil_cheat_set_iron(request_id: RequestId, json_req: *const c_char) {
475  send!(request_id, cheat_set_iron, json_req)
476}
477
478#[unsafe(no_mangle)]
479pub unsafe extern "C" fn nil_cheat_set_max_food(request_id: RequestId, json_req: *const c_char) {
480  send!(request_id, cheat_set_max_food, json_req)
481}
482
483#[unsafe(no_mangle)]
484pub unsafe extern "C" fn nil_cheat_set_max_infrastructure(
485  request_id: RequestId,
486  json_req: *const c_char,
487) {
488  send!(request_id, cheat_set_max_infrastructure, json_req)
489}
490
491#[unsafe(no_mangle)]
492pub unsafe extern "C" fn nil_cheat_set_max_iron(request_id: RequestId, json_req: *const c_char) {
493  send!(request_id, cheat_set_max_iron, json_req)
494}
495
496#[unsafe(no_mangle)]
497pub unsafe extern "C" fn nil_cheat_set_max_resources(
498  request_id: RequestId,
499  json_req: *const c_char,
500) {
501  send!(request_id, cheat_set_max_resources, json_req)
502}
503
504#[unsafe(no_mangle)]
505pub unsafe extern "C" fn nil_cheat_set_max_silo_resources(
506  request_id: RequestId,
507  json_req: *const c_char,
508) {
509  send!(request_id, cheat_set_max_silo_resources, json_req)
510}
511
512#[unsafe(no_mangle)]
513pub unsafe extern "C" fn nil_cheat_set_max_stone(request_id: RequestId, json_req: *const c_char) {
514  send!(request_id, cheat_set_max_stone, json_req)
515}
516
517#[unsafe(no_mangle)]
518pub unsafe extern "C" fn nil_cheat_set_max_warehouse_resources(
519  request_id: RequestId,
520  json_req: *const c_char,
521) {
522  send!(request_id, cheat_set_max_warehouse_resources, json_req)
523}
524
525#[unsafe(no_mangle)]
526pub unsafe extern "C" fn nil_cheat_set_max_wood(request_id: RequestId, json_req: *const c_char) {
527  send!(request_id, cheat_set_max_wood, json_req)
528}
529
530#[unsafe(no_mangle)]
531pub unsafe extern "C" fn nil_cheat_set_resources(request_id: RequestId, json_req: *const c_char) {
532  send!(request_id, cheat_set_resources, json_req)
533}
534
535#[unsafe(no_mangle)]
536pub unsafe extern "C" fn nil_cheat_set_stability(request_id: RequestId, json_req: *const c_char) {
537  send!(request_id, cheat_set_stability, json_req)
538}
539
540#[unsafe(no_mangle)]
541pub unsafe extern "C" fn nil_cheat_set_stone(request_id: RequestId, json_req: *const c_char) {
542  send!(request_id, cheat_set_stone, json_req)
543}
544
545#[unsafe(no_mangle)]
546pub unsafe extern "C" fn nil_cheat_set_wood(request_id: RequestId, json_req: *const c_char) {
547  send!(request_id, cheat_set_wood, json_req)
548}
549
550#[unsafe(no_mangle)]
551pub unsafe extern "C" fn nil_cheat_skip_round(request_id: RequestId, json_req: *const c_char) {
552  send!(request_id, cheat_skip_round, json_req)
553}
554
555#[unsafe(no_mangle)]
556pub unsafe extern "C" fn nil_cheat_spawn_bot(request_id: RequestId, json_req: *const c_char) {
557  send!(request_id, cheat_spawn_bot, json_req)
558}
559
560#[unsafe(no_mangle)]
561pub unsafe extern "C" fn nil_cheat_spawn_city(request_id: RequestId, json_req: *const c_char) {
562  send!(request_id, cheat_spawn_city, json_req)
563}
564
565#[unsafe(no_mangle)]
566pub unsafe extern "C" fn nil_cheat_spawn_personnel(request_id: RequestId, json_req: *const c_char) {
567  send!(request_id, cheat_spawn_personnel, json_req)
568}
569
570#[unsafe(no_mangle)]
571pub unsafe extern "C" fn nil_create_remote_world(request_id: RequestId, json_req: *const c_char) {
572  send!(request_id, create_remote_world, json_req)
573}
574
575#[unsafe(no_mangle)]
576pub unsafe extern "C" fn nil_create_user(request_id: RequestId, json_req: *const c_char) {
577  send!(request_id, create_user, json_req)
578}
579
580#[unsafe(no_mangle)]
581pub unsafe extern "C" fn nil_delete_remote_world(request_id: RequestId, json_req: *const c_char) {
582  send!(request_id, delete_remote_world, json_req)
583}
584
585#[unsafe(no_mangle)]
586pub unsafe extern "C" fn nil_forward_report(request_id: RequestId, json_req: *const c_char) {
587  send!(request_id, forward_report, json_req)
588}
589
590#[unsafe(no_mangle)]
591pub unsafe extern "C" fn nil_get_academy_recruit_catalog(
592  request_id: RequestId,
593  json_req: *const c_char,
594) {
595  send!(request_id, get_academy_recruit_catalog, json_req)
596}
597
598#[unsafe(no_mangle)]
599pub unsafe extern "C" fn nil_get_armies(request_id: RequestId, json_req: *const c_char) {
600  send!(request_id, get_armies, json_req)
601}
602
603#[unsafe(no_mangle)]
604pub unsafe extern "C" fn nil_get_army(request_id: RequestId, json_req: *const c_char) {
605  send!(request_id, get_army, json_req)
606}
607
608#[unsafe(no_mangle)]
609pub unsafe extern "C" fn nil_get_army_owner(request_id: RequestId, json_req: *const c_char) {
610  send!(request_id, get_army_owner, json_req)
611}
612
613#[unsafe(no_mangle)]
614pub unsafe extern "C" fn nil_get_bot_coords(request_id: RequestId, json_req: *const c_char) {
615  send!(request_id, get_bot_coords, json_req)
616}
617
618#[unsafe(no_mangle)]
619pub unsafe extern "C" fn nil_get_chat_history(request_id: RequestId, json_req: *const c_char) {
620  send!(request_id, get_chat_history, json_req)
621}
622
623#[unsafe(no_mangle)]
624pub unsafe extern "C" fn nil_get_cities(request_id: RequestId, json_req: *const c_char) {
625  send!(request_id, get_cities, json_req)
626}
627
628#[unsafe(no_mangle)]
629pub unsafe extern "C" fn nil_get_city(request_id: RequestId, json_req: *const c_char) {
630  send!(request_id, get_city, json_req)
631}
632
633#[unsafe(no_mangle)]
634pub unsafe extern "C" fn nil_get_city_score(request_id: RequestId, json_req: *const c_char) {
635  send!(request_id, get_city_score, json_req)
636}
637
638#[unsafe(no_mangle)]
639pub unsafe extern "C" fn nil_get_continent_size(request_id: RequestId, json_req: *const c_char) {
640  send!(request_id, get_continent_size, json_req)
641}
642
643#[unsafe(no_mangle)]
644pub unsafe extern "C" fn nil_get_idle_armies_at(request_id: RequestId, json_req: *const c_char) {
645  send!(request_id, get_idle_armies_at, json_req)
646}
647
648#[unsafe(no_mangle)]
649pub unsafe extern "C" fn nil_get_idle_armies_coords(
650  request_id: RequestId,
651  json_req: *const c_char,
652) {
653  send!(request_id, get_idle_armies_coords, json_req)
654}
655
656#[unsafe(no_mangle)]
657pub unsafe extern "C" fn nil_get_maneuver(request_id: RequestId, json_req: *const c_char) {
658  send!(request_id, get_maneuver, json_req)
659}
660
661#[unsafe(no_mangle)]
662pub unsafe extern "C" fn nil_get_player(request_id: RequestId, json_req: *const c_char) {
663  send!(request_id, get_player, json_req)
664}
665
666#[unsafe(no_mangle)]
667pub unsafe extern "C" fn nil_get_player_coords(request_id: RequestId, json_req: *const c_char) {
668  send!(request_id, get_player_coords, json_req)
669}
670
671#[unsafe(no_mangle)]
672pub unsafe extern "C" fn nil_get_player_ids(request_id: RequestId, json_req: *const c_char) {
673  send!(request_id, get_player_ids, json_req)
674}
675
676#[unsafe(no_mangle)]
677pub unsafe extern "C" fn nil_get_player_maintenance(
678  request_id: RequestId,
679  json_req: *const c_char,
680) {
681  send!(request_id, get_player_maintenance, json_req)
682}
683
684#[unsafe(no_mangle)]
685pub unsafe extern "C" fn nil_get_player_military(request_id: RequestId, json_req: *const c_char) {
686  send!(request_id, get_player_military, json_req)
687}
688
689#[unsafe(no_mangle)]
690pub unsafe extern "C" fn nil_get_player_status(request_id: RequestId, json_req: *const c_char) {
691  send!(request_id, get_player_status, json_req)
692}
693
694#[unsafe(no_mangle)]
695pub unsafe extern "C" fn nil_get_player_storage_capacity(
696  request_id: RequestId,
697  json_req: *const c_char,
698) {
699  send!(request_id, get_player_storage_capacity, json_req)
700}
701
702#[unsafe(no_mangle)]
703pub unsafe extern "C" fn nil_get_player_worlds(request_id: RequestId, json_req: *const c_char) {
704  send!(request_id, get_player_worlds, json_req)
705}
706
707#[unsafe(no_mangle)]
708pub unsafe extern "C" fn nil_get_precursor_coords(request_id: RequestId, json_req: *const c_char) {
709  send!(request_id, get_precursor_coords, json_req)
710}
711
712#[unsafe(no_mangle)]
713pub unsafe extern "C" fn nil_get_prefecture_build_catalog(
714  request_id: RequestId,
715  json_req: *const c_char,
716) {
717  send!(request_id, get_prefecture_build_catalog, json_req)
718}
719
720#[unsafe(no_mangle)]
721pub unsafe extern "C" fn nil_get_public_bot(request_id: RequestId, json_req: *const c_char) {
722  send!(request_id, get_public_bot, json_req)
723}
724
725#[unsafe(no_mangle)]
726pub unsafe extern "C" fn nil_get_public_bots(request_id: RequestId, json_req: *const c_char) {
727  send!(request_id, get_public_bots, json_req)
728}
729
730#[unsafe(no_mangle)]
731pub unsafe extern "C" fn nil_get_public_cities(request_id: RequestId, json_req: *const c_char) {
732  send!(request_id, get_public_cities, json_req)
733}
734
735#[unsafe(no_mangle)]
736pub unsafe extern "C" fn nil_get_public_city(request_id: RequestId, json_req: *const c_char) {
737  send!(request_id, get_public_city, json_req)
738}
739
740#[unsafe(no_mangle)]
741pub unsafe extern "C" fn nil_get_public_field(request_id: RequestId, json_req: *const c_char) {
742  send!(request_id, get_public_field, json_req)
743}
744
745#[unsafe(no_mangle)]
746pub unsafe extern "C" fn nil_get_public_fields(request_id: RequestId, json_req: *const c_char) {
747  send!(request_id, get_public_fields, json_req)
748}
749
750#[unsafe(no_mangle)]
751pub unsafe extern "C" fn nil_get_public_player(request_id: RequestId, json_req: *const c_char) {
752  send!(request_id, get_public_player, json_req)
753}
754
755#[unsafe(no_mangle)]
756pub unsafe extern "C" fn nil_get_public_players(request_id: RequestId, json_req: *const c_char) {
757  send!(request_id, get_public_players, json_req)
758}
759
760#[unsafe(no_mangle)]
761pub unsafe extern "C" fn nil_get_public_precursor(request_id: RequestId, json_req: *const c_char) {
762  send!(request_id, get_public_precursor, json_req)
763}
764
765#[unsafe(no_mangle)]
766pub unsafe extern "C" fn nil_get_public_precursors(request_id: RequestId, json_req: *const c_char) {
767  send!(request_id, get_public_precursors, json_req)
768}
769
770#[unsafe(no_mangle)]
771pub unsafe extern "C" fn nil_get_rank(request_id: RequestId, json_req: *const c_char) {
772  send!(request_id, get_rank, json_req)
773}
774
775#[unsafe(no_mangle)]
776pub unsafe extern "C" fn nil_get_ranking(request_id: RequestId, json_req: *const c_char) {
777  send!(request_id, get_ranking, json_req)
778}
779
780#[unsafe(no_mangle)]
781pub unsafe extern "C" fn nil_get_remote_world(request_id: RequestId, json_req: *const c_char) {
782  send!(request_id, get_remote_world, json_req)
783}
784
785#[unsafe(no_mangle)]
786pub unsafe extern "C" fn nil_get_remote_world_limit(request_id: RequestId) {
787  send!(request_id, get_remote_world_limit)
788}
789
790#[unsafe(no_mangle)]
791pub unsafe extern "C" fn nil_get_remote_world_limit_per_user(request_id: RequestId) {
792  send!(request_id, get_remote_world_limit_per_user)
793}
794
795#[unsafe(no_mangle)]
796pub unsafe extern "C" fn nil_get_remote_worlds(request_id: RequestId) {
797  send!(request_id, get_remote_worlds)
798}
799
800#[unsafe(no_mangle)]
801pub unsafe extern "C" fn nil_get_round(request_id: RequestId, json_req: *const c_char) {
802  send!(request_id, get_round, json_req)
803}
804
805#[unsafe(no_mangle)]
806pub unsafe extern "C" fn nil_get_server_kind(request_id: RequestId) {
807  send!(request_id, get_server_kind)
808}
809
810#[unsafe(no_mangle)]
811pub unsafe extern "C" fn nil_get_stable_recruit_catalog(
812  request_id: RequestId,
813  json_req: *const c_char,
814) {
815  send!(request_id, get_stable_recruit_catalog, json_req)
816}
817
818#[unsafe(no_mangle)]
819pub unsafe extern "C" fn nil_get_workshop_recruit_catalog(
820  request_id: RequestId,
821  json_req: *const c_char,
822) {
823  send!(request_id, get_workshop_recruit_catalog, json_req)
824}
825
826#[unsafe(no_mangle)]
827pub unsafe extern "C" fn nil_get_world_bots(request_id: RequestId, json_req: *const c_char) {
828  send!(request_id, get_world_bots, json_req)
829}
830
831#[unsafe(no_mangle)]
832pub unsafe extern "C" fn nil_get_world_config(request_id: RequestId, json_req: *const c_char) {
833  send!(request_id, get_world_config, json_req)
834}
835
836#[unsafe(no_mangle)]
837pub unsafe extern "C" fn nil_get_world_personnel(request_id: RequestId, json_req: *const c_char) {
838  send!(request_id, get_world_personnel, json_req)
839}
840
841#[unsafe(no_mangle)]
842pub unsafe extern "C" fn nil_get_world_players(request_id: RequestId, json_req: *const c_char) {
843  send!(request_id, get_world_players, json_req)
844}
845
846#[unsafe(no_mangle)]
847pub unsafe extern "C" fn nil_get_world_precursors(request_id: RequestId, json_req: *const c_char) {
848  send!(request_id, get_world_precursors, json_req)
849}
850
851#[unsafe(no_mangle)]
852pub unsafe extern "C" fn nil_get_world_stats(request_id: RequestId, json_req: *const c_char) {
853  send!(request_id, get_world_stats, json_req)
854}
855
856#[unsafe(no_mangle)]
857pub unsafe extern "C" fn nil_player_exists(request_id: RequestId, json_req: *const c_char) {
858  send!(request_id, player_exists, json_req)
859}
860
861#[unsafe(no_mangle)]
862pub unsafe extern "C" fn nil_push_chat_message(request_id: RequestId, json_req: *const c_char) {
863  send!(request_id, push_chat_message, json_req)
864}
865
866#[unsafe(no_mangle)]
867pub unsafe extern "C" fn nil_rename_city(request_id: RequestId, json_req: *const c_char) {
868  send!(request_id, rename_city, json_req)
869}
870
871#[unsafe(no_mangle)]
872pub unsafe extern "C" fn nil_request_maneuver(request_id: RequestId, json_req: *const c_char) {
873  send!(request_id, request_maneuver, json_req)
874}
875
876#[unsafe(no_mangle)]
877pub unsafe extern "C" fn nil_save_local_world(request_id: RequestId, json_req: *const c_char) {
878  send!(request_id, save_local_world, json_req)
879}
880
881#[unsafe(no_mangle)]
882pub unsafe extern "C" fn nil_search_city(request_id: RequestId, json_req: *const c_char) {
883  send!(request_id, search_city, json_req)
884}
885
886#[unsafe(no_mangle)]
887pub unsafe extern "C" fn nil_search_public_city(request_id: RequestId, json_req: *const c_char) {
888  send!(request_id, search_public_city, json_req)
889}
890
891#[unsafe(no_mangle)]
892pub unsafe extern "C" fn nil_server_version(request_id: RequestId) {
893  send!(request_id, version)
894}
895
896#[unsafe(no_mangle)]
897pub unsafe extern "C" fn nil_set_player_ready(request_id: RequestId, json_req: *const c_char) {
898  send!(request_id, set_player_ready, json_req)
899}
900
901#[unsafe(no_mangle)]
902pub unsafe extern "C" fn nil_set_player_status(request_id: RequestId, json_req: *const c_char) {
903  send!(request_id, set_player_status, json_req)
904}
905
906#[unsafe(no_mangle)]
907pub unsafe extern "C" fn nil_simulate_battle(request_id: RequestId, json_req: *const c_char) {
908  send!(request_id, simulate_battle, json_req)
909}
910
911#[unsafe(no_mangle)]
912pub unsafe extern "C" fn nil_spawn_player(request_id: RequestId, json_req: *const c_char) {
913  send!(request_id, spawn_player, json_req)
914}
915
916#[unsafe(no_mangle)]
917pub unsafe extern "C" fn nil_start_round(request_id: RequestId, json_req: *const c_char) {
918  send!(request_id, start_round, json_req)
919}
920
921#[unsafe(no_mangle)]
922pub unsafe extern "C" fn nil_toggle_building(request_id: RequestId, json_req: *const c_char) {
923  send!(request_id, toggle_building, json_req)
924}
925
926#[unsafe(no_mangle)]
927pub unsafe extern "C" fn nil_user_exists(request_id: RequestId, json_req: *const c_char) {
928  send!(request_id, user_exists, json_req)
929}
930
931#[unsafe(no_mangle)]
932pub unsafe extern "C" fn nil_validate_token(request_id: RequestId, json_req: *const c_char) {
933  send!(request_id, validate_token, json_req)
934}