Skip to main content

samp_sdk/omp/generated/
core.rs

1//! `ICore` — generated by `cargo xtask gen-omp` from `core.hpp`.
2//! Implemented by `Core` in the server's `omp-server`.
3//!
4//! Do not edit: change `xtask/omp-wrappers.toml` or the generator and
5//! regenerate. Slots are clang's layout of the header for each ABI, checked
6//! against the official binaries by `cargo xtask check-abi --generated`.
7
8#![allow(unused_imports)]
9
10use crate::omp::containers::{FlatSet, HybridString, Pair, Span};
11use crate::omp::types::{
12    Colour, GTAQuat, Hours, Microseconds, Milliseconds, Minutes, Seconds, StringView, TimePoint,
13    UID, Vector2, Vector3, Vector4, WorldTimePoint,
14};
15use crate::omp::vtable::{call_vtable_small_struct, opaque, slots, virtual_fns};
16use crate::omp::*;
17
18slots! {
19    /// `SemanticVersion ICore::getVersion()`
20    SLOT_GET_VERSION: usize = 6, 5;
21    /// `int ICore::getNetworkBitStreamVersion()`
22    SLOT_GET_NETWORK_BIT_STREAM_VERSION: usize = 7, 6;
23    /// `IPlayerPool & ICore::getPlayers()`
24    SLOT_GET_PLAYERS: usize = 8, 7;
25    /// `IEventDispatcher<CoreEventHandler> & ICore::getEventDispatcher()`
26    SLOT_GET_EVENT_DISPATCHER: usize = 9, 8;
27    /// `IConfig & ICore::getConfig()`
28    SLOT_GET_CONFIG: usize = 10, 9;
29    /// `const FlatPtrHashSet<INetwork> & ICore::getNetworks()`
30    SLOT_GET_NETWORKS: usize = 11, 10;
31    /// `unsigned int ICore::getTickCount()`
32    SLOT_GET_TICK_COUNT: usize = 12, 11;
33    /// `void ICore::setGravity(float)`
34    SLOT_SET_GRAVITY: usize = 13, 12;
35    /// `float ICore::getGravity()`
36    SLOT_GET_GRAVITY: usize = 14, 13;
37    /// `void ICore::setWeather(int)`
38    SLOT_SET_WEATHER: usize = 15, 14;
39    /// `void ICore::setWorldTime(Hours)`
40    SLOT_SET_WORLD_TIME: usize = 16, 15;
41    /// `void ICore::useStuntBonuses(bool)`
42    SLOT_USE_STUNT_BONUSES: usize = 17, 16;
43    /// `void ICore::setData(SettableCoreDataType, StringView)`
44    SLOT_SET_DATA: usize = 18, 17;
45    /// `void ICore::setThreadSleep(Microseconds)`
46    SLOT_SET_THREAD_SLEEP: usize = 19, 18;
47    /// `void ICore::useDynTicks(const bool)`
48    SLOT_USE_DYN_TICKS: usize = 20, 19;
49    /// `void ICore::resetAll()`
50    SLOT_RESET_ALL: usize = 21, 20;
51    /// `void ICore::reloadAll()`
52    SLOT_RELOAD_ALL: usize = 22, 21;
53    /// `StringView ICore::getWeaponName(PlayerWeapon)`
54    SLOT_GET_WEAPON_NAME: usize = 23, 22;
55    /// `void ICore::connectBot(StringView, StringView)`
56    SLOT_CONNECT_BOT: usize = 24, 23;
57    /// `void ICore::requestHTTP(HTTPResponseHandler *, HTTPRequestType, StringView, StringView)`
58    SLOT_REQUEST_HTTP: usize = 25, 24;
59    /// `unsigned int ICore::tickRate()`
60    SLOT_TICK_RATE: usize = 26, 25;
61    /// `bool ICore::sha256(StringView, StringView, StaticArray<char, 64 + 1> &)`
62    SLOT_SHA256: usize = 27, 26;
63    /// `StringView ICore::getVersionHash()`
64    SLOT_GET_VERSION_HASH: usize = 28, 27;
65    /// `void ICore::requestHTTP4(HTTPResponseHandler *, HTTPRequestType, StringView, StringView)`
66    SLOT_REQUEST_HTTP4: usize = 29, 28;
67}
68
69virtual_fns! {
70    /// `int ICore::getNetworkBitStreamVersion()`.
71    ///
72    /// # Safety
73    /// `core` must be a live `ICore`.
74    #[must_use]
75    pub fn core_network_bit_stream_version(
76        core: ICore,
77    ) -> i32 = [0, SLOT_GET_NETWORK_BIT_STREAM_VERSION] or 0;
78
79    /// `IPlayerPool & ICore::getPlayers()`.
80    ///
81    /// # Safety
82    /// `core` must be a live `ICore`.
83    #[must_use]
84    pub fn core_players(
85        core: ICore,
86    ) -> *mut IPlayerPool = [0, SLOT_GET_PLAYERS] or std::ptr::null_mut();
87
88    /// `IEventDispatcher<CoreEventHandler> & ICore::getEventDispatcher()`.
89    ///
90    /// # Safety
91    /// `core` must be a live `ICore`.
92    #[must_use]
93    pub fn core_event_dispatcher(
94        core: ICore,
95    ) -> *mut EventDispatcher<CoreHandler> = [0, SLOT_GET_EVENT_DISPATCHER] or std::ptr::null_mut();
96
97    /// `IConfig & ICore::getConfig()`.
98    ///
99    /// # Safety
100    /// `core` must be a live `ICore`.
101    #[must_use]
102    pub fn core_config(core: ICore) -> *mut IConfig = [0, SLOT_GET_CONFIG] or std::ptr::null_mut();
103
104    /// `const FlatPtrHashSet<INetwork> & ICore::getNetworks()`.
105    ///
106    /// # Safety
107    /// `core` must be a live `ICore`.
108    #[must_use]
109    pub fn core_networks(
110        core: ICore,
111    ) -> *const FlatSet<std::ffi::c_void> = [0, SLOT_GET_NETWORKS] or std::ptr::null();
112
113    /// `unsigned int ICore::getTickCount()`.
114    ///
115    /// # Safety
116    /// `core` must be a live `ICore`.
117    #[must_use]
118    pub fn core_tick_count(core: ICore) -> u32 = [0, SLOT_GET_TICK_COUNT] or 0;
119
120    /// `void ICore::setGravity(float)`.
121    ///
122    /// # Safety
123    /// `core` must be a live `ICore`.
124    pub fn core_set_gravity(core: ICore, gravity: f32) = [0, SLOT_SET_GRAVITY];
125
126    /// `float ICore::getGravity()`.
127    ///
128    /// # Safety
129    /// `core` must be a live `ICore`.
130    #[must_use]
131    pub fn core_gravity(core: ICore) -> f32 = [0, SLOT_GET_GRAVITY] or 0.0;
132
133    /// `void ICore::setWeather(int)`.
134    ///
135    /// # Safety
136    /// `core` must be a live `ICore`.
137    pub fn core_set_weather(core: ICore, weather: i32) = [0, SLOT_SET_WEATHER];
138
139    /// `void ICore::setWorldTime(Hours)`.
140    ///
141    /// # Safety
142    /// `core` must be a live `ICore`.
143    pub fn core_set_world_time(core: ICore, time: Hours) = [0, SLOT_SET_WORLD_TIME];
144
145    /// `void ICore::useStuntBonuses(bool)`.
146    ///
147    /// # Safety
148    /// `core` must be a live `ICore`.
149    pub fn core_use_stunt_bonuses(core: ICore, enable: bool) = [0, SLOT_USE_STUNT_BONUSES];
150
151    /// `void ICore::setData(SettableCoreDataType, StringView)`.
152    ///
153    /// # Safety
154    /// `core` must be a live `ICore`.
155    pub fn core_set_data(core: ICore, type_value: i32, data: StringView) = [0, SLOT_SET_DATA];
156
157    /// `void ICore::setThreadSleep(Microseconds)`.
158    ///
159    /// # Safety
160    /// `core` must be a live `ICore`.
161    pub fn core_set_thread_sleep(core: ICore, value: Microseconds) = [0, SLOT_SET_THREAD_SLEEP];
162
163    /// `void ICore::useDynTicks(const bool)`.
164    ///
165    /// # Safety
166    /// `core` must be a live `ICore`.
167    pub fn core_use_dyn_ticks(core: ICore, enable: bool) = [0, SLOT_USE_DYN_TICKS];
168
169    /// `void ICore::resetAll()`.
170    ///
171    /// # Safety
172    /// `core` must be a live `ICore`.
173    pub fn core_reset_all(core: ICore) = [0, SLOT_RESET_ALL];
174
175    /// `void ICore::reloadAll()`.
176    ///
177    /// # Safety
178    /// `core` must be a live `ICore`.
179    pub fn core_reload_all(core: ICore) = [0, SLOT_RELOAD_ALL];
180
181    /// `void ICore::connectBot(StringView, StringView)`.
182    ///
183    /// # Safety
184    /// `core` must be a live `ICore`.
185    pub fn core_connect_bot(
186        core: ICore,
187        name: StringView,
188        script: StringView,
189    ) = [0, SLOT_CONNECT_BOT];
190
191    /// `void ICore::requestHTTP(HTTPResponseHandler *, HTTPRequestType, StringView, StringView)`.
192    ///
193    /// # Safety
194    /// `core` must be a live `ICore`.
195    pub fn core_request_http(
196        core: ICore,
197        handler: *mut HTTPResponseHandler,
198        type_value: i32,
199        url: StringView,
200        data: StringView,
201    ) = [0, SLOT_REQUEST_HTTP];
202
203    /// `unsigned int ICore::tickRate()`.
204    ///
205    /// # Safety
206    /// `core` must be a live `ICore`.
207    #[must_use]
208    pub fn core_tick_rate(core: ICore) -> u32 = [0, SLOT_TICK_RATE] or 0;
209
210    /// `bool ICore::sha256(StringView, StringView, StaticArray<char, 64 + 1> &)`.
211    ///
212    /// # Safety
213    /// `core` must be a live `ICore`.
214    #[must_use]
215    pub fn core_sha256(
216        core: ICore,
217        password: StringView,
218        salt: StringView,
219        output: &mut [i8; 65],
220    ) -> bool = [0, SLOT_SHA256] or false;
221
222    /// `void ICore::requestHTTP4(HTTPResponseHandler *, HTTPRequestType, StringView, StringView)`.
223    ///
224    /// # Safety
225    /// `core` must be a live `ICore`.
226    pub fn core_request_http4(
227        core: ICore,
228        handler: *mut HTTPResponseHandler,
229        type_value: i32,
230        url: StringView,
231        data: StringView,
232    ) = [0, SLOT_REQUEST_HTTP4];
233}
234
235/// `SemanticVersion ICore::getVersion()`.
236///
237/// # Safety
238/// `core` must be a live `ICore`.
239#[must_use]
240pub unsafe fn core_version(core: *mut ICore) -> Option<SemanticVersion> {
241    call_vtable_small_struct!(
242        core.cast::<u8>(),
243        0,
244        SLOT_GET_VERSION,
245        SemanticVersion,
246        SemanticVersion::new(0, 0, 0)
247    )
248}
249
250/// `StringView ICore::getWeaponName(PlayerWeapon)`.
251///
252/// # Safety
253/// `core` must be a live `ICore`.
254#[must_use]
255pub unsafe fn core_weapon_name(core: *mut ICore, weapon: i32) -> Option<String> {
256    let view = call_vtable_small_struct!(
257        core.cast::<u8>(),
258        0,
259        SLOT_GET_WEAPON_NAME,
260        StringView,
261        StringView::EMPTY,
262        (i32)(weapon)
263    )?;
264    unsafe { view.to_owned_string() }
265}
266
267/// `StringView ICore::getVersionHash()`.
268///
269/// # Safety
270/// `core` must be a live `ICore`.
271#[must_use]
272pub unsafe fn core_version_hash(core: *mut ICore) -> Option<String> {
273    let view = call_vtable_small_struct!(
274        core.cast::<u8>(),
275        0,
276        SLOT_GET_VERSION_HASH,
277        StringView,
278        StringView::EMPTY
279    )?;
280    unsafe { view.to_owned_string() }
281}