1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//! Player actions and renames the loader asks a mod to answer.
use c_void;
use crate;
/// A question the loader asks a mod about its player actions, registered
/// with [`HostApi::actions`](super::HostApi::actions).
///
/// # Examples
///
/// ```
/// use enshwick::abi::{ActionCall, Header, PlayerInfo, Str};
///
/// let call = ActionCall {
/// header: Header::of::<ActionCall>(),
/// kind: ActionCall::RUN,
/// language: 0,
/// player: PlayerInfo {
/// header: Header::of::<PlayerInfo>(),
/// slot: 0,
/// entity: enshwick::Entity(2),
/// key: enshwick::PlayerKey::new(7),
/// permissions: 0,
/// name_len: 0,
/// name: [0; 64],
/// },
/// action: Str::new("access"),
/// args: Str::new("p0000000000000009\tb1"),
/// };
/// assert_eq!(call.kind, ActionCall::RUN);
/// ```
impl_headed!;
/// A mod's answer to the loader's questions about its player actions: the
/// call, the pointer given at registration and where to write the reply,
/// which stays valid until the callback runs again.
pub type ActionFn =
unsafe extern "system" fn;
/// A mod's status source: the pointer given at registration and where to
/// write the mod's lines for the loader's status summary. The text stays
/// valid until the source runs again; empty for none.
pub type StatusFn = unsafe extern "system" fn;
/// A player renaming an entity, handed to the filters registered with
/// [`HostApi::rename_filter`](super::HostApi::rename_filter) before the game applies it.
///
/// # Examples
///
/// ```
/// use enshwick::abi::{Header, PlayerInfo, RenameCall, Str};
///
/// let call = RenameCall {
/// header: Header::of::<RenameCall>(),
/// entity: enshwick::Entity(4096),
/// known: 0,
/// player: PlayerInfo {
/// header: Header::of::<PlayerInfo>(),
/// slot: 0,
/// entity: enshwick::Entity(0),
/// key: enshwick::PlayerKey::new(0),
/// permissions: 0,
/// name_len: 0,
/// name: [0; 64],
/// },
/// text: Str::new("Tools"),
/// };
/// assert_eq!(call.known, 0);
/// ```
impl_headed!;
/// A mod's rename filter: the call and the pointer given at registration;
/// returns 1 to let the rename through, 0 to refuse it.
pub type RenameCallFn = unsafe extern "system" fn ;