Skip to content

Commit

Permalink
change indentation in some macros (where rustfmt did not)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxshady committed Sep 22, 2024
1 parent 004d074 commit f4bfb67
Show file tree
Hide file tree
Showing 14 changed files with 921 additions and 921 deletions.
56 changes: 28 additions & 28 deletions altv_module/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
#[macro_export]
macro_rules! on_base_object_event {
($method_name:ident, $resource_name:expr, $base_object:expr) => {
paste::paste! {
RESOURCE_MANAGER_INSTANCE.with(|manager| {
let stringified_method_name = stringify!([$method_name]);
($method_name:ident, $resource_name:expr, $base_object:expr) => {
paste::paste! {
RESOURCE_MANAGER_INSTANCE.with(|manager| {
let stringified_method_name = stringify!([$method_name]);

let manager = manager.borrow();
if manager.is_pending(&$resource_name) {
logger::debug!(
"{} resource start is pending: {}",
stringified_method_name,
$resource_name
);
return;
}
let manager = manager.borrow();
if manager.is_pending(&$resource_name) {
logger::debug!(
"{} resource start is pending: {}",
stringified_method_name,
$resource_name
);
return;
}

let base_object_type = unsafe { altv_sdk::helpers::get_base_object_type($base_object.as_ptr()) };
let base_object_type = unsafe { altv_sdk::helpers::get_base_object_type($base_object.as_ptr()) };

logger::debug!(
"{} type: {:?}",
stringified_method_name,
base_object_type
);
logger::debug!(
"{} type: {:?}",
stringified_method_name,
base_object_type
);

manager
.get_resource_for_module_by_name($resource_name)
.unwrap_or_else(|| {
panic!("{} resource: {:?} get_resource_for_module_by_path failed", stringified_method_name, $resource_name);
})
.[<$method_name>]($base_object, base_object_type);
});
}
};
manager
.get_resource_for_module_by_name($resource_name)
.unwrap_or_else(|| {
panic!("{} resource: {:?} get_resource_for_module_by_path failed", stringified_method_name, $resource_name);
})
.[<$method_name>]($base_object, base_object_type);
});
}
};
}
142 changes: 71 additions & 71 deletions core_resource/src/base_objects/extra_pools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,87 +13,87 @@ mod world_object;
pub use world_object::{WorldObject, WorldObjectRawPtr};

macro_rules! extra_pool_enum {
(@internal
$any_name:ident,
$name:ident,
$raw_ptr_type:ty: [ $(
$variant:ident,
$container:ty,
$wrapper:ty;
)+ ]
) => {
paste::paste! {
#[derive(Debug)]
pub enum $any_name { $(
$variant($container),
)+ }
(@internal
$any_name:ident,
$name:ident,
$raw_ptr_type:ty: [ $(
$variant:ident,
$container:ty,
$wrapper:ty;
)+ ]
) => {
paste::paste! {
#[derive(Debug)]
pub enum $any_name { $(
$variant($container),
)+ }

impl $any_name {
#[allow(dead_code)]
pub(crate) fn raw_ptr(&self) -> SomeResult<$raw_ptr_type> {
use super::inherit_ptrs::traits::*;
match self { $(
$any_name::$variant(e) => Ok(e.inherit_ptrs()?.[<$name:snake>]()),
)+}
}
}

impl TryFrom<AnyBaseObject> for $any_name {
type Error = anyhow::Error;
fn try_from(value: AnyBaseObject) -> Result<Self, Self::Error> {
Ok(match value {
$(
AnyBaseObject::$variant(e) => $any_name::$variant(e),
)+
base_object => anyhow::bail!("cannot convert: {base_object:?} to {}", stringify!($any_name)),
})
}
}
impl $any_name {
#[allow(dead_code)]
pub(crate) fn raw_ptr(&self) -> SomeResult<$raw_ptr_type> {
use super::inherit_ptrs::traits::*;
match self { $(
$any_name::$variant(e) => Ok(e.inherit_ptrs()?.[<$name:snake>]()),
)+}
}
}

$(
impl From<$container> for $any_name {
fn from(value: $container) -> Self {
$any_name::$variant(value)
}
}
impl TryFrom<AnyBaseObject> for $any_name {
type Error = anyhow::Error;
fn try_from(value: AnyBaseObject) -> Result<Self, Self::Error> {
Ok(match value {
$(
AnyBaseObject::$variant(e) => $any_name::$variant(e),
)+
base_object => anyhow::bail!("cannot convert: {base_object:?} to {}", stringify!($any_name)),
})
}
}

// TODO: refactor this shit, this only needed for meta
impl From<Rc<$wrapper>> for $any_name {
fn from(value: Rc<$wrapper>) -> Self {
$any_name::$variant(BaseObjectContainer(value))
}
}
)+
$(
impl From<$container> for $any_name {
fn from(value: $container) -> Self {
$any_name::$variant(value)
}
};
}

($name:ident, $raw_ptr_type:ty: [ $( $variant:ident, $base_object_mod:path; )+ ]) => {
paste::paste! {
extra_pool_enum!(@internal
[<Any $name>],
$name,
$raw_ptr_type: [
$(
$variant,
$base_object_mod::[<$variant Container>],
$base_object_mod::$variant;
)+
]
);
// TODO: refactor this shit, this only needed for meta
impl From<Rc<$wrapper>> for $any_name {
fn from(value: Rc<$wrapper>) -> Self {
$any_name::$variant(BaseObjectContainer(value))
}
};
}
)+
}
};

($name:ident, $raw_ptr_type:ty: [ $( $variant:ident, $base_object_mod:path; )+ ]) => {
paste::paste! {
extra_pool_enum!(@internal
[<Any $name>],
$name,
$raw_ptr_type: [
$(
$variant,
$base_object_mod::[<$variant Container>],
$base_object_mod::$variant;
)+
]
);
}
};
}

extra_pool_enum!(Entity, EntityRawPtr: [
Player, player;
Vehicle, vehicle;
Ped, ped;
Object, object;
Player, player;
Vehicle, vehicle;
Ped, ped;
Object, object;
]);

extra_pool_enum!(WorldObject, WorldObjectRawPtr: [
Player, player;
Vehicle, vehicle;
Ped, ped;
Object, object;
Player, player;
Vehicle, vehicle;
Ped, ped;
Object, object;
]);
Loading

0 comments on commit f4bfb67

Please sign in to comment.