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