Skip to main content

OmpComponent

Struct OmpComponent 

Source
pub struct OmpComponent {
    pub uid: u64,
    pub plugin_ptr: *mut (),
    /* private fields */
}
Expand description

Rust object with a layout compatible with Open Multiplayer’s IComponent*.

The layout differs between Linux (GCC i686) and Windows MSVC i686 because FlatHashMap (robin_hood::unordered_flat_map) has a different sizeof on each platform. The offset of uid_vtable (IUIDProvider subobject) is hardcoded by the server and was confirmed via disasm:

  • Linux/GCC i686: uid_vtable at offset 40.
  • MSVC i686: uid_vtable at offset 56 (server emits add ecx, 0x38 when calling getUID() on IComponent*).

Layout on i686 Linux (GCC / Itanium ABI):

offset  0: vtable*        (primary IExtensible/IComponent)
offset  4: _misc_ext[36]  (robin_hood::unordered_flat_map, zero-init = empty)
offset 40: uid_vtable*    (secondary IUIDProvider)
offset 44: uid             (UID = u64)
offset 52: plugin_ptr      (*mut ())

Layout on i686 Windows (MSVC ABI):

offset  0: vtable*        (primary IExtensible/IComponent)
offset  4: _misc_ext[52]  (padding + robin_hood + trailing pad, zero-init)
offset 56: uid_vtable*    (secondary IUIDProvider)
offset 60: _uid_pad[4]    (padding to align uid (u64) to 8 bytes)
offset 64: uid             (UID = u64)
offset 72: plugin_ptr      (*mut ())

Fields§

§uid: u64

Unique UID for this component.

§plugin_ptr: *mut ()

Pointer to the Rust plugin (SampPlugin).

Implementations§

Source§

impl OmpComponent

Source

pub fn new( vtable: *const IComponentVTable, uid_vtable: *const IUIDProviderVTable, uid: u64, ) -> OmpComponent

Creates a new OmpComponent with a layout compatible with the platform ABI.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.