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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
//! `ICore` — generated by `cargo xtask gen-omp` from `core.hpp`.
//! Implemented by `Core` in the server's `omp-server`.
//!
//! Do not edit: change `xtask/omp-wrappers.toml` or the generator and
//! regenerate. Slots are clang's layout of the header for each ABI, checked
//! against the official binaries by `cargo xtask check-abi --generated`.
#![allow(unused_imports)]
use crate::omp::containers::{FlatSet, HybridString, Pair, Span};
use crate::omp::types::{
Colour, GTAQuat, Hours, Microseconds, Milliseconds, Minutes, Seconds, StringView, TimePoint,
UID, Vector2, Vector3, Vector4, WorldTimePoint,
};
use crate::omp::vtable::{call_vtable_small_struct, opaque, slots, virtual_fns};
use crate::omp::*;
slots! {
/// `SemanticVersion ICore::getVersion()`
SLOT_GET_VERSION: usize = 6, 5;
/// `int ICore::getNetworkBitStreamVersion()`
SLOT_GET_NETWORK_BIT_STREAM_VERSION: usize = 7, 6;
/// `IPlayerPool & ICore::getPlayers()`
SLOT_GET_PLAYERS: usize = 8, 7;
/// `IEventDispatcher<CoreEventHandler> & ICore::getEventDispatcher()`
SLOT_GET_EVENT_DISPATCHER: usize = 9, 8;
/// `IConfig & ICore::getConfig()`
SLOT_GET_CONFIG: usize = 10, 9;
/// `const FlatPtrHashSet<INetwork> & ICore::getNetworks()`
SLOT_GET_NETWORKS: usize = 11, 10;
/// `unsigned int ICore::getTickCount()`
SLOT_GET_TICK_COUNT: usize = 12, 11;
/// `void ICore::setGravity(float)`
SLOT_SET_GRAVITY: usize = 13, 12;
/// `float ICore::getGravity()`
SLOT_GET_GRAVITY: usize = 14, 13;
/// `void ICore::setWeather(int)`
SLOT_SET_WEATHER: usize = 15, 14;
/// `void ICore::setWorldTime(Hours)`
SLOT_SET_WORLD_TIME: usize = 16, 15;
/// `void ICore::useStuntBonuses(bool)`
SLOT_USE_STUNT_BONUSES: usize = 17, 16;
/// `void ICore::setData(SettableCoreDataType, StringView)`
SLOT_SET_DATA: usize = 18, 17;
/// `void ICore::setThreadSleep(Microseconds)`
SLOT_SET_THREAD_SLEEP: usize = 19, 18;
/// `void ICore::useDynTicks(const bool)`
SLOT_USE_DYN_TICKS: usize = 20, 19;
/// `void ICore::resetAll()`
SLOT_RESET_ALL: usize = 21, 20;
/// `void ICore::reloadAll()`
SLOT_RELOAD_ALL: usize = 22, 21;
/// `StringView ICore::getWeaponName(PlayerWeapon)`
SLOT_GET_WEAPON_NAME: usize = 23, 22;
/// `void ICore::connectBot(StringView, StringView)`
SLOT_CONNECT_BOT: usize = 24, 23;
/// `void ICore::requestHTTP(HTTPResponseHandler *, HTTPRequestType, StringView, StringView)`
SLOT_REQUEST_HTTP: usize = 25, 24;
/// `unsigned int ICore::tickRate()`
SLOT_TICK_RATE: usize = 26, 25;
/// `bool ICore::sha256(StringView, StringView, StaticArray<char, 64 + 1> &)`
SLOT_SHA256: usize = 27, 26;
/// `StringView ICore::getVersionHash()`
SLOT_GET_VERSION_HASH: usize = 28, 27;
/// `void ICore::requestHTTP4(HTTPResponseHandler *, HTTPRequestType, StringView, StringView)`
SLOT_REQUEST_HTTP4: usize = 29, 28;
}
virtual_fns! {
/// `int ICore::getNetworkBitStreamVersion()`.
///
/// # Safety
/// `core` must be a live `ICore`.
#[must_use]
pub fn core_network_bit_stream_version(
core: ICore,
) -> i32 = [0, SLOT_GET_NETWORK_BIT_STREAM_VERSION] or 0;
/// `IPlayerPool & ICore::getPlayers()`.
///
/// # Safety
/// `core` must be a live `ICore`.
#[must_use]
pub fn core_players(
core: ICore,
) -> *mut IPlayerPool = [0, SLOT_GET_PLAYERS] or std::ptr::null_mut();
/// `IEventDispatcher<CoreEventHandler> & ICore::getEventDispatcher()`.
///
/// # Safety
/// `core` must be a live `ICore`.
#[must_use]
pub fn core_event_dispatcher(
core: ICore,
) -> *mut EventDispatcher<CoreHandler> = [0, SLOT_GET_EVENT_DISPATCHER] or std::ptr::null_mut();
/// `IConfig & ICore::getConfig()`.
///
/// # Safety
/// `core` must be a live `ICore`.
#[must_use]
pub fn core_config(core: ICore) -> *mut IConfig = [0, SLOT_GET_CONFIG] or std::ptr::null_mut();
/// `const FlatPtrHashSet<INetwork> & ICore::getNetworks()`.
///
/// # Safety
/// `core` must be a live `ICore`.
#[must_use]
pub fn core_networks(
core: ICore,
) -> *const FlatSet<std::ffi::c_void> = [0, SLOT_GET_NETWORKS] or std::ptr::null();
/// `unsigned int ICore::getTickCount()`.
///
/// # Safety
/// `core` must be a live `ICore`.
#[must_use]
pub fn core_tick_count(core: ICore) -> u32 = [0, SLOT_GET_TICK_COUNT] or 0;
/// `void ICore::setGravity(float)`.
///
/// # Safety
/// `core` must be a live `ICore`.
pub fn core_set_gravity(core: ICore, gravity: f32) = [0, SLOT_SET_GRAVITY];
/// `float ICore::getGravity()`.
///
/// # Safety
/// `core` must be a live `ICore`.
#[must_use]
pub fn core_gravity(core: ICore) -> f32 = [0, SLOT_GET_GRAVITY] or 0.0;
/// `void ICore::setWeather(int)`.
///
/// # Safety
/// `core` must be a live `ICore`.
pub fn core_set_weather(core: ICore, weather: i32) = [0, SLOT_SET_WEATHER];
/// `void ICore::setWorldTime(Hours)`.
///
/// # Safety
/// `core` must be a live `ICore`.
pub fn core_set_world_time(core: ICore, time: Hours) = [0, SLOT_SET_WORLD_TIME];
/// `void ICore::useStuntBonuses(bool)`.
///
/// # Safety
/// `core` must be a live `ICore`.
pub fn core_use_stunt_bonuses(core: ICore, enable: bool) = [0, SLOT_USE_STUNT_BONUSES];
/// `void ICore::setData(SettableCoreDataType, StringView)`.
///
/// # Safety
/// `core` must be a live `ICore`.
pub fn core_set_data(core: ICore, type_value: i32, data: StringView) = [0, SLOT_SET_DATA];
/// `void ICore::setThreadSleep(Microseconds)`.
///
/// # Safety
/// `core` must be a live `ICore`.
pub fn core_set_thread_sleep(core: ICore, value: Microseconds) = [0, SLOT_SET_THREAD_SLEEP];
/// `void ICore::useDynTicks(const bool)`.
///
/// # Safety
/// `core` must be a live `ICore`.
pub fn core_use_dyn_ticks(core: ICore, enable: bool) = [0, SLOT_USE_DYN_TICKS];
/// `void ICore::resetAll()`.
///
/// # Safety
/// `core` must be a live `ICore`.
pub fn core_reset_all(core: ICore) = [0, SLOT_RESET_ALL];
/// `void ICore::reloadAll()`.
///
/// # Safety
/// `core` must be a live `ICore`.
pub fn core_reload_all(core: ICore) = [0, SLOT_RELOAD_ALL];
/// `void ICore::connectBot(StringView, StringView)`.
///
/// # Safety
/// `core` must be a live `ICore`.
pub fn core_connect_bot(
core: ICore,
name: StringView,
script: StringView,
) = [0, SLOT_CONNECT_BOT];
/// `void ICore::requestHTTP(HTTPResponseHandler *, HTTPRequestType, StringView, StringView)`.
///
/// # Safety
/// `core` must be a live `ICore`.
pub fn core_request_http(
core: ICore,
handler: *mut HTTPResponseHandler,
type_value: i32,
url: StringView,
data: StringView,
) = [0, SLOT_REQUEST_HTTP];
/// `unsigned int ICore::tickRate()`.
///
/// # Safety
/// `core` must be a live `ICore`.
#[must_use]
pub fn core_tick_rate(core: ICore) -> u32 = [0, SLOT_TICK_RATE] or 0;
/// `bool ICore::sha256(StringView, StringView, StaticArray<char, 64 + 1> &)`.
///
/// # Safety
/// `core` must be a live `ICore`.
#[must_use]
pub fn core_sha256(
core: ICore,
password: StringView,
salt: StringView,
output: &mut [i8; 65],
) -> bool = [0, SLOT_SHA256] or false;
/// `void ICore::requestHTTP4(HTTPResponseHandler *, HTTPRequestType, StringView, StringView)`.
///
/// # Safety
/// `core` must be a live `ICore`.
pub fn core_request_http4(
core: ICore,
handler: *mut HTTPResponseHandler,
type_value: i32,
url: StringView,
data: StringView,
) = [0, SLOT_REQUEST_HTTP4];
}
/// `SemanticVersion ICore::getVersion()`.
///
/// # Safety
/// `core` must be a live `ICore`.
#[must_use]
pub unsafe fn core_version(core: *mut ICore) -> Option<SemanticVersion> {
call_vtable_small_struct!(
core.cast::<u8>(),
0,
SLOT_GET_VERSION,
SemanticVersion,
SemanticVersion::new(0, 0, 0)
)
}
/// `StringView ICore::getWeaponName(PlayerWeapon)`.
///
/// # Safety
/// `core` must be a live `ICore`.
#[must_use]
pub unsafe fn core_weapon_name(core: *mut ICore, weapon: i32) -> Option<String> {
let view = call_vtable_small_struct!(
core.cast::<u8>(),
0,
SLOT_GET_WEAPON_NAME,
StringView,
StringView::EMPTY,
(i32)(weapon)
)?;
unsafe { view.to_owned_string() }
}
/// `StringView ICore::getVersionHash()`.
///
/// # Safety
/// `core` must be a live `ICore`.
#[must_use]
pub unsafe fn core_version_hash(core: *mut ICore) -> Option<String> {
let view = call_vtable_small_struct!(
core.cast::<u8>(),
0,
SLOT_GET_VERSION_HASH,
StringView,
StringView::EMPTY
)?;
unsafe { view.to_owned_string() }
}