diff --git a/src/ffi/com_model.rs b/src/ffi/com_model.rs index 858f6fa8..5f490af5 100644 --- a/src/ffi/com_model.rs +++ b/src/ffi/com_model.rs @@ -1,66 +1,37 @@ +// bindgen halflife/common/com_model.h --allowlist-type "mleaf_s|model_s" -- +// --target=i686-unknown-linux-gnu -Ihalflife/{public,common,engine} -include mathlib.h -include +// const.h +// Keep everything before the generated part +// Remove the unnecessary qualifiers `::std::os::raw::` and `::std::mem::` +// Remove `vec_t` and `vec3_t` and replace `vec3_t` with `[f32; 3]` + #![allow(unused, nonstandard_style, deref_nullptr)] -/* bindgen halflife/common/com_model.h --whitelist-type "mleaf_s|model_s" -- - * --target=i686-unknown-linux-gnu -Ihalflife/{public,common,engine} -include mathlib.h -include - * const.h > src/ffi/com_model.rs */ -/* automatically generated by rust-bindgen 0.58.1 */ -use std::mem::{align_of, size_of}; +/* automatically generated by rust-bindgen 0.71.1 */ + +use std::mem::offset_of; use std::os::raw::*; -use std::ptr::null; +#[doc = "\tCopyright (c) 1996-2002, Valve LLC. All rights reserved.\n\n\tThis product contains software technology licensed from Id\n\tSoftware, Inc. (\"Id Technology\"). Id Technology (c) 1996 Id Software, Inc.\n\tAll Rights Reserved.\n\n Use, distribution, and modification of this source code and/or resulting\n object code is restricted to non-commercial enhancements to products from\n Valve LLC. All other use, distribution, or modification is prohibited\n without written permission from Valve LLC."] +pub type byte = c_uchar; pub const qboolean_false_: qboolean = 0; pub const qboolean_true_: qboolean = 1; pub type qboolean = c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct color24 { - pub r: c_uchar, - pub g: c_uchar, - pub b: c_uchar, -} -#[test] -fn bindgen_test_layout_color24() { - assert_eq!( - size_of::(), - 3usize, - concat!("Size of: ", stringify!(color24)) - ); - assert_eq!( - align_of::(), - 1usize, - concat!("Alignment of ", stringify!(color24)) - ); - assert_eq!( - unsafe { &(*(null::())).r as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(color24), - "::", - stringify!(r) - ) - ); - assert_eq!( - unsafe { &(*(null::())).g as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(color24), - "::", - stringify!(g) - ) - ); - assert_eq!( - unsafe { &(*(null::())).b as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(color24), - "::", - stringify!(b) - ) - ); -} + pub r: byte, + pub g: byte, + pub b: byte, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of color24"][size_of::() - 3usize]; + ["Alignment of color24"][align_of::() - 1usize]; + ["Offset of field: color24::r"][offset_of!(color24, r) - 0usize]; + ["Offset of field: color24::g"][offset_of!(color24, g) - 1usize]; + ["Offset of field: color24::b"][offset_of!(color24, b) - 2usize]; +}; pub const modtype_t_mod_brush: modtype_t = 0; pub const modtype_t_mod_sprite: modtype_t = 1; pub const modtype_t_mod_alias: modtype_t = 2; @@ -80,231 +51,64 @@ pub struct dmodel_t { pub firstface: c_int, pub numfaces: c_int, } -#[test] -fn bindgen_test_layout_dmodel_t() { - assert_eq!( - size_of::(), - 64usize, - concat!("Size of: ", stringify!(dmodel_t)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(dmodel_t)) - ); - assert_eq!( - unsafe { &(*(null::())).mins as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(dmodel_t), - "::", - stringify!(mins) - ) - ); - assert_eq!( - unsafe { &(*(null::())).maxs as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(dmodel_t), - "::", - stringify!(maxs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).origin as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(dmodel_t), - "::", - stringify!(origin) - ) - ); - assert_eq!( - unsafe { &(*(null::())).headnode as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(dmodel_t), - "::", - stringify!(headnode) - ) - ); - assert_eq!( - unsafe { &(*(null::())).visleafs as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(dmodel_t), - "::", - stringify!(visleafs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).firstface as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(dmodel_t), - "::", - stringify!(firstface) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numfaces as *const _ as usize }, - 60usize, - concat!( - "Offset of field: ", - stringify!(dmodel_t), - "::", - stringify!(numfaces) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of dmodel_t"][size_of::() - 64usize]; + ["Alignment of dmodel_t"][align_of::() - 4usize]; + ["Offset of field: dmodel_t::mins"][offset_of!(dmodel_t, mins) - 0usize]; + ["Offset of field: dmodel_t::maxs"][offset_of!(dmodel_t, maxs) - 12usize]; + ["Offset of field: dmodel_t::origin"][offset_of!(dmodel_t, origin) - 24usize]; + ["Offset of field: dmodel_t::headnode"][offset_of!(dmodel_t, headnode) - 36usize]; + ["Offset of field: dmodel_t::visleafs"][offset_of!(dmodel_t, visleafs) - 52usize]; + ["Offset of field: dmodel_t::firstface"][offset_of!(dmodel_t, firstface) - 56usize]; + ["Offset of field: dmodel_t::numfaces"][offset_of!(dmodel_t, numfaces) - 60usize]; +}; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Clone, Copy)] pub struct mplane_s { pub normal: [f32; 3], pub dist: f32, - pub type_: c_uchar, - pub signbits: c_uchar, - pub pad: [c_uchar; 2usize], -} -#[test] -fn bindgen_test_layout_mplane_s() { - assert_eq!( - size_of::(), - 20usize, - concat!("Size of: ", stringify!(mplane_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(mplane_s)) - ); - assert_eq!( - unsafe { &(*(null::())).normal as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(mplane_s), - "::", - stringify!(normal) - ) - ); - assert_eq!( - unsafe { &(*(null::())).dist as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(mplane_s), - "::", - stringify!(dist) - ) - ); - assert_eq!( - unsafe { &(*(null::())).type_ as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(mplane_s), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(null::())).signbits as *const _ as usize }, - 17usize, - concat!( - "Offset of field: ", - stringify!(mplane_s), - "::", - stringify!(signbits) - ) - ); - assert_eq!( - unsafe { &(*(null::())).pad as *const _ as usize }, - 18usize, - concat!( - "Offset of field: ", - stringify!(mplane_s), - "::", - stringify!(pad) - ) - ); -} + pub type_: byte, + pub signbits: byte, + pub pad: [byte; 2usize], +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of mplane_s"][size_of::() - 20usize]; + ["Alignment of mplane_s"][align_of::() - 4usize]; + ["Offset of field: mplane_s::normal"][offset_of!(mplane_s, normal) - 0usize]; + ["Offset of field: mplane_s::dist"][offset_of!(mplane_s, dist) - 12usize]; + ["Offset of field: mplane_s::type_"][offset_of!(mplane_s, type_) - 16usize]; + ["Offset of field: mplane_s::signbits"][offset_of!(mplane_s, signbits) - 17usize]; + ["Offset of field: mplane_s::pad"][offset_of!(mplane_s, pad) - 18usize]; +}; pub type mplane_t = mplane_s; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Clone, Copy)] pub struct mvertex_t { pub position: [f32; 3], } -#[test] -fn bindgen_test_layout_mvertex_t() { - assert_eq!( - size_of::(), - 12usize, - concat!("Size of: ", stringify!(mvertex_t)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(mvertex_t)) - ); - assert_eq!( - unsafe { &(*(null::())).position as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(mvertex_t), - "::", - stringify!(position) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of mvertex_t"][size_of::() - 12usize]; + ["Alignment of mvertex_t"][align_of::() - 4usize]; + ["Offset of field: mvertex_t::position"][offset_of!(mvertex_t, position) - 0usize]; +}; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Clone, Copy)] pub struct medge_t { pub v: [c_ushort; 2usize], pub cachededgeoffset: c_uint, } -#[test] -fn bindgen_test_layout_medge_t() { - assert_eq!( - size_of::(), - 8usize, - concat!("Size of: ", stringify!(medge_t)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(medge_t)) - ); - assert_eq!( - unsafe { &(*(null::())).v as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(medge_t), - "::", - stringify!(v) - ) - ); - assert_eq!( - unsafe { &(*(null::())).cachededgeoffset as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(medge_t), - "::", - stringify!(cachededgeoffset) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of medge_t"][size_of::() - 8usize]; + ["Alignment of medge_t"][align_of::() - 4usize]; + ["Offset of field: medge_t::v"][offset_of!(medge_t, v) - 0usize]; + ["Offset of field: medge_t::cachededgeoffset"][offset_of!(medge_t, cachededgeoffset) - 4usize]; +}; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct texture_s { pub name: [c_char; 16usize], pub width: c_uint, @@ -317,183 +121,42 @@ pub struct texture_s { pub offsets: [c_uint; 4usize], pub paloffset: c_uint, } -#[test] -fn bindgen_test_layout_texture_s() { - assert_eq!( - size_of::(), - 64usize, - concat!("Size of: ", stringify!(texture_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(texture_s)) - ); - assert_eq!( - unsafe { &(*(null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(texture_s), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(null::())).width as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(texture_s), - "::", - stringify!(width) - ) - ); - assert_eq!( - unsafe { &(*(null::())).height as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(texture_s), - "::", - stringify!(height) - ) - ); - assert_eq!( - unsafe { &(*(null::())).anim_total as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(texture_s), - "::", - stringify!(anim_total) - ) - ); - assert_eq!( - unsafe { &(*(null::())).anim_min as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(texture_s), - "::", - stringify!(anim_min) - ) - ); - assert_eq!( - unsafe { &(*(null::())).anim_max as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(texture_s), - "::", - stringify!(anim_max) - ) - ); - assert_eq!( - unsafe { &(*(null::())).anim_next as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(texture_s), - "::", - stringify!(anim_next) - ) - ); - assert_eq!( - unsafe { &(*(null::())).alternate_anims as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(texture_s), - "::", - stringify!(alternate_anims) - ) - ); - assert_eq!( - unsafe { &(*(null::())).offsets as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(texture_s), - "::", - stringify!(offsets) - ) - ); - assert_eq!( - unsafe { &(*(null::())).paloffset as *const _ as usize }, - 60usize, - concat!( - "Offset of field: ", - stringify!(texture_s), - "::", - stringify!(paloffset) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of texture_s"][size_of::() - 64usize]; + ["Alignment of texture_s"][align_of::() - 4usize]; + ["Offset of field: texture_s::name"][offset_of!(texture_s, name) - 0usize]; + ["Offset of field: texture_s::width"][offset_of!(texture_s, width) - 16usize]; + ["Offset of field: texture_s::height"][offset_of!(texture_s, height) - 20usize]; + ["Offset of field: texture_s::anim_total"][offset_of!(texture_s, anim_total) - 24usize]; + ["Offset of field: texture_s::anim_min"][offset_of!(texture_s, anim_min) - 28usize]; + ["Offset of field: texture_s::anim_max"][offset_of!(texture_s, anim_max) - 32usize]; + ["Offset of field: texture_s::anim_next"][offset_of!(texture_s, anim_next) - 36usize]; + ["Offset of field: texture_s::alternate_anims"] + [offset_of!(texture_s, alternate_anims) - 40usize]; + ["Offset of field: texture_s::offsets"][offset_of!(texture_s, offsets) - 44usize]; + ["Offset of field: texture_s::paloffset"][offset_of!(texture_s, paloffset) - 60usize]; +}; pub type texture_t = texture_s; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct mtexinfo_t { pub vecs: [[f32; 4usize]; 2usize], pub mipadjust: f32, pub texture: *mut texture_t, pub flags: c_int, } -#[test] -fn bindgen_test_layout_mtexinfo_t() { - assert_eq!( - size_of::(), - 44usize, - concat!("Size of: ", stringify!(mtexinfo_t)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(mtexinfo_t)) - ); - assert_eq!( - unsafe { &(*(null::())).vecs as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(mtexinfo_t), - "::", - stringify!(vecs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).mipadjust as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(mtexinfo_t), - "::", - stringify!(mipadjust) - ) - ); - assert_eq!( - unsafe { &(*(null::())).texture as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(mtexinfo_t), - "::", - stringify!(texture) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flags as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(mtexinfo_t), - "::", - stringify!(flags) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of mtexinfo_t"][size_of::() - 44usize]; + ["Alignment of mtexinfo_t"][align_of::() - 4usize]; + ["Offset of field: mtexinfo_t::vecs"][offset_of!(mtexinfo_t, vecs) - 0usize]; + ["Offset of field: mtexinfo_t::mipadjust"][offset_of!(mtexinfo_t, mipadjust) - 32usize]; + ["Offset of field: mtexinfo_t::texture"][offset_of!(mtexinfo_t, texture) - 36usize]; + ["Offset of field: mtexinfo_t::flags"][offset_of!(mtexinfo_t, flags) - 40usize]; +}; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct mnode_s { pub contents: c_int, pub visframe: c_int, @@ -504,336 +167,79 @@ pub struct mnode_s { pub firstsurface: c_ushort, pub numsurfaces: c_ushort, } -#[test] -fn bindgen_test_layout_mnode_s() { - assert_eq!( - size_of::(), - 40usize, - concat!("Size of: ", stringify!(mnode_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(mnode_s)) - ); - assert_eq!( - unsafe { &(*(null::())).contents as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(mnode_s), - "::", - stringify!(contents) - ) - ); - assert_eq!( - unsafe { &(*(null::())).visframe as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(mnode_s), - "::", - stringify!(visframe) - ) - ); - assert_eq!( - unsafe { &(*(null::())).minmaxs as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(mnode_s), - "::", - stringify!(minmaxs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).parent as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(mnode_s), - "::", - stringify!(parent) - ) - ); - assert_eq!( - unsafe { &(*(null::())).plane as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(mnode_s), - "::", - stringify!(plane) - ) - ); - assert_eq!( - unsafe { &(*(null::())).children as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(mnode_s), - "::", - stringify!(children) - ) - ); - assert_eq!( - unsafe { &(*(null::())).firstsurface as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(mnode_s), - "::", - stringify!(firstsurface) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numsurfaces as *const _ as usize }, - 38usize, - concat!( - "Offset of field: ", - stringify!(mnode_s), - "::", - stringify!(numsurfaces) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of mnode_s"][size_of::() - 40usize]; + ["Alignment of mnode_s"][align_of::() - 4usize]; + ["Offset of field: mnode_s::contents"][offset_of!(mnode_s, contents) - 0usize]; + ["Offset of field: mnode_s::visframe"][offset_of!(mnode_s, visframe) - 4usize]; + ["Offset of field: mnode_s::minmaxs"][offset_of!(mnode_s, minmaxs) - 8usize]; + ["Offset of field: mnode_s::parent"][offset_of!(mnode_s, parent) - 20usize]; + ["Offset of field: mnode_s::plane"][offset_of!(mnode_s, plane) - 24usize]; + ["Offset of field: mnode_s::children"][offset_of!(mnode_s, children) - 28usize]; + ["Offset of field: mnode_s::firstsurface"][offset_of!(mnode_s, firstsurface) - 36usize]; + ["Offset of field: mnode_s::numsurfaces"][offset_of!(mnode_s, numsurfaces) - 38usize]; +}; pub type mnode_t = mnode_s; pub type msurface_t = msurface_s; pub type decal_t = decal_s; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct decal_s { pub pnext: *mut decal_t, pub psurface: *mut msurface_t, pub dx: c_short, pub dy: c_short, pub texture: c_short, - pub scale: c_uchar, - pub flags: c_uchar, + pub scale: byte, + pub flags: byte, pub entityIndex: c_short, } -#[test] -fn bindgen_test_layout_decal_s() { - assert_eq!( - size_of::(), - 20usize, - concat!("Size of: ", stringify!(decal_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(decal_s)) - ); - assert_eq!( - unsafe { &(*(null::())).pnext as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(decal_s), - "::", - stringify!(pnext) - ) - ); - assert_eq!( - unsafe { &(*(null::())).psurface as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(decal_s), - "::", - stringify!(psurface) - ) - ); - assert_eq!( - unsafe { &(*(null::())).dx as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(decal_s), - "::", - stringify!(dx) - ) - ); - assert_eq!( - unsafe { &(*(null::())).dy as *const _ as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(decal_s), - "::", - stringify!(dy) - ) - ); - assert_eq!( - unsafe { &(*(null::())).texture as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(decal_s), - "::", - stringify!(texture) - ) - ); - assert_eq!( - unsafe { &(*(null::())).scale as *const _ as usize }, - 14usize, - concat!( - "Offset of field: ", - stringify!(decal_s), - "::", - stringify!(scale) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flags as *const _ as usize }, - 15usize, - concat!( - "Offset of field: ", - stringify!(decal_s), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(null::())).entityIndex as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(decal_s), - "::", - stringify!(entityIndex) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of decal_s"][size_of::() - 20usize]; + ["Alignment of decal_s"][align_of::() - 4usize]; + ["Offset of field: decal_s::pnext"][offset_of!(decal_s, pnext) - 0usize]; + ["Offset of field: decal_s::psurface"][offset_of!(decal_s, psurface) - 4usize]; + ["Offset of field: decal_s::dx"][offset_of!(decal_s, dx) - 8usize]; + ["Offset of field: decal_s::dy"][offset_of!(decal_s, dy) - 10usize]; + ["Offset of field: decal_s::texture"][offset_of!(decal_s, texture) - 12usize]; + ["Offset of field: decal_s::scale"][offset_of!(decal_s, scale) - 14usize]; + ["Offset of field: decal_s::flags"][offset_of!(decal_s, flags) - 15usize]; + ["Offset of field: decal_s::entityIndex"][offset_of!(decal_s, entityIndex) - 16usize]; +}; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct mleaf_s { pub contents: c_int, pub visframe: c_int, pub minmaxs: [c_short; 6usize], pub parent: *mut mnode_s, - pub compressed_vis: *mut c_uchar, + pub compressed_vis: *mut byte, pub efrags: *mut efrag_s, pub firstmarksurface: *mut *mut msurface_t, pub nummarksurfaces: c_int, pub key: c_int, - pub ambient_sound_level: [c_uchar; 4usize], -} -#[test] -fn bindgen_test_layout_mleaf_s() { - assert_eq!( - size_of::(), - 48usize, - concat!("Size of: ", stringify!(mleaf_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(mleaf_s)) - ); - assert_eq!( - unsafe { &(*(null::())).contents as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(mleaf_s), - "::", - stringify!(contents) - ) - ); - assert_eq!( - unsafe { &(*(null::())).visframe as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(mleaf_s), - "::", - stringify!(visframe) - ) - ); - assert_eq!( - unsafe { &(*(null::())).minmaxs as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(mleaf_s), - "::", - stringify!(minmaxs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).parent as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(mleaf_s), - "::", - stringify!(parent) - ) - ); - assert_eq!( - unsafe { &(*(null::())).compressed_vis as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(mleaf_s), - "::", - stringify!(compressed_vis) - ) - ); - assert_eq!( - unsafe { &(*(null::())).efrags as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(mleaf_s), - "::", - stringify!(efrags) - ) - ); - assert_eq!( - unsafe { &(*(null::())).firstmarksurface as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(mleaf_s), - "::", - stringify!(firstmarksurface) - ) - ); - assert_eq!( - unsafe { &(*(null::())).nummarksurfaces as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(mleaf_s), - "::", - stringify!(nummarksurfaces) - ) - ); - assert_eq!( - unsafe { &(*(null::())).key as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(mleaf_s), - "::", - stringify!(key) - ) - ); - assert_eq!( - unsafe { &(*(null::())).ambient_sound_level as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(mleaf_s), - "::", - stringify!(ambient_sound_level) - ) - ); -} + pub ambient_sound_level: [byte; 4usize], +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of mleaf_s"][size_of::() - 48usize]; + ["Alignment of mleaf_s"][align_of::() - 4usize]; + ["Offset of field: mleaf_s::contents"][offset_of!(mleaf_s, contents) - 0usize]; + ["Offset of field: mleaf_s::visframe"][offset_of!(mleaf_s, visframe) - 4usize]; + ["Offset of field: mleaf_s::minmaxs"][offset_of!(mleaf_s, minmaxs) - 8usize]; + ["Offset of field: mleaf_s::parent"][offset_of!(mleaf_s, parent) - 20usize]; + ["Offset of field: mleaf_s::compressed_vis"][offset_of!(mleaf_s, compressed_vis) - 24usize]; + ["Offset of field: mleaf_s::efrags"][offset_of!(mleaf_s, efrags) - 28usize]; + ["Offset of field: mleaf_s::firstmarksurface"][offset_of!(mleaf_s, firstmarksurface) - 32usize]; + ["Offset of field: mleaf_s::nummarksurfaces"][offset_of!(mleaf_s, nummarksurfaces) - 36usize]; + ["Offset of field: mleaf_s::key"][offset_of!(mleaf_s, key) - 40usize]; + ["Offset of field: mleaf_s::ambient_sound_level"] + [offset_of!(mleaf_s, ambient_sound_level) - 44usize]; +}; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct msurface_s { pub visframe: c_int, pub dlightframe: c_int, @@ -846,204 +252,44 @@ pub struct msurface_s { pub texturemins: [c_short; 2usize], pub extents: [c_short; 2usize], pub texinfo: *mut mtexinfo_t, - pub styles: [c_uchar; 4usize], + pub styles: [byte; 4usize], pub samples: *mut color24, pub pdecals: *mut decal_t, } -#[test] -fn bindgen_test_layout_msurface_s() { - assert_eq!( - size_of::(), - 68usize, - concat!("Size of: ", stringify!(msurface_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(msurface_s)) - ); - assert_eq!( - unsafe { &(*(null::())).visframe as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(visframe) - ) - ); - assert_eq!( - unsafe { &(*(null::())).dlightframe as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(dlightframe) - ) - ); - assert_eq!( - unsafe { &(*(null::())).dlightbits as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(dlightbits) - ) - ); - assert_eq!( - unsafe { &(*(null::())).plane as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(plane) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flags as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(null::())).firstedge as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(firstedge) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numedges as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(numedges) - ) - ); - assert_eq!( - unsafe { &(*(null::())).cachespots as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(cachespots) - ) - ); - assert_eq!( - unsafe { &(*(null::())).texturemins as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(texturemins) - ) - ); - assert_eq!( - unsafe { &(*(null::())).extents as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(extents) - ) - ); - assert_eq!( - unsafe { &(*(null::())).texinfo as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(texinfo) - ) - ); - assert_eq!( - unsafe { &(*(null::())).styles as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(styles) - ) - ); - assert_eq!( - unsafe { &(*(null::())).samples as *const _ as usize }, - 60usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(samples) - ) - ); - assert_eq!( - unsafe { &(*(null::())).pdecals as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(msurface_s), - "::", - stringify!(pdecals) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of msurface_s"][size_of::() - 68usize]; + ["Alignment of msurface_s"][align_of::() - 4usize]; + ["Offset of field: msurface_s::visframe"][offset_of!(msurface_s, visframe) - 0usize]; + ["Offset of field: msurface_s::dlightframe"][offset_of!(msurface_s, dlightframe) - 4usize]; + ["Offset of field: msurface_s::dlightbits"][offset_of!(msurface_s, dlightbits) - 8usize]; + ["Offset of field: msurface_s::plane"][offset_of!(msurface_s, plane) - 12usize]; + ["Offset of field: msurface_s::flags"][offset_of!(msurface_s, flags) - 16usize]; + ["Offset of field: msurface_s::firstedge"][offset_of!(msurface_s, firstedge) - 20usize]; + ["Offset of field: msurface_s::numedges"][offset_of!(msurface_s, numedges) - 24usize]; + ["Offset of field: msurface_s::cachespots"][offset_of!(msurface_s, cachespots) - 28usize]; + ["Offset of field: msurface_s::texturemins"][offset_of!(msurface_s, texturemins) - 44usize]; + ["Offset of field: msurface_s::extents"][offset_of!(msurface_s, extents) - 48usize]; + ["Offset of field: msurface_s::texinfo"][offset_of!(msurface_s, texinfo) - 52usize]; + ["Offset of field: msurface_s::styles"][offset_of!(msurface_s, styles) - 56usize]; + ["Offset of field: msurface_s::samples"][offset_of!(msurface_s, samples) - 60usize]; + ["Offset of field: msurface_s::pdecals"][offset_of!(msurface_s, pdecals) - 64usize]; +}; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Clone, Copy)] pub struct dclipnode_t { pub planenum: c_int, pub children: [c_short; 2usize], } -#[test] -fn bindgen_test_layout_dclipnode_t() { - assert_eq!( - size_of::(), - 8usize, - concat!("Size of: ", stringify!(dclipnode_t)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(dclipnode_t)) - ); - assert_eq!( - unsafe { &(*(null::())).planenum as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(dclipnode_t), - "::", - stringify!(planenum) - ) - ); - assert_eq!( - unsafe { &(*(null::())).children as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(dclipnode_t), - "::", - stringify!(children) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of dclipnode_t"][size_of::() - 8usize]; + ["Alignment of dclipnode_t"][align_of::() - 4usize]; + ["Offset of field: dclipnode_t::planenum"][offset_of!(dclipnode_t, planenum) - 0usize]; + ["Offset of field: dclipnode_t::children"][offset_of!(dclipnode_t, children) - 4usize]; +}; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Clone, Copy)] pub struct hull_s { pub clipnodes: *mut dclipnode_t, pub planes: *mut mplane_t, @@ -1052,111 +298,32 @@ pub struct hull_s { pub clip_mins: [f32; 3], pub clip_maxs: [f32; 3], } -#[test] -fn bindgen_test_layout_hull_s() { - assert_eq!( - size_of::(), - 40usize, - concat!("Size of: ", stringify!(hull_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(hull_s)) - ); - assert_eq!( - unsafe { &(*(null::())).clipnodes as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(hull_s), - "::", - stringify!(clipnodes) - ) - ); - assert_eq!( - unsafe { &(*(null::())).planes as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(hull_s), - "::", - stringify!(planes) - ) - ); - assert_eq!( - unsafe { &(*(null::())).firstclipnode as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(hull_s), - "::", - stringify!(firstclipnode) - ) - ); - assert_eq!( - unsafe { &(*(null::())).lastclipnode as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(hull_s), - "::", - stringify!(lastclipnode) - ) - ); - assert_eq!( - unsafe { &(*(null::())).clip_mins as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(hull_s), - "::", - stringify!(clip_mins) - ) - ); - assert_eq!( - unsafe { &(*(null::())).clip_maxs as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(hull_s), - "::", - stringify!(clip_maxs) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of hull_s"][size_of::() - 40usize]; + ["Alignment of hull_s"][align_of::() - 4usize]; + ["Offset of field: hull_s::clipnodes"][offset_of!(hull_s, clipnodes) - 0usize]; + ["Offset of field: hull_s::planes"][offset_of!(hull_s, planes) - 4usize]; + ["Offset of field: hull_s::firstclipnode"][offset_of!(hull_s, firstclipnode) - 8usize]; + ["Offset of field: hull_s::lastclipnode"][offset_of!(hull_s, lastclipnode) - 12usize]; + ["Offset of field: hull_s::clip_mins"][offset_of!(hull_s, clip_mins) - 16usize]; + ["Offset of field: hull_s::clip_maxs"][offset_of!(hull_s, clip_maxs) - 28usize]; +}; pub type hull_t = hull_s; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct cache_user_s { pub data: *mut c_void, } -#[test] -fn bindgen_test_layout_cache_user_s() { - assert_eq!( - size_of::(), - 4usize, - concat!("Size of: ", stringify!(cache_user_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(cache_user_s)) - ); - assert_eq!( - unsafe { &(*(null::())).data as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(cache_user_s), - "::", - stringify!(data) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of cache_user_s"][size_of::() - 4usize]; + ["Alignment of cache_user_s"][align_of::() - 4usize]; + ["Offset of field: cache_user_s::data"][offset_of!(cache_user_s, data) - 0usize]; +}; pub type cache_user_t = cache_user_s; #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug)] pub struct model_s { pub name: [c_char; 64usize], pub needload: qboolean, @@ -1194,431 +361,65 @@ pub struct model_s { pub hulls: [hull_t; 4usize], pub numtextures: c_int, pub textures: *mut *mut texture_t, - pub visdata: *mut c_uchar, + pub visdata: *mut byte, pub lightdata: *mut color24, pub entities: *mut c_char, pub cache: cache_user_t, } -#[test] -fn bindgen_test_layout_model_s() { - assert_eq!( - size_of::(), - 392usize, - concat!("Size of: ", stringify!(model_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(model_s)) - ); - assert_eq!( - unsafe { &(*(null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(null::())).needload as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(needload) - ) - ); - assert_eq!( - unsafe { &(*(null::())).type_ as *const _ as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numframes as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(numframes) - ) - ); - assert_eq!( - unsafe { &(*(null::())).synctype as *const _ as usize }, - 76usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(synctype) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flags as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(null::())).mins as *const _ as usize }, - 84usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(mins) - ) - ); - assert_eq!( - unsafe { &(*(null::())).maxs as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(maxs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).radius as *const _ as usize }, - 108usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(radius) - ) - ); - assert_eq!( - unsafe { &(*(null::())).firstmodelsurface as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(firstmodelsurface) - ) - ); - assert_eq!( - unsafe { &(*(null::())).nummodelsurfaces as *const _ as usize }, - 116usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(nummodelsurfaces) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numsubmodels as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(numsubmodels) - ) - ); - assert_eq!( - unsafe { &(*(null::())).submodels as *const _ as usize }, - 124usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(submodels) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numplanes as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(numplanes) - ) - ); - assert_eq!( - unsafe { &(*(null::())).planes as *const _ as usize }, - 132usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(planes) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numleafs as *const _ as usize }, - 136usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(numleafs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).leafs as *const _ as usize }, - 140usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(leafs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numvertexes as *const _ as usize }, - 144usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(numvertexes) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vertexes as *const _ as usize }, - 148usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(vertexes) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numedges as *const _ as usize }, - 152usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(numedges) - ) - ); - assert_eq!( - unsafe { &(*(null::())).edges as *const _ as usize }, - 156usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(edges) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numnodes as *const _ as usize }, - 160usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(numnodes) - ) - ); - assert_eq!( - unsafe { &(*(null::())).nodes as *const _ as usize }, - 164usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(nodes) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numtexinfo as *const _ as usize }, - 168usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(numtexinfo) - ) - ); - assert_eq!( - unsafe { &(*(null::())).texinfo as *const _ as usize }, - 172usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(texinfo) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numsurfaces as *const _ as usize }, - 176usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(numsurfaces) - ) - ); - assert_eq!( - unsafe { &(*(null::())).surfaces as *const _ as usize }, - 180usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(surfaces) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numsurfedges as *const _ as usize }, - 184usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(numsurfedges) - ) - ); - assert_eq!( - unsafe { &(*(null::())).surfedges as *const _ as usize }, - 188usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(surfedges) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numclipnodes as *const _ as usize }, - 192usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(numclipnodes) - ) - ); - assert_eq!( - unsafe { &(*(null::())).clipnodes as *const _ as usize }, - 196usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(clipnodes) - ) - ); - assert_eq!( - unsafe { &(*(null::())).nummarksurfaces as *const _ as usize }, - 200usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(nummarksurfaces) - ) - ); - assert_eq!( - unsafe { &(*(null::())).marksurfaces as *const _ as usize }, - 204usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(marksurfaces) - ) - ); - assert_eq!( - unsafe { &(*(null::())).hulls as *const _ as usize }, - 208usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(hulls) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numtextures as *const _ as usize }, - 368usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(numtextures) - ) - ); - assert_eq!( - unsafe { &(*(null::())).textures as *const _ as usize }, - 372usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(textures) - ) - ); - assert_eq!( - unsafe { &(*(null::())).visdata as *const _ as usize }, - 376usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(visdata) - ) - ); - assert_eq!( - unsafe { &(*(null::())).lightdata as *const _ as usize }, - 380usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(lightdata) - ) - ); - assert_eq!( - unsafe { &(*(null::())).entities as *const _ as usize }, - 384usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(entities) - ) - ); - assert_eq!( - unsafe { &(*(null::())).cache as *const _ as usize }, - 388usize, - concat!( - "Offset of field: ", - stringify!(model_s), - "::", - stringify!(cache) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of model_s"][size_of::() - 392usize]; + ["Alignment of model_s"][align_of::() - 4usize]; + ["Offset of field: model_s::name"][offset_of!(model_s, name) - 0usize]; + ["Offset of field: model_s::needload"][offset_of!(model_s, needload) - 64usize]; + ["Offset of field: model_s::type_"][offset_of!(model_s, type_) - 68usize]; + ["Offset of field: model_s::numframes"][offset_of!(model_s, numframes) - 72usize]; + ["Offset of field: model_s::synctype"][offset_of!(model_s, synctype) - 76usize]; + ["Offset of field: model_s::flags"][offset_of!(model_s, flags) - 80usize]; + ["Offset of field: model_s::mins"][offset_of!(model_s, mins) - 84usize]; + ["Offset of field: model_s::maxs"][offset_of!(model_s, maxs) - 96usize]; + ["Offset of field: model_s::radius"][offset_of!(model_s, radius) - 108usize]; + ["Offset of field: model_s::firstmodelsurface"] + [offset_of!(model_s, firstmodelsurface) - 112usize]; + ["Offset of field: model_s::nummodelsurfaces"] + [offset_of!(model_s, nummodelsurfaces) - 116usize]; + ["Offset of field: model_s::numsubmodels"][offset_of!(model_s, numsubmodels) - 120usize]; + ["Offset of field: model_s::submodels"][offset_of!(model_s, submodels) - 124usize]; + ["Offset of field: model_s::numplanes"][offset_of!(model_s, numplanes) - 128usize]; + ["Offset of field: model_s::planes"][offset_of!(model_s, planes) - 132usize]; + ["Offset of field: model_s::numleafs"][offset_of!(model_s, numleafs) - 136usize]; + ["Offset of field: model_s::leafs"][offset_of!(model_s, leafs) - 140usize]; + ["Offset of field: model_s::numvertexes"][offset_of!(model_s, numvertexes) - 144usize]; + ["Offset of field: model_s::vertexes"][offset_of!(model_s, vertexes) - 148usize]; + ["Offset of field: model_s::numedges"][offset_of!(model_s, numedges) - 152usize]; + ["Offset of field: model_s::edges"][offset_of!(model_s, edges) - 156usize]; + ["Offset of field: model_s::numnodes"][offset_of!(model_s, numnodes) - 160usize]; + ["Offset of field: model_s::nodes"][offset_of!(model_s, nodes) - 164usize]; + ["Offset of field: model_s::numtexinfo"][offset_of!(model_s, numtexinfo) - 168usize]; + ["Offset of field: model_s::texinfo"][offset_of!(model_s, texinfo) - 172usize]; + ["Offset of field: model_s::numsurfaces"][offset_of!(model_s, numsurfaces) - 176usize]; + ["Offset of field: model_s::surfaces"][offset_of!(model_s, surfaces) - 180usize]; + ["Offset of field: model_s::numsurfedges"][offset_of!(model_s, numsurfedges) - 184usize]; + ["Offset of field: model_s::surfedges"][offset_of!(model_s, surfedges) - 188usize]; + ["Offset of field: model_s::numclipnodes"][offset_of!(model_s, numclipnodes) - 192usize]; + ["Offset of field: model_s::clipnodes"][offset_of!(model_s, clipnodes) - 196usize]; + ["Offset of field: model_s::nummarksurfaces"][offset_of!(model_s, nummarksurfaces) - 200usize]; + ["Offset of field: model_s::marksurfaces"][offset_of!(model_s, marksurfaces) - 204usize]; + ["Offset of field: model_s::hulls"][offset_of!(model_s, hulls) - 208usize]; + ["Offset of field: model_s::numtextures"][offset_of!(model_s, numtextures) - 368usize]; + ["Offset of field: model_s::textures"][offset_of!(model_s, textures) - 372usize]; + ["Offset of field: model_s::visdata"][offset_of!(model_s, visdata) - 376usize]; + ["Offset of field: model_s::lightdata"][offset_of!(model_s, lightdata) - 380usize]; + ["Offset of field: model_s::entities"][offset_of!(model_s, entities) - 384usize]; + ["Offset of field: model_s::cache"][offset_of!(model_s, cache) - 388usize]; +}; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct efrag_s { pub _address: u8, } #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct surfcache_s { pub _address: u8, } diff --git a/src/ffi/command.rs b/src/ffi/command.rs index 8b108e83..557bda20 100644 --- a/src/ffi/command.rs +++ b/src/ffi/command.rs @@ -1,4 +1,4 @@ -#![allow(unused)] +#![allow(unused, nonstandard_style, deref_nullptr)] use std::os::raw::*; diff --git a/src/ffi/cvar.rs b/src/ffi/cvar.rs index 9760c279..941398bb 100644 --- a/src/ffi/cvar.rs +++ b/src/ffi/cvar.rs @@ -1,6 +1,12 @@ -#![allow(unused, deref_nullptr)] +// bindgen halflife/common/cvardef.h --allowlist-type "cvar_s" -- --target=i686-unknown-linux-gnu +// -Ihalflife/{public,common,engine} -include mathlib.h -include const.h +// Keep everything before the generated part +// Change `cvar_s.name` and `cvars_s.string` to use type `*const ...` for code compatibility +// Remove `vec_t` and `vec3_t` and replace `vec3_t` with `[f32; 3]` -use std::mem::{align_of, size_of}; +#![allow(unused, deref_nullptr, nonstandard_style)] + +use std::mem::{align_of, offset_of, size_of}; use std::os::raw::*; use std::ptr::null; @@ -21,6 +27,11 @@ bitflags! { } } +/* automatically generated by rust-bindgen 0.71.1 */ + +// intentionally modify `name` and `strings` field to +// [`*const c_char`] +// instead of the generated [`*mut ...`] #[repr(C)] #[derive(Debug)] pub struct cvar_s { @@ -30,68 +41,13 @@ pub struct cvar_s { pub value: f32, pub next: *mut cvar_s, } - -#[cfg(target_arch = "x86")] -#[test] -fn bindgen_test_layout_cvar_s() { - assert_eq!( - size_of::(), - 20usize, - concat!("Size of: ", stringify!(cvar_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(cvar_s)) - ); - assert_eq!( - unsafe { &(*(null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(cvar_s), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(null::())).string as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(cvar_s), - "::", - stringify!(string) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flags as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(cvar_s), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(null::())).value as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(cvar_s), - "::", - stringify!(value) - ) - ); - assert_eq!( - unsafe { &(*(null::())).next as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(cvar_s), - "::", - stringify!(next) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of cvar_s"][size_of::() - 20usize]; + ["Alignment of cvar_s"][align_of::() - 4usize]; + ["Offset of field: cvar_s::name"][offset_of!(cvar_s, name) - 0usize]; + ["Offset of field: cvar_s::string"][offset_of!(cvar_s, string) - 4usize]; + ["Offset of field: cvar_s::flags"][offset_of!(cvar_s, flags) - 8usize]; + ["Offset of field: cvar_s::value"][offset_of!(cvar_s, value) - 12usize]; + ["Offset of field: cvar_s::next"][offset_of!(cvar_s, next) - 16usize]; +}; diff --git a/src/ffi/edict.rs b/src/ffi/edict.rs index 71ed3b8c..0e143195 100644 --- a/src/ffi/edict.rs +++ b/src/ffi/edict.rs @@ -1,6 +1,14 @@ +// bindgen halflife/engine/edict.h --allowlist-type "edict_s" -- --target=i686-unknown-linux-gnu +// -Ihalflife/{public,common,engine} -include mathlib.h -include const.h +// Keep everything before the generated part +// Change `entvars_s.flags` member to use `Flags` type +// Remove the unnecessary qualifiers `::std::os::raw::` and `::std::mem::` +// Remove `vec_t` and `vec3_t` and replace `vec3_t` with `[f32; 3]` +// Remove `edict_t` and replace `edict_t` with `edict_s` + #![allow(unused, nonstandard_style, deref_nullptr, clippy::upper_case_acronyms)] -use std::mem::{align_of, size_of}; +use std::mem::{align_of, offset_of, size_of}; use std::os::raw::*; use std::ptr::null; @@ -42,49 +50,30 @@ bitflags! { } } -pub type string_t = c_int; +/* automatically generated by rust-bindgen 0.71.1 */ +#[doc = "\tCopyright (c) 1996-2002, Valve LLC. All rights reserved.\n\n\tThis product contains software technology licensed from Id\n\tSoftware, Inc. (\"Id Technology\"). Id Technology (c) 1996 Id Software, Inc.\n\tAll Rights Reserved.\n\n Use, distribution, and modification of this source code and/or resulting\n object code is restricted to non-commercial enhancements to products from\n Valve LLC. All other use, distribution, or modification is prohibited\n without written permission from Valve LLC."] +pub type string_t = c_uint; +pub type byte = c_uchar; +pub const qboolean_false_: qboolean = 0; +pub const qboolean_true_: qboolean = 1; +pub type qboolean = c_uint; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct link_s { pub prev: *mut link_s, pub next: *mut link_s, } -#[test] -fn bindgen_test_layout_link_s() { - assert_eq!( - size_of::(), - 8usize, - concat!("Size of: ", stringify!(link_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(link_s)) - ); - assert_eq!( - unsafe { &(*(null::())).prev as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(link_s), - "::", - stringify!(prev) - ) - ); - assert_eq!( - unsafe { &(*(null::())).next as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(link_s), - "::", - stringify!(next) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of link_s"][size_of::() - 8usize]; + ["Alignment of link_s"][align_of::() - 4usize]; + ["Offset of field: link_s::prev"][offset_of!(link_s, prev) - 0usize]; + ["Offset of field: link_s::next"][offset_of!(link_s, next) - 4usize]; +}; +pub type link_t = link_s; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct entvars_s { pub classname: string_t, pub globalname: string_t, @@ -131,8 +120,8 @@ pub struct entvars_s { pub frame: f32, pub animtime: f32, pub framerate: f32, - pub controller: [c_uchar; 4usize], - pub blending: [c_uchar; 2usize], + pub controller: [byte; 4usize], + pub blending: [byte; 2usize], pub scale: f32, pub rendermode: c_int, pub renderamt: f32, @@ -153,6 +142,7 @@ pub struct entvars_s { pub owner: *mut edict_s, pub groundentity: *mut edict_s, pub spawnflags: c_int, + // CHANGE THIS pub flags: Flags, pub colormap: c_int, pub team: c_int, @@ -210,1256 +200,145 @@ pub struct entvars_s { pub euser3: *mut edict_s, pub euser4: *mut edict_s, } -#[test] -fn bindgen_test_layout_entvars_s() { - assert_eq!( - size_of::(), - 676usize, - concat!("Size of: ", stringify!(entvars_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(entvars_s)) - ); - assert_eq!( - unsafe { &(*(null::())).classname as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(classname) - ) - ); - assert_eq!( - unsafe { &(*(null::())).globalname as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(globalname) - ) - ); - assert_eq!( - unsafe { &(*(null::())).origin as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(origin) - ) - ); - assert_eq!( - unsafe { &(*(null::())).oldorigin as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(oldorigin) - ) - ); - assert_eq!( - unsafe { &(*(null::())).velocity as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(velocity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).basevelocity as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(basevelocity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).clbasevelocity as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(clbasevelocity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).movedir as *const _ as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(movedir) - ) - ); - assert_eq!( - unsafe { &(*(null::())).angles as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(angles) - ) - ); - assert_eq!( - unsafe { &(*(null::())).avelocity as *const _ as usize }, - 92usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(avelocity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).punchangle as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(punchangle) - ) - ); - assert_eq!( - unsafe { &(*(null::())).v_angle as *const _ as usize }, - 116usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(v_angle) - ) - ); - assert_eq!( - unsafe { &(*(null::())).endpos as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(endpos) - ) - ); - assert_eq!( - unsafe { &(*(null::())).startpos as *const _ as usize }, - 140usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(startpos) - ) - ); - assert_eq!( - unsafe { &(*(null::())).impacttime as *const _ as usize }, - 152usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(impacttime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).starttime as *const _ as usize }, - 156usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(starttime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fixangle as *const _ as usize }, - 160usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(fixangle) - ) - ); - assert_eq!( - unsafe { &(*(null::())).idealpitch as *const _ as usize }, - 164usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(idealpitch) - ) - ); - assert_eq!( - unsafe { &(*(null::())).pitch_speed as *const _ as usize }, - 168usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(pitch_speed) - ) - ); - assert_eq!( - unsafe { &(*(null::())).ideal_yaw as *const _ as usize }, - 172usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(ideal_yaw) - ) - ); - assert_eq!( - unsafe { &(*(null::())).yaw_speed as *const _ as usize }, - 176usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(yaw_speed) - ) - ); - assert_eq!( - unsafe { &(*(null::())).modelindex as *const _ as usize }, - 180usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(modelindex) - ) - ); - assert_eq!( - unsafe { &(*(null::())).model as *const _ as usize }, - 184usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(model) - ) - ); - assert_eq!( - unsafe { &(*(null::())).viewmodel as *const _ as usize }, - 188usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(viewmodel) - ) - ); - assert_eq!( - unsafe { &(*(null::())).weaponmodel as *const _ as usize }, - 192usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(weaponmodel) - ) - ); - assert_eq!( - unsafe { &(*(null::())).absmin as *const _ as usize }, - 196usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(absmin) - ) - ); - assert_eq!( - unsafe { &(*(null::())).absmax as *const _ as usize }, - 208usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(absmax) - ) - ); - assert_eq!( - unsafe { &(*(null::())).mins as *const _ as usize }, - 220usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(mins) - ) - ); - assert_eq!( - unsafe { &(*(null::())).maxs as *const _ as usize }, - 232usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(maxs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).size as *const _ as usize }, - 244usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(size) - ) - ); - assert_eq!( - unsafe { &(*(null::())).ltime as *const _ as usize }, - 256usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(ltime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).nextthink as *const _ as usize }, - 260usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(nextthink) - ) - ); - assert_eq!( - unsafe { &(*(null::())).movetype as *const _ as usize }, - 264usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(movetype) - ) - ); - assert_eq!( - unsafe { &(*(null::())).solid as *const _ as usize }, - 268usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(solid) - ) - ); - assert_eq!( - unsafe { &(*(null::())).skin as *const _ as usize }, - 272usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(skin) - ) - ); - assert_eq!( - unsafe { &(*(null::())).body as *const _ as usize }, - 276usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(body) - ) - ); - assert_eq!( - unsafe { &(*(null::())).effects as *const _ as usize }, - 280usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(effects) - ) - ); - assert_eq!( - unsafe { &(*(null::())).gravity as *const _ as usize }, - 284usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(gravity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).friction as *const _ as usize }, - 288usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(friction) - ) - ); - assert_eq!( - unsafe { &(*(null::())).light_level as *const _ as usize }, - 292usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(light_level) - ) - ); - assert_eq!( - unsafe { &(*(null::())).sequence as *const _ as usize }, - 296usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(sequence) - ) - ); - assert_eq!( - unsafe { &(*(null::())).gaitsequence as *const _ as usize }, - 300usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(gaitsequence) - ) - ); - assert_eq!( - unsafe { &(*(null::())).frame as *const _ as usize }, - 304usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(frame) - ) - ); - assert_eq!( - unsafe { &(*(null::())).animtime as *const _ as usize }, - 308usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(animtime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).framerate as *const _ as usize }, - 312usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(framerate) - ) - ); - assert_eq!( - unsafe { &(*(null::())).controller as *const _ as usize }, - 316usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(controller) - ) - ); - assert_eq!( - unsafe { &(*(null::())).blending as *const _ as usize }, - 320usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(blending) - ) - ); - assert_eq!( - unsafe { &(*(null::())).scale as *const _ as usize }, - 324usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(scale) - ) - ); - assert_eq!( - unsafe { &(*(null::())).rendermode as *const _ as usize }, - 328usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(rendermode) - ) - ); - assert_eq!( - unsafe { &(*(null::())).renderamt as *const _ as usize }, - 332usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(renderamt) - ) - ); - assert_eq!( - unsafe { &(*(null::())).rendercolor as *const _ as usize }, - 336usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(rendercolor) - ) - ); - assert_eq!( - unsafe { &(*(null::())).renderfx as *const _ as usize }, - 348usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(renderfx) - ) - ); - assert_eq!( - unsafe { &(*(null::())).health as *const _ as usize }, - 352usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(health) - ) - ); - assert_eq!( - unsafe { &(*(null::())).frags as *const _ as usize }, - 356usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(frags) - ) - ); - assert_eq!( - unsafe { &(*(null::())).weapons as *const _ as usize }, - 360usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(weapons) - ) - ); - assert_eq!( - unsafe { &(*(null::())).takedamage as *const _ as usize }, - 364usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(takedamage) - ) - ); - assert_eq!( - unsafe { &(*(null::())).deadflag as *const _ as usize }, - 368usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(deadflag) - ) - ); - assert_eq!( - unsafe { &(*(null::())).view_ofs as *const _ as usize }, - 372usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(view_ofs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).button as *const _ as usize }, - 384usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(button) - ) - ); - assert_eq!( - unsafe { &(*(null::())).impulse as *const _ as usize }, - 388usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(impulse) - ) - ); - assert_eq!( - unsafe { &(*(null::())).chain as *const _ as usize }, - 392usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(chain) - ) - ); - assert_eq!( - unsafe { &(*(null::())).dmg_inflictor as *const _ as usize }, - 396usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(dmg_inflictor) - ) - ); - assert_eq!( - unsafe { &(*(null::())).enemy as *const _ as usize }, - 400usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(enemy) - ) - ); - assert_eq!( - unsafe { &(*(null::())).aiment as *const _ as usize }, - 404usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(aiment) - ) - ); - assert_eq!( - unsafe { &(*(null::())).owner as *const _ as usize }, - 408usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(owner) - ) - ); - assert_eq!( - unsafe { &(*(null::())).groundentity as *const _ as usize }, - 412usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(groundentity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).spawnflags as *const _ as usize }, - 416usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(spawnflags) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flags as *const _ as usize }, - 420usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(null::())).colormap as *const _ as usize }, - 424usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(colormap) - ) - ); - assert_eq!( - unsafe { &(*(null::())).team as *const _ as usize }, - 428usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(team) - ) - ); - assert_eq!( - unsafe { &(*(null::())).max_health as *const _ as usize }, - 432usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(max_health) - ) - ); - assert_eq!( - unsafe { &(*(null::())).teleport_time as *const _ as usize }, - 436usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(teleport_time) - ) - ); - assert_eq!( - unsafe { &(*(null::())).armortype as *const _ as usize }, - 440usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(armortype) - ) - ); - assert_eq!( - unsafe { &(*(null::())).armorvalue as *const _ as usize }, - 444usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(armorvalue) - ) - ); - assert_eq!( - unsafe { &(*(null::())).waterlevel as *const _ as usize }, - 448usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(waterlevel) - ) - ); - assert_eq!( - unsafe { &(*(null::())).watertype as *const _ as usize }, - 452usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(watertype) - ) - ); - assert_eq!( - unsafe { &(*(null::())).target as *const _ as usize }, - 456usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(target) - ) - ); - assert_eq!( - unsafe { &(*(null::())).targetname as *const _ as usize }, - 460usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(targetname) - ) - ); - assert_eq!( - unsafe { &(*(null::())).netname as *const _ as usize }, - 464usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(netname) - ) - ); - assert_eq!( - unsafe { &(*(null::())).message as *const _ as usize }, - 468usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(message) - ) - ); - assert_eq!( - unsafe { &(*(null::())).dmg_take as *const _ as usize }, - 472usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(dmg_take) - ) - ); - assert_eq!( - unsafe { &(*(null::())).dmg_save as *const _ as usize }, - 476usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(dmg_save) - ) - ); - assert_eq!( - unsafe { &(*(null::())).dmg as *const _ as usize }, - 480usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(dmg) - ) - ); - assert_eq!( - unsafe { &(*(null::())).dmgtime as *const _ as usize }, - 484usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(dmgtime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).noise as *const _ as usize }, - 488usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(noise) - ) - ); - assert_eq!( - unsafe { &(*(null::())).noise1 as *const _ as usize }, - 492usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(noise1) - ) - ); - assert_eq!( - unsafe { &(*(null::())).noise2 as *const _ as usize }, - 496usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(noise2) - ) - ); - assert_eq!( - unsafe { &(*(null::())).noise3 as *const _ as usize }, - 500usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(noise3) - ) - ); - assert_eq!( - unsafe { &(*(null::())).speed as *const _ as usize }, - 504usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(speed) - ) - ); - assert_eq!( - unsafe { &(*(null::())).air_finished as *const _ as usize }, - 508usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(air_finished) - ) - ); - assert_eq!( - unsafe { &(*(null::())).pain_finished as *const _ as usize }, - 512usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(pain_finished) - ) - ); - assert_eq!( - unsafe { &(*(null::())).radsuit_finished as *const _ as usize }, - 516usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(radsuit_finished) - ) - ); - assert_eq!( - unsafe { &(*(null::())).pContainingEntity as *const _ as usize }, - 520usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(pContainingEntity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).playerclass as *const _ as usize }, - 524usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(playerclass) - ) - ); - assert_eq!( - unsafe { &(*(null::())).maxspeed as *const _ as usize }, - 528usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(maxspeed) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fov as *const _ as usize }, - 532usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(fov) - ) - ); - assert_eq!( - unsafe { &(*(null::())).weaponanim as *const _ as usize }, - 536usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(weaponanim) - ) - ); - assert_eq!( - unsafe { &(*(null::())).pushmsec as *const _ as usize }, - 540usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(pushmsec) - ) - ); - assert_eq!( - unsafe { &(*(null::())).bInDuck as *const _ as usize }, - 544usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(bInDuck) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flTimeStepSound as *const _ as usize }, - 548usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(flTimeStepSound) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flSwimTime as *const _ as usize }, - 552usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(flSwimTime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flDuckTime as *const _ as usize }, - 556usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(flDuckTime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iStepLeft as *const _ as usize }, - 560usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(iStepLeft) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flFallVelocity as *const _ as usize }, - 564usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(flFallVelocity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).gamestate as *const _ as usize }, - 568usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(gamestate) - ) - ); - assert_eq!( - unsafe { &(*(null::())).oldbuttons as *const _ as usize }, - 572usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(oldbuttons) - ) - ); - assert_eq!( - unsafe { &(*(null::())).groupinfo as *const _ as usize }, - 576usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(groupinfo) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iuser1 as *const _ as usize }, - 580usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(iuser1) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iuser2 as *const _ as usize }, - 584usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(iuser2) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iuser3 as *const _ as usize }, - 588usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(iuser3) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iuser4 as *const _ as usize }, - 592usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(iuser4) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fuser1 as *const _ as usize }, - 596usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(fuser1) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fuser2 as *const _ as usize }, - 600usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(fuser2) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fuser3 as *const _ as usize }, - 604usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(fuser3) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fuser4 as *const _ as usize }, - 608usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(fuser4) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vuser1 as *const _ as usize }, - 612usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(vuser1) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vuser2 as *const _ as usize }, - 624usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(vuser2) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vuser3 as *const _ as usize }, - 636usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(vuser3) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vuser4 as *const _ as usize }, - 648usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(vuser4) - ) - ); - assert_eq!( - unsafe { &(*(null::())).euser1 as *const _ as usize }, - 660usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(euser1) - ) - ); - assert_eq!( - unsafe { &(*(null::())).euser2 as *const _ as usize }, - 664usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(euser2) - ) - ); - assert_eq!( - unsafe { &(*(null::())).euser3 as *const _ as usize }, - 668usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(euser3) - ) - ); - assert_eq!( - unsafe { &(*(null::())).euser4 as *const _ as usize }, - 672usize, - concat!( - "Offset of field: ", - stringify!(entvars_s), - "::", - stringify!(euser4) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of entvars_s"][size_of::() - 676usize]; + ["Alignment of entvars_s"][align_of::() - 4usize]; + ["Offset of field: entvars_s::classname"][offset_of!(entvars_s, classname) - 0usize]; + ["Offset of field: entvars_s::globalname"][offset_of!(entvars_s, globalname) - 4usize]; + ["Offset of field: entvars_s::origin"][offset_of!(entvars_s, origin) - 8usize]; + ["Offset of field: entvars_s::oldorigin"][offset_of!(entvars_s, oldorigin) - 20usize]; + ["Offset of field: entvars_s::velocity"][offset_of!(entvars_s, velocity) - 32usize]; + ["Offset of field: entvars_s::basevelocity"][offset_of!(entvars_s, basevelocity) - 44usize]; + ["Offset of field: entvars_s::clbasevelocity"][offset_of!(entvars_s, clbasevelocity) - 56usize]; + ["Offset of field: entvars_s::movedir"][offset_of!(entvars_s, movedir) - 68usize]; + ["Offset of field: entvars_s::angles"][offset_of!(entvars_s, angles) - 80usize]; + ["Offset of field: entvars_s::avelocity"][offset_of!(entvars_s, avelocity) - 92usize]; + ["Offset of field: entvars_s::punchangle"][offset_of!(entvars_s, punchangle) - 104usize]; + ["Offset of field: entvars_s::v_angle"][offset_of!(entvars_s, v_angle) - 116usize]; + ["Offset of field: entvars_s::endpos"][offset_of!(entvars_s, endpos) - 128usize]; + ["Offset of field: entvars_s::startpos"][offset_of!(entvars_s, startpos) - 140usize]; + ["Offset of field: entvars_s::impacttime"][offset_of!(entvars_s, impacttime) - 152usize]; + ["Offset of field: entvars_s::starttime"][offset_of!(entvars_s, starttime) - 156usize]; + ["Offset of field: entvars_s::fixangle"][offset_of!(entvars_s, fixangle) - 160usize]; + ["Offset of field: entvars_s::idealpitch"][offset_of!(entvars_s, idealpitch) - 164usize]; + ["Offset of field: entvars_s::pitch_speed"][offset_of!(entvars_s, pitch_speed) - 168usize]; + ["Offset of field: entvars_s::ideal_yaw"][offset_of!(entvars_s, ideal_yaw) - 172usize]; + ["Offset of field: entvars_s::yaw_speed"][offset_of!(entvars_s, yaw_speed) - 176usize]; + ["Offset of field: entvars_s::modelindex"][offset_of!(entvars_s, modelindex) - 180usize]; + ["Offset of field: entvars_s::model"][offset_of!(entvars_s, model) - 184usize]; + ["Offset of field: entvars_s::viewmodel"][offset_of!(entvars_s, viewmodel) - 188usize]; + ["Offset of field: entvars_s::weaponmodel"][offset_of!(entvars_s, weaponmodel) - 192usize]; + ["Offset of field: entvars_s::absmin"][offset_of!(entvars_s, absmin) - 196usize]; + ["Offset of field: entvars_s::absmax"][offset_of!(entvars_s, absmax) - 208usize]; + ["Offset of field: entvars_s::mins"][offset_of!(entvars_s, mins) - 220usize]; + ["Offset of field: entvars_s::maxs"][offset_of!(entvars_s, maxs) - 232usize]; + ["Offset of field: entvars_s::size"][offset_of!(entvars_s, size) - 244usize]; + ["Offset of field: entvars_s::ltime"][offset_of!(entvars_s, ltime) - 256usize]; + ["Offset of field: entvars_s::nextthink"][offset_of!(entvars_s, nextthink) - 260usize]; + ["Offset of field: entvars_s::movetype"][offset_of!(entvars_s, movetype) - 264usize]; + ["Offset of field: entvars_s::solid"][offset_of!(entvars_s, solid) - 268usize]; + ["Offset of field: entvars_s::skin"][offset_of!(entvars_s, skin) - 272usize]; + ["Offset of field: entvars_s::body"][offset_of!(entvars_s, body) - 276usize]; + ["Offset of field: entvars_s::effects"][offset_of!(entvars_s, effects) - 280usize]; + ["Offset of field: entvars_s::gravity"][offset_of!(entvars_s, gravity) - 284usize]; + ["Offset of field: entvars_s::friction"][offset_of!(entvars_s, friction) - 288usize]; + ["Offset of field: entvars_s::light_level"][offset_of!(entvars_s, light_level) - 292usize]; + ["Offset of field: entvars_s::sequence"][offset_of!(entvars_s, sequence) - 296usize]; + ["Offset of field: entvars_s::gaitsequence"][offset_of!(entvars_s, gaitsequence) - 300usize]; + ["Offset of field: entvars_s::frame"][offset_of!(entvars_s, frame) - 304usize]; + ["Offset of field: entvars_s::animtime"][offset_of!(entvars_s, animtime) - 308usize]; + ["Offset of field: entvars_s::framerate"][offset_of!(entvars_s, framerate) - 312usize]; + ["Offset of field: entvars_s::controller"][offset_of!(entvars_s, controller) - 316usize]; + ["Offset of field: entvars_s::blending"][offset_of!(entvars_s, blending) - 320usize]; + ["Offset of field: entvars_s::scale"][offset_of!(entvars_s, scale) - 324usize]; + ["Offset of field: entvars_s::rendermode"][offset_of!(entvars_s, rendermode) - 328usize]; + ["Offset of field: entvars_s::renderamt"][offset_of!(entvars_s, renderamt) - 332usize]; + ["Offset of field: entvars_s::rendercolor"][offset_of!(entvars_s, rendercolor) - 336usize]; + ["Offset of field: entvars_s::renderfx"][offset_of!(entvars_s, renderfx) - 348usize]; + ["Offset of field: entvars_s::health"][offset_of!(entvars_s, health) - 352usize]; + ["Offset of field: entvars_s::frags"][offset_of!(entvars_s, frags) - 356usize]; + ["Offset of field: entvars_s::weapons"][offset_of!(entvars_s, weapons) - 360usize]; + ["Offset of field: entvars_s::takedamage"][offset_of!(entvars_s, takedamage) - 364usize]; + ["Offset of field: entvars_s::deadflag"][offset_of!(entvars_s, deadflag) - 368usize]; + ["Offset of field: entvars_s::view_ofs"][offset_of!(entvars_s, view_ofs) - 372usize]; + ["Offset of field: entvars_s::button"][offset_of!(entvars_s, button) - 384usize]; + ["Offset of field: entvars_s::impulse"][offset_of!(entvars_s, impulse) - 388usize]; + ["Offset of field: entvars_s::chain"][offset_of!(entvars_s, chain) - 392usize]; + ["Offset of field: entvars_s::dmg_inflictor"][offset_of!(entvars_s, dmg_inflictor) - 396usize]; + ["Offset of field: entvars_s::enemy"][offset_of!(entvars_s, enemy) - 400usize]; + ["Offset of field: entvars_s::aiment"][offset_of!(entvars_s, aiment) - 404usize]; + ["Offset of field: entvars_s::owner"][offset_of!(entvars_s, owner) - 408usize]; + ["Offset of field: entvars_s::groundentity"][offset_of!(entvars_s, groundentity) - 412usize]; + ["Offset of field: entvars_s::spawnflags"][offset_of!(entvars_s, spawnflags) - 416usize]; + ["Offset of field: entvars_s::flags"][offset_of!(entvars_s, flags) - 420usize]; + ["Offset of field: entvars_s::colormap"][offset_of!(entvars_s, colormap) - 424usize]; + ["Offset of field: entvars_s::team"][offset_of!(entvars_s, team) - 428usize]; + ["Offset of field: entvars_s::max_health"][offset_of!(entvars_s, max_health) - 432usize]; + ["Offset of field: entvars_s::teleport_time"][offset_of!(entvars_s, teleport_time) - 436usize]; + ["Offset of field: entvars_s::armortype"][offset_of!(entvars_s, armortype) - 440usize]; + ["Offset of field: entvars_s::armorvalue"][offset_of!(entvars_s, armorvalue) - 444usize]; + ["Offset of field: entvars_s::waterlevel"][offset_of!(entvars_s, waterlevel) - 448usize]; + ["Offset of field: entvars_s::watertype"][offset_of!(entvars_s, watertype) - 452usize]; + ["Offset of field: entvars_s::target"][offset_of!(entvars_s, target) - 456usize]; + ["Offset of field: entvars_s::targetname"][offset_of!(entvars_s, targetname) - 460usize]; + ["Offset of field: entvars_s::netname"][offset_of!(entvars_s, netname) - 464usize]; + ["Offset of field: entvars_s::message"][offset_of!(entvars_s, message) - 468usize]; + ["Offset of field: entvars_s::dmg_take"][offset_of!(entvars_s, dmg_take) - 472usize]; + ["Offset of field: entvars_s::dmg_save"][offset_of!(entvars_s, dmg_save) - 476usize]; + ["Offset of field: entvars_s::dmg"][offset_of!(entvars_s, dmg) - 480usize]; + ["Offset of field: entvars_s::dmgtime"][offset_of!(entvars_s, dmgtime) - 484usize]; + ["Offset of field: entvars_s::noise"][offset_of!(entvars_s, noise) - 488usize]; + ["Offset of field: entvars_s::noise1"][offset_of!(entvars_s, noise1) - 492usize]; + ["Offset of field: entvars_s::noise2"][offset_of!(entvars_s, noise2) - 496usize]; + ["Offset of field: entvars_s::noise3"][offset_of!(entvars_s, noise3) - 500usize]; + ["Offset of field: entvars_s::speed"][offset_of!(entvars_s, speed) - 504usize]; + ["Offset of field: entvars_s::air_finished"][offset_of!(entvars_s, air_finished) - 508usize]; + ["Offset of field: entvars_s::pain_finished"][offset_of!(entvars_s, pain_finished) - 512usize]; + ["Offset of field: entvars_s::radsuit_finished"] + [offset_of!(entvars_s, radsuit_finished) - 516usize]; + ["Offset of field: entvars_s::pContainingEntity"] + [offset_of!(entvars_s, pContainingEntity) - 520usize]; + ["Offset of field: entvars_s::playerclass"][offset_of!(entvars_s, playerclass) - 524usize]; + ["Offset of field: entvars_s::maxspeed"][offset_of!(entvars_s, maxspeed) - 528usize]; + ["Offset of field: entvars_s::fov"][offset_of!(entvars_s, fov) - 532usize]; + ["Offset of field: entvars_s::weaponanim"][offset_of!(entvars_s, weaponanim) - 536usize]; + ["Offset of field: entvars_s::pushmsec"][offset_of!(entvars_s, pushmsec) - 540usize]; + ["Offset of field: entvars_s::bInDuck"][offset_of!(entvars_s, bInDuck) - 544usize]; + ["Offset of field: entvars_s::flTimeStepSound"] + [offset_of!(entvars_s, flTimeStepSound) - 548usize]; + ["Offset of field: entvars_s::flSwimTime"][offset_of!(entvars_s, flSwimTime) - 552usize]; + ["Offset of field: entvars_s::flDuckTime"][offset_of!(entvars_s, flDuckTime) - 556usize]; + ["Offset of field: entvars_s::iStepLeft"][offset_of!(entvars_s, iStepLeft) - 560usize]; + ["Offset of field: entvars_s::flFallVelocity"] + [offset_of!(entvars_s, flFallVelocity) - 564usize]; + ["Offset of field: entvars_s::gamestate"][offset_of!(entvars_s, gamestate) - 568usize]; + ["Offset of field: entvars_s::oldbuttons"][offset_of!(entvars_s, oldbuttons) - 572usize]; + ["Offset of field: entvars_s::groupinfo"][offset_of!(entvars_s, groupinfo) - 576usize]; + ["Offset of field: entvars_s::iuser1"][offset_of!(entvars_s, iuser1) - 580usize]; + ["Offset of field: entvars_s::iuser2"][offset_of!(entvars_s, iuser2) - 584usize]; + ["Offset of field: entvars_s::iuser3"][offset_of!(entvars_s, iuser3) - 588usize]; + ["Offset of field: entvars_s::iuser4"][offset_of!(entvars_s, iuser4) - 592usize]; + ["Offset of field: entvars_s::fuser1"][offset_of!(entvars_s, fuser1) - 596usize]; + ["Offset of field: entvars_s::fuser2"][offset_of!(entvars_s, fuser2) - 600usize]; + ["Offset of field: entvars_s::fuser3"][offset_of!(entvars_s, fuser3) - 604usize]; + ["Offset of field: entvars_s::fuser4"][offset_of!(entvars_s, fuser4) - 608usize]; + ["Offset of field: entvars_s::vuser1"][offset_of!(entvars_s, vuser1) - 612usize]; + ["Offset of field: entvars_s::vuser2"][offset_of!(entvars_s, vuser2) - 624usize]; + ["Offset of field: entvars_s::vuser3"][offset_of!(entvars_s, vuser3) - 636usize]; + ["Offset of field: entvars_s::vuser4"][offset_of!(entvars_s, vuser4) - 648usize]; + ["Offset of field: entvars_s::euser1"][offset_of!(entvars_s, euser1) - 660usize]; + ["Offset of field: entvars_s::euser2"][offset_of!(entvars_s, euser2) - 664usize]; + ["Offset of field: entvars_s::euser3"][offset_of!(entvars_s, euser3) - 668usize]; + ["Offset of field: entvars_s::euser4"][offset_of!(entvars_s, euser4) - 672usize]; +}; pub type entvars_t = entvars_s; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct edict_s { - pub free: c_int, + pub free: qboolean, pub serialnumber: c_int, - pub area: link_s, + pub area: link_t, pub headnode: c_int, pub num_leafs: c_int, pub leafnums: [c_short; 48usize], @@ -1467,106 +346,17 @@ pub struct edict_s { pub pvPrivateData: *mut c_void, pub v: entvars_t, } -#[test] -fn bindgen_test_layout_edict_s() { - assert_eq!( - size_of::(), - 804usize, - concat!("Size of: ", stringify!(edict_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(edict_s)) - ); - assert_eq!( - unsafe { &(*(null::())).free as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edict_s), - "::", - stringify!(free) - ) - ); - assert_eq!( - unsafe { &(*(null::())).serialnumber as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(edict_s), - "::", - stringify!(serialnumber) - ) - ); - assert_eq!( - unsafe { &(*(null::())).area as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(edict_s), - "::", - stringify!(area) - ) - ); - assert_eq!( - unsafe { &(*(null::())).headnode as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(edict_s), - "::", - stringify!(headnode) - ) - ); - assert_eq!( - unsafe { &(*(null::())).num_leafs as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(edict_s), - "::", - stringify!(num_leafs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).leafnums as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(edict_s), - "::", - stringify!(leafnums) - ) - ); - assert_eq!( - unsafe { &(*(null::())).freetime as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(edict_s), - "::", - stringify!(freetime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).pvPrivateData as *const _ as usize }, - 124usize, - concat!( - "Offset of field: ", - stringify!(edict_s), - "::", - stringify!(pvPrivateData) - ) - ); - assert_eq!( - unsafe { &(*(null::())).v as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(edict_s), - "::", - stringify!(v) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of edict_s"][size_of::() - 804usize]; + ["Alignment of edict_s"][align_of::() - 4usize]; + ["Offset of field: edict_s::free"][offset_of!(edict_s, free) - 0usize]; + ["Offset of field: edict_s::serialnumber"][offset_of!(edict_s, serialnumber) - 4usize]; + ["Offset of field: edict_s::area"][offset_of!(edict_s, area) - 8usize]; + ["Offset of field: edict_s::headnode"][offset_of!(edict_s, headnode) - 16usize]; + ["Offset of field: edict_s::num_leafs"][offset_of!(edict_s, num_leafs) - 20usize]; + ["Offset of field: edict_s::leafnums"][offset_of!(edict_s, leafnums) - 24usize]; + ["Offset of field: edict_s::freetime"][offset_of!(edict_s, freetime) - 120usize]; + ["Offset of field: edict_s::pvPrivateData"][offset_of!(edict_s, pvPrivateData) - 124usize]; + ["Offset of field: edict_s::v"][offset_of!(edict_s, v) - 128usize]; +}; diff --git a/src/ffi/physent.rs b/src/ffi/physent.rs index 2dfa44a5..2336c879 100644 --- a/src/ffi/physent.rs +++ b/src/ffi/physent.rs @@ -1,8 +1,14 @@ -#![allow(unused, deref_nullptr)] +// `physent_s` struct is from generated bindgen in playermove.rs -use std::mem::{align_of, size_of}; +#![allow(unused, nonstandard_style, deref_nullptr)] + +use std::mem::{align_of, offset_of, size_of}; use std::os::raw::*; -use std::ptr::null; + +use super::com_model::model_s; + +pub type string_t = c_uint; +pub type byte = c_uchar; #[repr(C)] #[derive(Debug)] @@ -10,8 +16,8 @@ pub struct physent_s { pub name: [c_char; 32usize], pub player: c_int, pub origin: [f32; 3], - pub model: *mut c_void, - pub studiomodel: *mut c_void, + pub model: *mut model_s, + pub studiomodel: *mut model_s, pub mins: [f32; 3], pub maxs: [f32; 3], pub info: c_int, @@ -21,8 +27,8 @@ pub struct physent_s { pub rendermode: c_int, pub frame: f32, pub sequence: c_int, - pub controller: [c_uchar; 4usize], - pub blending: [c_uchar; 2usize], + pub controller: [byte; 4usize], + pub blending: [byte; 2usize], pub movetype: c_int, pub takedamage: c_int, pub blooddecal: c_int, @@ -41,348 +47,41 @@ pub struct physent_s { pub vuser3: [f32; 3], pub vuser4: [f32; 3], } - -#[cfg(target_arch = "x86")] -#[test] -fn bindgen_test_layout_physent_s() { - assert_eq!( - size_of::(), - 224usize, - concat!("Size of: ", stringify!(physent_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(physent_s)) - ); - assert_eq!( - unsafe { &(*(null::())).name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(null::())).player as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(player) - ) - ); - assert_eq!( - unsafe { &(*(null::())).origin as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(origin) - ) - ); - assert_eq!( - unsafe { &(*(null::())).model as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(model) - ) - ); - assert_eq!( - unsafe { &(*(null::())).studiomodel as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(studiomodel) - ) - ); - assert_eq!( - unsafe { &(*(null::())).mins as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(mins) - ) - ); - assert_eq!( - unsafe { &(*(null::())).maxs as *const _ as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(maxs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).info as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(info) - ) - ); - assert_eq!( - unsafe { &(*(null::())).angles as *const _ as usize }, - 84usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(angles) - ) - ); - assert_eq!( - unsafe { &(*(null::())).solid as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(solid) - ) - ); - assert_eq!( - unsafe { &(*(null::())).skin as *const _ as usize }, - 100usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(skin) - ) - ); - assert_eq!( - unsafe { &(*(null::())).rendermode as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(rendermode) - ) - ); - assert_eq!( - unsafe { &(*(null::())).frame as *const _ as usize }, - 108usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(frame) - ) - ); - assert_eq!( - unsafe { &(*(null::())).sequence as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(sequence) - ) - ); - assert_eq!( - unsafe { &(*(null::())).controller as *const _ as usize }, - 116usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(controller) - ) - ); - assert_eq!( - unsafe { &(*(null::())).blending as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(blending) - ) - ); - assert_eq!( - unsafe { &(*(null::())).movetype as *const _ as usize }, - 124usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(movetype) - ) - ); - assert_eq!( - unsafe { &(*(null::())).takedamage as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(takedamage) - ) - ); - assert_eq!( - unsafe { &(*(null::())).blooddecal as *const _ as usize }, - 132usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(blooddecal) - ) - ); - assert_eq!( - unsafe { &(*(null::())).team as *const _ as usize }, - 136usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(team) - ) - ); - assert_eq!( - unsafe { &(*(null::())).classnumber as *const _ as usize }, - 140usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(classnumber) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iuser1 as *const _ as usize }, - 144usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(iuser1) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iuser2 as *const _ as usize }, - 148usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(iuser2) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iuser3 as *const _ as usize }, - 152usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(iuser3) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iuser4 as *const _ as usize }, - 156usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(iuser4) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fuser1 as *const _ as usize }, - 160usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(fuser1) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fuser2 as *const _ as usize }, - 164usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(fuser2) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fuser3 as *const _ as usize }, - 168usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(fuser3) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fuser4 as *const _ as usize }, - 172usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(fuser4) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vuser1 as *const _ as usize }, - 176usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(vuser1) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vuser2 as *const _ as usize }, - 188usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(vuser2) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vuser3 as *const _ as usize }, - 200usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(vuser3) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vuser4 as *const _ as usize }, - 212usize, - concat!( - "Offset of field: ", - stringify!(physent_s), - "::", - stringify!(vuser4) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of physent_s"][size_of::() - 224usize]; + ["Alignment of physent_s"][align_of::() - 4usize]; + ["Offset of field: physent_s::name"][offset_of!(physent_s, name) - 0usize]; + ["Offset of field: physent_s::player"][offset_of!(physent_s, player) - 32usize]; + ["Offset of field: physent_s::origin"][offset_of!(physent_s, origin) - 36usize]; + ["Offset of field: physent_s::model"][offset_of!(physent_s, model) - 48usize]; + ["Offset of field: physent_s::studiomodel"][offset_of!(physent_s, studiomodel) - 52usize]; + ["Offset of field: physent_s::mins"][offset_of!(physent_s, mins) - 56usize]; + ["Offset of field: physent_s::maxs"][offset_of!(physent_s, maxs) - 68usize]; + ["Offset of field: physent_s::info"][offset_of!(physent_s, info) - 80usize]; + ["Offset of field: physent_s::angles"][offset_of!(physent_s, angles) - 84usize]; + ["Offset of field: physent_s::solid"][offset_of!(physent_s, solid) - 96usize]; + ["Offset of field: physent_s::skin"][offset_of!(physent_s, skin) - 100usize]; + ["Offset of field: physent_s::rendermode"][offset_of!(physent_s, rendermode) - 104usize]; + ["Offset of field: physent_s::frame"][offset_of!(physent_s, frame) - 108usize]; + ["Offset of field: physent_s::sequence"][offset_of!(physent_s, sequence) - 112usize]; + ["Offset of field: physent_s::controller"][offset_of!(physent_s, controller) - 116usize]; + ["Offset of field: physent_s::blending"][offset_of!(physent_s, blending) - 120usize]; + ["Offset of field: physent_s::movetype"][offset_of!(physent_s, movetype) - 124usize]; + ["Offset of field: physent_s::takedamage"][offset_of!(physent_s, takedamage) - 128usize]; + ["Offset of field: physent_s::blooddecal"][offset_of!(physent_s, blooddecal) - 132usize]; + ["Offset of field: physent_s::team"][offset_of!(physent_s, team) - 136usize]; + ["Offset of field: physent_s::classnumber"][offset_of!(physent_s, classnumber) - 140usize]; + ["Offset of field: physent_s::iuser1"][offset_of!(physent_s, iuser1) - 144usize]; + ["Offset of field: physent_s::iuser2"][offset_of!(physent_s, iuser2) - 148usize]; + ["Offset of field: physent_s::iuser3"][offset_of!(physent_s, iuser3) - 152usize]; + ["Offset of field: physent_s::iuser4"][offset_of!(physent_s, iuser4) - 156usize]; + ["Offset of field: physent_s::fuser1"][offset_of!(physent_s, fuser1) - 160usize]; + ["Offset of field: physent_s::fuser2"][offset_of!(physent_s, fuser2) - 164usize]; + ["Offset of field: physent_s::fuser3"][offset_of!(physent_s, fuser3) - 168usize]; + ["Offset of field: physent_s::fuser4"][offset_of!(physent_s, fuser4) - 172usize]; + ["Offset of field: physent_s::vuser1"][offset_of!(physent_s, vuser1) - 176usize]; + ["Offset of field: physent_s::vuser2"][offset_of!(physent_s, vuser2) - 188usize]; + ["Offset of field: physent_s::vuser3"][offset_of!(physent_s, vuser3) - 200usize]; + ["Offset of field: physent_s::vuser4"][offset_of!(physent_s, vuser4) - 212usize]; +}; diff --git a/src/ffi/playermove.rs b/src/ffi/playermove.rs index 7315fc53..2031efe7 100644 --- a/src/ffi/playermove.rs +++ b/src/ffi/playermove.rs @@ -1,16 +1,37 @@ +// bindgen halflife/pm_shared/pm_defs.h --allowlist-type "playermove_s" -- +// --target=i686-unknown-linux-gnu -Ihalflife/{public,common,engine} -include mathlib.h -include +// const.h +// Keep everything before the generated part +// Then change playermove_s.flags member to use [`edict::Flags`] type +// Then change playermove_s.PlayerTrace argument `traceFlags` to use [`TraceFlags`] type +// Then change playermove_s.PlayerTrace argument `start` and `end` to `*const ...` from `*mut ...` +// Change `playermove_s` members who are functions from `Option` to `T`. +// Remove the unnecessary qualifiers `::std::os::raw::` and `::std::mem::` +// Remove `vec_t` and `[f32; 3]` and replace `[f32; 3]` with `[f32; 3]` +// Remove `physent_t` alias and replace `physent_t` with `physent_s` +// Remove `pmtrace_t` alias and replace `pmtrace_t` with `pmtrace_s` +// Remove `usercmd_t` alias and replace `usercmd_t` with `usercmd_s` +// Remove `edict_t` alias and import `edict_s` from edict.rs +// Remove `model_s` dummy struct and import `model_s` from com_model.rs + +// For some reasons, this `playermove_s` also generates physent, pmplane, pmtrace, and usercmd. +// So put those structs along with tests in their own respective files. + #![allow(unused, nonstandard_style, deref_nullptr)] -use std::mem::{align_of, size_of}; +use std::mem::{align_of, offset_of, size_of}; use std::os::raw::*; use std::ptr::null; use bitflags::bitflags; +use super::com_model::model_s; +use super::edict::edict_s; +use super::physent::physent_s; +use super::pmplane::pmplane_t; +use super::pmtrace::pmtrace_s; +use super::usercmd::usercmd_s; use crate::ffi::edict; -use crate::ffi::physent::physent_s; -use crate::ffi::pmplane::pmplane_t; -use crate::ffi::pmtrace::pmtrace_s; -use crate::ffi::usercmd::usercmd_s; bitflags! { #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -28,11 +49,60 @@ pub const PM_TRACELINE_PHYSENTONLY: TraceLineFlag = 0; pub const PM_TRACELINE_ANYVISIBLE: TraceLineFlag = 1; pub type TraceLineFlag = c_int; +/* automatically generated by rust-bindgen 0.71.1 */ + +#[doc = "\tCopyright (c) 1996-2002, Valve LLC. All rights reserved.\n\n\tThis product contains software technology licensed from Id\n\tSoftware, Inc. (\"Id Technology\"). Id Technology (c) 1996 Id Software, Inc.\n\tAll Rights Reserved.\n\n Use, distribution, and modification of this source code and/or resulting\n object code is restricted to non-commercial enhancements to products from\n Valve LLC. All other use, distribution, or modification is prohibited\n without written permission from Valve LLC."] +pub type string_t = c_uint; +pub type byte = c_uchar; +pub const qboolean_false_: qboolean = 0; +pub const qboolean_true_: qboolean = 1; +pub type qboolean = c_uint; #[repr(C)] +#[derive(Debug, Clone, Copy)] +pub struct plane_t { + pub normal: [f32; 3], + pub dist: f32, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of plane_t"][size_of::() - 16usize]; + ["Alignment of plane_t"][align_of::() - 4usize]; + ["Offset of field: plane_t::normal"][offset_of!(plane_t, normal) - 0usize]; + ["Offset of field: plane_t::dist"][offset_of!(plane_t, dist) - 12usize]; +}; +#[repr(C)] +#[derive(Debug)] +pub struct trace_t { + pub allsolid: qboolean, + pub startsolid: qboolean, + pub inopen: qboolean, + pub inwater: qboolean, + pub fraction: f32, + pub endpos: [f32; 3], + pub plane: plane_t, + pub ent: *mut edict_s, + pub hitgroup: c_int, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of trace_t"][size_of::() - 56usize]; + ["Alignment of trace_t"][align_of::() - 4usize]; + ["Offset of field: trace_t::allsolid"][offset_of!(trace_t, allsolid) - 0usize]; + ["Offset of field: trace_t::startsolid"][offset_of!(trace_t, startsolid) - 4usize]; + ["Offset of field: trace_t::inopen"][offset_of!(trace_t, inopen) - 8usize]; + ["Offset of field: trace_t::inwater"][offset_of!(trace_t, inwater) - 12usize]; + ["Offset of field: trace_t::fraction"][offset_of!(trace_t, fraction) - 16usize]; + ["Offset of field: trace_t::endpos"][offset_of!(trace_t, endpos) - 20usize]; + ["Offset of field: trace_t::plane"][offset_of!(trace_t, plane) - 32usize]; + ["Offset of field: trace_t::ent"][offset_of!(trace_t, ent) - 48usize]; + ["Offset of field: trace_t::hitgroup"][offset_of!(trace_t, hitgroup) - 52usize]; +}; +#[repr(C)] +#[derive(Debug)] pub struct playermove_s { pub player_index: c_int, - pub server: u32, - pub multiplayer: u32, + pub server: qboolean, + pub multiplayer: qboolean, pub time: f32, pub frametime: f32, pub forward: [f32; 3], @@ -46,7 +116,7 @@ pub struct playermove_s { pub basevelocity: [f32; 3], pub view_ofs: [f32; 3], pub flDuckTime: f32, - pub bInDuck: u32, + pub bInDuck: qboolean, pub flTimeStepSound: c_int, pub iStepLeft: c_int, pub flFallVelocity: f32, @@ -60,7 +130,7 @@ pub struct playermove_s { pub friction: f32, pub oldbuttons: c_int, pub waterjumptime: f32, - pub dead: u32, + pub dead: qboolean, pub deadflag: c_int, pub spectator: c_int, pub movetype: c_int, @@ -94,7 +164,7 @@ pub struct playermove_s { pub numtouch: c_int, pub touchindex: [pmtrace_s; 600usize], pub physinfo: [c_char; 256usize], - pub movevars: *mut c_void, + pub movevars: *mut movevars_s, pub player_mins: [[f32; 3]; 4usize], pub player_maxs: [[f32; 3]; 4usize], pub PM_Info_ValueForKey: @@ -110,7 +180,7 @@ pub struct playermove_s { pub PM_PointContents: unsafe extern "C" fn(p: *mut f32, truecontents: *mut c_int) -> c_int, pub PM_TruePointContents: unsafe extern "C" fn(p: *mut f32) -> c_int, pub PM_HullPointContents: - unsafe extern "C" fn(hull: *mut c_void, num: c_int, p: *mut f32) -> c_int, + unsafe extern "C" fn(hull: *mut hull_s, num: c_int, p: *mut f32) -> c_int, pub PM_PlayerTrace: unsafe extern "C" fn( start: *const f32, end: *const f32, @@ -126,30 +196,27 @@ pub struct playermove_s { ) -> *mut pmtrace_s, pub RandomLong: unsafe extern "C" fn(lLow: c_int, lHigh: c_int) -> c_int, pub RandomFloat: unsafe extern "C" fn(flLow: f32, flHigh: f32) -> f32, - pub PM_GetModelType: unsafe extern "C" fn(mod_: *mut c_void) -> c_int, - pub PM_GetModelBounds: unsafe extern "C" fn(mod_: *mut c_void, mins: *mut f32, maxs: *mut f32), + pub PM_GetModelType: unsafe extern "C" fn(mod_: *mut model_s) -> c_int, + pub PM_GetModelBounds: unsafe extern "C" fn(mod_: *mut model_s, mins: *mut f32, maxs: *mut f32), pub PM_HullForBsp: unsafe extern "C" fn(pe: *mut physent_s, offset: *mut f32) -> *mut c_void, pub PM_TraceModel: unsafe extern "C" fn( pEnt: *mut physent_s, start: *mut f32, end: *mut f32, - trace: *mut c_void, + trace: *mut trace_t, ) -> f32, pub COM_FileSize: unsafe extern "C" fn(filename: *mut c_char) -> c_int, - pub COM_LoadFile: unsafe extern "C" fn( - path: *mut c_char, - usehunk: c_int, - pLength: *mut c_int, - ) -> *mut c_uchar, + pub COM_LoadFile: + unsafe extern "C" fn(path: *mut c_char, usehunk: c_int, pLength: *mut c_int) -> *mut byte, pub COM_FreeFile: unsafe extern "C" fn(buffer: *mut c_void), pub memfgets: unsafe extern "C" fn( - pMemFile: *mut c_uchar, + pMemFile: *mut byte, fileSize: c_int, pFilePos: *mut c_int, pBuffer: *mut c_char, bufferSize: c_int, ) -> *mut c_char, - pub runfuncs: u32, + pub runfuncs: qboolean, pub PM_PlaySound: unsafe extern "C" fn( channel: c_int, sample: *const c_char, @@ -193,988 +260,157 @@ pub struct playermove_s { pfnIgnore: unsafe extern "C" fn(pe: *mut physent_s) -> c_int, ) -> *mut pmtrace_s, } - -#[cfg(target_arch = "x86")] -#[test] -fn bindgen_test_layout_playermove_s() { - assert_eq!( - size_of::(), - 325068usize, - concat!("Size of: ", stringify!(playermove_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(playermove_s)) - ); - assert_eq!( - unsafe { &(*(null::())).player_index as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(player_index) - ) - ); - assert_eq!( - unsafe { &(*(null::())).server as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(server) - ) - ); - assert_eq!( - unsafe { &(*(null::())).multiplayer as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(multiplayer) - ) - ); - assert_eq!( - unsafe { &(*(null::())).time as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(time) - ) - ); - assert_eq!( - unsafe { &(*(null::())).frametime as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(frametime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).forward as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(forward) - ) - ); - assert_eq!( - unsafe { &(*(null::())).right as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(right) - ) - ); - assert_eq!( - unsafe { &(*(null::())).up as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(up) - ) - ); - assert_eq!( - unsafe { &(*(null::())).origin as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(origin) - ) - ); - assert_eq!( - unsafe { &(*(null::())).angles as *const _ as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(angles) - ) - ); - assert_eq!( - unsafe { &(*(null::())).oldangles as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(oldangles) - ) - ); - assert_eq!( - unsafe { &(*(null::())).velocity as *const _ as usize }, - 92usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(velocity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).movedir as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(movedir) - ) - ); - assert_eq!( - unsafe { &(*(null::())).basevelocity as *const _ as usize }, - 116usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(basevelocity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).view_ofs as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(view_ofs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flDuckTime as *const _ as usize }, - 140usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(flDuckTime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).bInDuck as *const _ as usize }, - 144usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(bInDuck) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flTimeStepSound as *const _ as usize }, - 148usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(flTimeStepSound) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iStepLeft as *const _ as usize }, - 152usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(iStepLeft) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flFallVelocity as *const _ as usize }, - 156usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(flFallVelocity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).punchangle as *const _ as usize }, - 160usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(punchangle) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flSwimTime as *const _ as usize }, - 172usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(flSwimTime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flNextPrimaryAttack as *const _ as usize }, - 176usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(flNextPrimaryAttack) - ) - ); - assert_eq!( - unsafe { &(*(null::())).effects as *const _ as usize }, - 180usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(effects) - ) - ); - assert_eq!( - unsafe { &(*(null::())).flags as *const _ as usize }, - 184usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(null::())).usehull as *const _ as usize }, - 188usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(usehull) - ) - ); - assert_eq!( - unsafe { &(*(null::())).gravity as *const _ as usize }, - 192usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(gravity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).friction as *const _ as usize }, - 196usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(friction) - ) - ); - assert_eq!( - unsafe { &(*(null::())).oldbuttons as *const _ as usize }, - 200usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(oldbuttons) - ) - ); - assert_eq!( - unsafe { &(*(null::())).waterjumptime as *const _ as usize }, - 204usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(waterjumptime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).dead as *const _ as usize }, - 208usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(dead) - ) - ); - assert_eq!( - unsafe { &(*(null::())).deadflag as *const _ as usize }, - 212usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(deadflag) - ) - ); - assert_eq!( - unsafe { &(*(null::())).spectator as *const _ as usize }, - 216usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(spectator) - ) - ); - assert_eq!( - unsafe { &(*(null::())).movetype as *const _ as usize }, - 220usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(movetype) - ) - ); - assert_eq!( - unsafe { &(*(null::())).onground as *const _ as usize }, - 224usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(onground) - ) - ); - assert_eq!( - unsafe { &(*(null::())).waterlevel as *const _ as usize }, - 228usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(waterlevel) - ) - ); - assert_eq!( - unsafe { &(*(null::())).watertype as *const _ as usize }, - 232usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(watertype) - ) - ); - assert_eq!( - unsafe { &(*(null::())).oldwaterlevel as *const _ as usize }, - 236usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(oldwaterlevel) - ) - ); - assert_eq!( - unsafe { &(*(null::())).sztexturename as *const _ as usize }, - 240usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(sztexturename) - ) - ); - assert_eq!( - unsafe { &(*(null::())).chtexturetype as *const _ as usize }, - 496usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(chtexturetype) - ) - ); - assert_eq!( - unsafe { &(*(null::())).maxspeed as *const _ as usize }, - 500usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(maxspeed) - ) - ); - assert_eq!( - unsafe { &(*(null::())).clientmaxspeed as *const _ as usize }, - 504usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(clientmaxspeed) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iuser1 as *const _ as usize }, - 508usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(iuser1) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iuser2 as *const _ as usize }, - 512usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(iuser2) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iuser3 as *const _ as usize }, - 516usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(iuser3) - ) - ); - assert_eq!( - unsafe { &(*(null::())).iuser4 as *const _ as usize }, - 520usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(iuser4) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fuser1 as *const _ as usize }, - 524usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(fuser1) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fuser2 as *const _ as usize }, - 528usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(fuser2) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fuser3 as *const _ as usize }, - 532usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(fuser3) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fuser4 as *const _ as usize }, - 536usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(fuser4) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vuser1 as *const _ as usize }, - 540usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(vuser1) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vuser2 as *const _ as usize }, - 552usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(vuser2) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vuser3 as *const _ as usize }, - 564usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(vuser3) - ) - ); - assert_eq!( - unsafe { &(*(null::())).vuser4 as *const _ as usize }, - 576usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(vuser4) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numphysent as *const _ as usize }, - 588usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(numphysent) - ) - ); - assert_eq!( - unsafe { &(*(null::())).physents as *const _ as usize }, - 592usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(physents) - ) - ); - assert_eq!( - unsafe { &(*(null::())).nummoveent as *const _ as usize }, - 134992usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(nummoveent) - ) - ); - assert_eq!( - unsafe { &(*(null::())).moveents as *const _ as usize }, - 134996usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(moveents) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numvisent as *const _ as usize }, - 149332usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(numvisent) - ) - ); - assert_eq!( - unsafe { &(*(null::())).visents as *const _ as usize }, - 149336usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(visents) - ) - ); - assert_eq!( - unsafe { &(*(null::())).cmd as *const _ as usize }, - 283736usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(cmd) - ) - ); - assert_eq!( - unsafe { &(*(null::())).numtouch as *const _ as usize }, - 283788usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(numtouch) - ) - ); - assert_eq!( - unsafe { &(*(null::())).touchindex as *const _ as usize }, - 283792usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(touchindex) - ) - ); - assert_eq!( - unsafe { &(*(null::())).physinfo as *const _ as usize }, - 324592usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(physinfo) - ) - ); - assert_eq!( - unsafe { &(*(null::())).movevars as *const _ as usize }, - 324848usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(movevars) - ) - ); - assert_eq!( - unsafe { &(*(null::())).player_mins as *const _ as usize }, - 324852usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(player_mins) - ) - ); - assert_eq!( - unsafe { &(*(null::())).player_maxs as *const _ as usize }, - 324900usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(player_maxs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_Info_ValueForKey as *const _ as usize }, - 324948usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_Info_ValueForKey) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_Particle as *const _ as usize }, - 324952usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_Particle) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_TestPlayerPosition as *const _ as usize }, - 324956usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_TestPlayerPosition) - ) - ); - assert_eq!( - unsafe { &(*(null::())).Con_NPrintf as *const _ as usize }, - 324960usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(Con_NPrintf) - ) - ); - assert_eq!( - unsafe { &(*(null::())).Con_DPrintf as *const _ as usize }, - 324964usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(Con_DPrintf) - ) - ); - assert_eq!( - unsafe { &(*(null::())).Con_Printf as *const _ as usize }, - 324968usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(Con_Printf) - ) - ); - assert_eq!( - unsafe { &(*(null::())).Sys_FloatTime as *const _ as usize }, - 324972usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(Sys_FloatTime) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_StuckTouch as *const _ as usize }, - 324976usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_StuckTouch) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_PointContents as *const _ as usize }, - 324980usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_PointContents) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_TruePointContents as *const _ as usize }, - 324984usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_TruePointContents) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_HullPointContents as *const _ as usize }, - 324988usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_HullPointContents) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_PlayerTrace as *const _ as usize }, - 324992usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_PlayerTrace) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_TraceLine as *const _ as usize }, - 324996usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_TraceLine) - ) - ); - assert_eq!( - unsafe { &(*(null::())).RandomLong as *const _ as usize }, - 325000usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(RandomLong) - ) - ); - assert_eq!( - unsafe { &(*(null::())).RandomFloat as *const _ as usize }, - 325004usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(RandomFloat) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_GetModelType as *const _ as usize }, - 325008usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_GetModelType) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_GetModelBounds as *const _ as usize }, - 325012usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_GetModelBounds) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_HullForBsp as *const _ as usize }, - 325016usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_HullForBsp) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_TraceModel as *const _ as usize }, - 325020usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_TraceModel) - ) - ); - assert_eq!( - unsafe { &(*(null::())).COM_FileSize as *const _ as usize }, - 325024usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(COM_FileSize) - ) - ); - assert_eq!( - unsafe { &(*(null::())).COM_LoadFile as *const _ as usize }, - 325028usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(COM_LoadFile) - ) - ); - assert_eq!( - unsafe { &(*(null::())).COM_FreeFile as *const _ as usize }, - 325032usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(COM_FreeFile) - ) - ); - assert_eq!( - unsafe { &(*(null::())).memfgets as *const _ as usize }, - 325036usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(memfgets) - ) - ); - assert_eq!( - unsafe { &(*(null::())).runfuncs as *const _ as usize }, - 325040usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(runfuncs) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_PlaySound as *const _ as usize }, - 325044usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_PlaySound) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_TraceTexture as *const _ as usize }, - 325048usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_TraceTexture) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_PlaybackEventFull as *const _ as usize }, - 325052usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_PlaybackEventFull) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_PlayerTraceEx as *const _ as usize }, - 325056usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_PlayerTraceEx) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_TestPlayerPositionEx as *const _ as usize }, - 325060usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_TestPlayerPositionEx) - ) - ); - assert_eq!( - unsafe { &(*(null::())).PM_TraceLineEx as *const _ as usize }, - 325064usize, - concat!( - "Offset of field: ", - stringify!(playermove_s), - "::", - stringify!(PM_TraceLineEx) - ) - ); +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of playermove_s"][size_of::() - 325068usize]; + ["Alignment of playermove_s"][align_of::() - 4usize]; + ["Offset of field: playermove_s::player_index"] + [offset_of!(playermove_s, player_index) - 0usize]; + ["Offset of field: playermove_s::server"][offset_of!(playermove_s, server) - 4usize]; + ["Offset of field: playermove_s::multiplayer"][offset_of!(playermove_s, multiplayer) - 8usize]; + ["Offset of field: playermove_s::time"][offset_of!(playermove_s, time) - 12usize]; + ["Offset of field: playermove_s::frametime"][offset_of!(playermove_s, frametime) - 16usize]; + ["Offset of field: playermove_s::forward"][offset_of!(playermove_s, forward) - 20usize]; + ["Offset of field: playermove_s::right"][offset_of!(playermove_s, right) - 32usize]; + ["Offset of field: playermove_s::up"][offset_of!(playermove_s, up) - 44usize]; + ["Offset of field: playermove_s::origin"][offset_of!(playermove_s, origin) - 56usize]; + ["Offset of field: playermove_s::angles"][offset_of!(playermove_s, angles) - 68usize]; + ["Offset of field: playermove_s::oldangles"][offset_of!(playermove_s, oldangles) - 80usize]; + ["Offset of field: playermove_s::velocity"][offset_of!(playermove_s, velocity) - 92usize]; + ["Offset of field: playermove_s::movedir"][offset_of!(playermove_s, movedir) - 104usize]; + ["Offset of field: playermove_s::basevelocity"] + [offset_of!(playermove_s, basevelocity) - 116usize]; + ["Offset of field: playermove_s::view_ofs"][offset_of!(playermove_s, view_ofs) - 128usize]; + ["Offset of field: playermove_s::flDuckTime"][offset_of!(playermove_s, flDuckTime) - 140usize]; + ["Offset of field: playermove_s::bInDuck"][offset_of!(playermove_s, bInDuck) - 144usize]; + ["Offset of field: playermove_s::flTimeStepSound"] + [offset_of!(playermove_s, flTimeStepSound) - 148usize]; + ["Offset of field: playermove_s::iStepLeft"][offset_of!(playermove_s, iStepLeft) - 152usize]; + ["Offset of field: playermove_s::flFallVelocity"] + [offset_of!(playermove_s, flFallVelocity) - 156usize]; + ["Offset of field: playermove_s::punchangle"][offset_of!(playermove_s, punchangle) - 160usize]; + ["Offset of field: playermove_s::flSwimTime"][offset_of!(playermove_s, flSwimTime) - 172usize]; + ["Offset of field: playermove_s::flNextPrimaryAttack"] + [offset_of!(playermove_s, flNextPrimaryAttack) - 176usize]; + ["Offset of field: playermove_s::effects"][offset_of!(playermove_s, effects) - 180usize]; + ["Offset of field: playermove_s::flags"][offset_of!(playermove_s, flags) - 184usize]; + ["Offset of field: playermove_s::usehull"][offset_of!(playermove_s, usehull) - 188usize]; + ["Offset of field: playermove_s::gravity"][offset_of!(playermove_s, gravity) - 192usize]; + ["Offset of field: playermove_s::friction"][offset_of!(playermove_s, friction) - 196usize]; + ["Offset of field: playermove_s::oldbuttons"][offset_of!(playermove_s, oldbuttons) - 200usize]; + ["Offset of field: playermove_s::waterjumptime"] + [offset_of!(playermove_s, waterjumptime) - 204usize]; + ["Offset of field: playermove_s::dead"][offset_of!(playermove_s, dead) - 208usize]; + ["Offset of field: playermove_s::deadflag"][offset_of!(playermove_s, deadflag) - 212usize]; + ["Offset of field: playermove_s::spectator"][offset_of!(playermove_s, spectator) - 216usize]; + ["Offset of field: playermove_s::movetype"][offset_of!(playermove_s, movetype) - 220usize]; + ["Offset of field: playermove_s::onground"][offset_of!(playermove_s, onground) - 224usize]; + ["Offset of field: playermove_s::waterlevel"][offset_of!(playermove_s, waterlevel) - 228usize]; + ["Offset of field: playermove_s::watertype"][offset_of!(playermove_s, watertype) - 232usize]; + ["Offset of field: playermove_s::oldwaterlevel"] + [offset_of!(playermove_s, oldwaterlevel) - 236usize]; + ["Offset of field: playermove_s::sztexturename"] + [offset_of!(playermove_s, sztexturename) - 240usize]; + ["Offset of field: playermove_s::chtexturetype"] + [offset_of!(playermove_s, chtexturetype) - 496usize]; + ["Offset of field: playermove_s::maxspeed"][offset_of!(playermove_s, maxspeed) - 500usize]; + ["Offset of field: playermove_s::clientmaxspeed"] + [offset_of!(playermove_s, clientmaxspeed) - 504usize]; + ["Offset of field: playermove_s::iuser1"][offset_of!(playermove_s, iuser1) - 508usize]; + ["Offset of field: playermove_s::iuser2"][offset_of!(playermove_s, iuser2) - 512usize]; + ["Offset of field: playermove_s::iuser3"][offset_of!(playermove_s, iuser3) - 516usize]; + ["Offset of field: playermove_s::iuser4"][offset_of!(playermove_s, iuser4) - 520usize]; + ["Offset of field: playermove_s::fuser1"][offset_of!(playermove_s, fuser1) - 524usize]; + ["Offset of field: playermove_s::fuser2"][offset_of!(playermove_s, fuser2) - 528usize]; + ["Offset of field: playermove_s::fuser3"][offset_of!(playermove_s, fuser3) - 532usize]; + ["Offset of field: playermove_s::fuser4"][offset_of!(playermove_s, fuser4) - 536usize]; + ["Offset of field: playermove_s::vuser1"][offset_of!(playermove_s, vuser1) - 540usize]; + ["Offset of field: playermove_s::vuser2"][offset_of!(playermove_s, vuser2) - 552usize]; + ["Offset of field: playermove_s::vuser3"][offset_of!(playermove_s, vuser3) - 564usize]; + ["Offset of field: playermove_s::vuser4"][offset_of!(playermove_s, vuser4) - 576usize]; + ["Offset of field: playermove_s::numphysent"][offset_of!(playermove_s, numphysent) - 588usize]; + ["Offset of field: playermove_s::physents"][offset_of!(playermove_s, physents) - 592usize]; + ["Offset of field: playermove_s::nummoveent"] + [offset_of!(playermove_s, nummoveent) - 134992usize]; + ["Offset of field: playermove_s::moveents"][offset_of!(playermove_s, moveents) - 134996usize]; + ["Offset of field: playermove_s::numvisent"][offset_of!(playermove_s, numvisent) - 149332usize]; + ["Offset of field: playermove_s::visents"][offset_of!(playermove_s, visents) - 149336usize]; + ["Offset of field: playermove_s::cmd"][offset_of!(playermove_s, cmd) - 283736usize]; + ["Offset of field: playermove_s::numtouch"][offset_of!(playermove_s, numtouch) - 283788usize]; + ["Offset of field: playermove_s::touchindex"] + [offset_of!(playermove_s, touchindex) - 283792usize]; + ["Offset of field: playermove_s::physinfo"][offset_of!(playermove_s, physinfo) - 324592usize]; + ["Offset of field: playermove_s::movevars"][offset_of!(playermove_s, movevars) - 324848usize]; + ["Offset of field: playermove_s::player_mins"] + [offset_of!(playermove_s, player_mins) - 324852usize]; + ["Offset of field: playermove_s::player_maxs"] + [offset_of!(playermove_s, player_maxs) - 324900usize]; + ["Offset of field: playermove_s::PM_Info_ValueForKey"] + [offset_of!(playermove_s, PM_Info_ValueForKey) - 324948usize]; + ["Offset of field: playermove_s::PM_Particle"] + [offset_of!(playermove_s, PM_Particle) - 324952usize]; + ["Offset of field: playermove_s::PM_TestPlayerPosition"] + [offset_of!(playermove_s, PM_TestPlayerPosition) - 324956usize]; + ["Offset of field: playermove_s::Con_NPrintf"] + [offset_of!(playermove_s, Con_NPrintf) - 324960usize]; + ["Offset of field: playermove_s::Con_DPrintf"] + [offset_of!(playermove_s, Con_DPrintf) - 324964usize]; + ["Offset of field: playermove_s::Con_Printf"] + [offset_of!(playermove_s, Con_Printf) - 324968usize]; + ["Offset of field: playermove_s::Sys_FloatTime"] + [offset_of!(playermove_s, Sys_FloatTime) - 324972usize]; + ["Offset of field: playermove_s::PM_StuckTouch"] + [offset_of!(playermove_s, PM_StuckTouch) - 324976usize]; + ["Offset of field: playermove_s::PM_PointContents"] + [offset_of!(playermove_s, PM_PointContents) - 324980usize]; + ["Offset of field: playermove_s::PM_TruePointContents"] + [offset_of!(playermove_s, PM_TruePointContents) - 324984usize]; + ["Offset of field: playermove_s::PM_HullPointContents"] + [offset_of!(playermove_s, PM_HullPointContents) - 324988usize]; + ["Offset of field: playermove_s::PM_PlayerTrace"] + [offset_of!(playermove_s, PM_PlayerTrace) - 324992usize]; + ["Offset of field: playermove_s::PM_TraceLine"] + [offset_of!(playermove_s, PM_TraceLine) - 324996usize]; + ["Offset of field: playermove_s::RandomLong"] + [offset_of!(playermove_s, RandomLong) - 325000usize]; + ["Offset of field: playermove_s::RandomFloat"] + [offset_of!(playermove_s, RandomFloat) - 325004usize]; + ["Offset of field: playermove_s::PM_GetModelType"] + [offset_of!(playermove_s, PM_GetModelType) - 325008usize]; + ["Offset of field: playermove_s::PM_GetModelBounds"] + [offset_of!(playermove_s, PM_GetModelBounds) - 325012usize]; + ["Offset of field: playermove_s::PM_HullForBsp"] + [offset_of!(playermove_s, PM_HullForBsp) - 325016usize]; + ["Offset of field: playermove_s::PM_TraceModel"] + [offset_of!(playermove_s, PM_TraceModel) - 325020usize]; + ["Offset of field: playermove_s::COM_FileSize"] + [offset_of!(playermove_s, COM_FileSize) - 325024usize]; + ["Offset of field: playermove_s::COM_LoadFile"] + [offset_of!(playermove_s, COM_LoadFile) - 325028usize]; + ["Offset of field: playermove_s::COM_FreeFile"] + [offset_of!(playermove_s, COM_FreeFile) - 325032usize]; + ["Offset of field: playermove_s::memfgets"][offset_of!(playermove_s, memfgets) - 325036usize]; + ["Offset of field: playermove_s::runfuncs"][offset_of!(playermove_s, runfuncs) - 325040usize]; + ["Offset of field: playermove_s::PM_PlaySound"] + [offset_of!(playermove_s, PM_PlaySound) - 325044usize]; + ["Offset of field: playermove_s::PM_TraceTexture"] + [offset_of!(playermove_s, PM_TraceTexture) - 325048usize]; + ["Offset of field: playermove_s::PM_PlaybackEventFull"] + [offset_of!(playermove_s, PM_PlaybackEventFull) - 325052usize]; + ["Offset of field: playermove_s::PM_PlayerTraceEx"] + [offset_of!(playermove_s, PM_PlayerTraceEx) - 325056usize]; + ["Offset of field: playermove_s::PM_TestPlayerPositionEx"] + [offset_of!(playermove_s, PM_TestPlayerPositionEx) - 325060usize]; + ["Offset of field: playermove_s::PM_TraceLineEx"] + [offset_of!(playermove_s, PM_TraceLineEx) - 325064usize]; +}; +#[repr(C)] +#[derive(Debug)] +pub struct movevars_s { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug)] +pub struct hull_s { + _unused: [u8; 0], } diff --git a/src/ffi/pmplane.rs b/src/ffi/pmplane.rs index d28f8d90..36ba6135 100644 --- a/src/ffi/pmplane.rs +++ b/src/ffi/pmplane.rs @@ -1,8 +1,9 @@ -#![allow(unused, deref_nullptr)] +// `pmplane_t` struct is from generated bindgen in playermove.rs -use std::mem::{align_of, size_of}; +#![allow(unused, nonstandard_style, deref_nullptr)] + +use std::mem::{align_of, offset_of, size_of}; use std::os::raw::*; -use std::ptr::null; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -10,37 +11,10 @@ pub struct pmplane_t { pub normal: [f32; 3], pub dist: f32, } - -#[test] -fn bindgen_test_layout_pmplane_t() { - assert_eq!( - size_of::(), - 16usize, - concat!("Size of: ", stringify!(pmplane_t)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(pmplane_t)) - ); - assert_eq!( - unsafe { &(*(null::())).normal as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(pmplane_t), - "::", - stringify!(normal) - ) - ); - assert_eq!( - unsafe { &(*(null::())).dist as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(pmplane_t), - "::", - stringify!(dist) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of pmplane_t"][size_of::() - 16usize]; + ["Alignment of pmplane_t"][align_of::() - 4usize]; + ["Offset of field: pmplane_t::normal"][offset_of!(pmplane_t, normal) - 0usize]; + ["Offset of field: pmplane_t::dist"][offset_of!(pmplane_t, dist) - 12usize]; +}; diff --git a/src/ffi/pmtrace.rs b/src/ffi/pmtrace.rs index bffbab6b..d4135a4c 100644 --- a/src/ffi/pmtrace.rs +++ b/src/ffi/pmtrace.rs @@ -1,18 +1,23 @@ -#![allow(unused, deref_nullptr)] +// `pmtrace_s` struct is from generated bindgen in playermove.rs -use std::mem::{align_of, size_of}; +#![allow(unused, nonstandard_style, deref_nullptr)] + +use std::mem::{align_of, offset_of, size_of}; use std::os::raw::*; -use std::ptr::null; -use crate::ffi::pmplane::pmplane_t; +use super::pmplane::pmplane_t; + +pub const qboolean_false_: qboolean = 0; +pub const qboolean_true_: qboolean = 1; +pub type qboolean = c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct pmtrace_s { - pub allsolid: u32, - pub startsolid: u32, - pub inopen: u32, - pub inwater: u32, + pub allsolid: qboolean, + pub startsolid: qboolean, + pub inopen: qboolean, + pub inwater: qboolean, pub fraction: f32, pub endpos: [f32; 3], pub plane: pmplane_t, @@ -20,117 +25,18 @@ pub struct pmtrace_s { pub deltavelocity: [f32; 3], pub hitgroup: c_int, } - -#[test] -fn bindgen_test_layout_pmtrace_s() { - assert_eq!( - size_of::(), - 68usize, - concat!("Size of: ", stringify!(pmtrace_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(pmtrace_s)) - ); - assert_eq!( - unsafe { &(*(null::())).allsolid as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(pmtrace_s), - "::", - stringify!(allsolid) - ) - ); - assert_eq!( - unsafe { &(*(null::())).startsolid as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(pmtrace_s), - "::", - stringify!(startsolid) - ) - ); - assert_eq!( - unsafe { &(*(null::())).inopen as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(pmtrace_s), - "::", - stringify!(inopen) - ) - ); - assert_eq!( - unsafe { &(*(null::())).inwater as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(pmtrace_s), - "::", - stringify!(inwater) - ) - ); - assert_eq!( - unsafe { &(*(null::())).fraction as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(pmtrace_s), - "::", - stringify!(fraction) - ) - ); - assert_eq!( - unsafe { &(*(null::())).endpos as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(pmtrace_s), - "::", - stringify!(endpos) - ) - ); - assert_eq!( - unsafe { &(*(null::())).plane as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(pmtrace_s), - "::", - stringify!(plane) - ) - ); - assert_eq!( - unsafe { &(*(null::())).ent as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(pmtrace_s), - "::", - stringify!(ent) - ) - ); - assert_eq!( - unsafe { &(*(null::())).deltavelocity as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(pmtrace_s), - "::", - stringify!(deltavelocity) - ) - ); - assert_eq!( - unsafe { &(*(null::())).hitgroup as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(pmtrace_s), - "::", - stringify!(hitgroup) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of pmtrace_s"][size_of::() - 68usize]; + ["Alignment of pmtrace_s"][align_of::() - 4usize]; + ["Offset of field: pmtrace_s::allsolid"][offset_of!(pmtrace_s, allsolid) - 0usize]; + ["Offset of field: pmtrace_s::startsolid"][offset_of!(pmtrace_s, startsolid) - 4usize]; + ["Offset of field: pmtrace_s::inopen"][offset_of!(pmtrace_s, inopen) - 8usize]; + ["Offset of field: pmtrace_s::inwater"][offset_of!(pmtrace_s, inwater) - 12usize]; + ["Offset of field: pmtrace_s::fraction"][offset_of!(pmtrace_s, fraction) - 16usize]; + ["Offset of field: pmtrace_s::endpos"][offset_of!(pmtrace_s, endpos) - 20usize]; + ["Offset of field: pmtrace_s::plane"][offset_of!(pmtrace_s, plane) - 32usize]; + ["Offset of field: pmtrace_s::ent"][offset_of!(pmtrace_s, ent) - 48usize]; + ["Offset of field: pmtrace_s::deltavelocity"][offset_of!(pmtrace_s, deltavelocity) - 52usize]; + ["Offset of field: pmtrace_s::hitgroup"][offset_of!(pmtrace_s, hitgroup) - 64usize]; +}; diff --git a/src/ffi/triangleapi.rs b/src/ffi/triangleapi.rs index 5b2cc9ec..9186ea1a 100644 --- a/src/ffi/triangleapi.rs +++ b/src/ffi/triangleapi.rs @@ -1,8 +1,17 @@ +// bindgen halflife/common/triangleapi.h --allowlist-type "triangleapi_s" -- +// --target=i686-unknown-linux-gnu -Ihalflife/{public,common,engine} -include mathlib.h -include +// const.h +// Keep everything before the generated part +// The constants are `c_int` for code compatibility. Otherwise, the bindgen will generate `c_uint` +// Add `--allowlist-var 'TRI_.*'` to generate the constants +// Change `triangleapi_s` members who are functions from `Option` to `T` +// Remove the unnecessary qualifiers `::std::os::raw::` and `::std::mem::` +// Remove `model_s` dummy struct and import `model_s` from com_model.rs +// Change all `*mut ...` type arguments inside triangleapi_s struct members to `*const ...` + #![allow(unused, nonstandard_style, deref_nullptr, clippy::upper_case_acronyms)] -/* bindgen halflife/common/triangleapi.h --allowlist-type triangleapi_s --allowlist-var 'TRI_.*' - * -- --target=i686-unknown-linux-gnu > src/ffi/triangleapi.rs */ -use std::mem::{align_of, size_of}; +use std::mem::{align_of, offset_of, size_of}; use std::os::raw::*; use std::ptr::null; @@ -29,8 +38,15 @@ pub const kRenderGlow: c_int = 3; pub const kRenderTransAlpha: c_int = 4; pub const kRenderTransAdd: c_int = 5; +/* automatically generated by rust-bindgen 0.71.1 */ + +// intentionally commented out +// pub const TRICULLSTYLE_TRI_FRONT: TRICULLSTYLE = 0; +// pub const TRICULLSTYLE_TRI_NONE: TRICULLSTYLE = 1; +// pub type TRICULLSTYLE = c_uint; + #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct triangleapi_s { pub version: c_int, pub RenderMode: unsafe extern "C" fn(mode: c_int), @@ -44,226 +60,42 @@ pub struct triangleapi_s { pub Brightness: unsafe extern "C" fn(brightness: f32), pub CullFace: unsafe extern "C" fn(style: TRICULLSTYLE), pub SpriteTexture: unsafe extern "C" fn(pSpriteModel: *const model_s, frame: c_int) -> c_int, - pub WorldToScreen: unsafe extern "C" fn(world: *const f32, screen: *mut f32) -> c_int, - pub Fog: unsafe extern "C" fn(flFogColor: *const f32, flStart: f32, flEnd: f32, bOn: c_int), - pub ScreenToWorld: unsafe extern "C" fn(screen: *const f32, world: *mut f32), - pub GetMatrix: unsafe extern "C" fn(pname: c_int, matrix: *mut f32), + pub WorldToScreen: unsafe extern "C" fn(world: *const f32, screen: *const f32) -> c_int, + pub Fog: unsafe extern "C" fn(flFogColor: *mut f32, flStart: f32, flEnd: f32, bOn: c_int), + pub ScreenToWorld: unsafe extern "C" fn(screen: *const f32, world: *const f32), + pub GetMatrix: unsafe extern "C" fn(pname: c_int, matrix: *const f32), pub BoxInPVS: unsafe extern "C" fn(mins: *const f32, maxs: *const f32) -> c_int, - pub LightAtPoint: unsafe extern "C" fn(pos: *const f32, value: *mut f32), + pub LightAtPoint: unsafe extern "C" fn(pos: *const f32, value: *const f32), pub Color4fRendermode: unsafe extern "C" fn(r: f32, g: f32, b: f32, a: f32, rendermode: c_int), pub FogParams: unsafe extern "C" fn(flDensity: f32, iFogSkybox: c_int), } - -#[test] -fn bindgen_test_layout_triangleapi_s() { - assert_eq!( - size_of::(), - 80usize, - concat!("Size of: ", stringify!(triangleapi_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(triangleapi_s)) - ); - assert_eq!( - unsafe { &(*(null::())).version as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { &(*(null::())).RenderMode as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(RenderMode) - ) - ); - assert_eq!( - unsafe { &(*(null::())).Begin as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(Begin) - ) - ); - assert_eq!( - unsafe { &(*(null::())).End as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(End) - ) - ); - assert_eq!( - unsafe { &(*(null::())).Color4f as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(Color4f) - ) - ); - assert_eq!( - unsafe { &(*(null::())).Color4ub as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(Color4ub) - ) - ); - assert_eq!( - unsafe { &(*(null::())).TexCoord2f as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(TexCoord2f) - ) - ); - assert_eq!( - unsafe { &(*(null::())).Vertex3fv as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(Vertex3fv) - ) - ); - assert_eq!( - unsafe { &(*(null::())).Vertex3f as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(Vertex3f) - ) - ); - assert_eq!( - unsafe { &(*(null::())).Brightness as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(Brightness) - ) - ); - assert_eq!( - unsafe { &(*(null::())).CullFace as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(CullFace) - ) - ); - assert_eq!( - unsafe { &(*(null::())).SpriteTexture as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(SpriteTexture) - ) - ); - assert_eq!( - unsafe { &(*(null::())).WorldToScreen as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(WorldToScreen) - ) - ); - assert_eq!( - unsafe { &(*(null::())).Fog as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(Fog) - ) - ); - assert_eq!( - unsafe { &(*(null::())).ScreenToWorld as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(ScreenToWorld) - ) - ); - assert_eq!( - unsafe { &(*(null::())).GetMatrix as *const _ as usize }, - 60usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(GetMatrix) - ) - ); - assert_eq!( - unsafe { &(*(null::())).BoxInPVS as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(BoxInPVS) - ) - ); - assert_eq!( - unsafe { &(*(null::())).LightAtPoint as *const _ as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(LightAtPoint) - ) - ); - assert_eq!( - unsafe { &(*(null::())).Color4fRendermode as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(Color4fRendermode) - ) - ); - assert_eq!( - unsafe { &(*(null::())).FogParams as *const _ as usize }, - 76usize, - concat!( - "Offset of field: ", - stringify!(triangleapi_s), - "::", - stringify!(FogParams) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of triangleapi_s"][size_of::() - 80usize]; + ["Alignment of triangleapi_s"][align_of::() - 4usize]; + ["Offset of field: triangleapi_s::version"][offset_of!(triangleapi_s, version) - 0usize]; + ["Offset of field: triangleapi_s::RenderMode"][offset_of!(triangleapi_s, RenderMode) - 4usize]; + ["Offset of field: triangleapi_s::Begin"][offset_of!(triangleapi_s, Begin) - 8usize]; + ["Offset of field: triangleapi_s::End"][offset_of!(triangleapi_s, End) - 12usize]; + ["Offset of field: triangleapi_s::Color4f"][offset_of!(triangleapi_s, Color4f) - 16usize]; + ["Offset of field: triangleapi_s::Color4ub"][offset_of!(triangleapi_s, Color4ub) - 20usize]; + ["Offset of field: triangleapi_s::TexCoord2f"][offset_of!(triangleapi_s, TexCoord2f) - 24usize]; + ["Offset of field: triangleapi_s::Vertex3fv"][offset_of!(triangleapi_s, Vertex3fv) - 28usize]; + ["Offset of field: triangleapi_s::Vertex3f"][offset_of!(triangleapi_s, Vertex3f) - 32usize]; + ["Offset of field: triangleapi_s::Brightness"][offset_of!(triangleapi_s, Brightness) - 36usize]; + ["Offset of field: triangleapi_s::CullFace"][offset_of!(triangleapi_s, CullFace) - 40usize]; + ["Offset of field: triangleapi_s::SpriteTexture"] + [offset_of!(triangleapi_s, SpriteTexture) - 44usize]; + ["Offset of field: triangleapi_s::WorldToScreen"] + [offset_of!(triangleapi_s, WorldToScreen) - 48usize]; + ["Offset of field: triangleapi_s::Fog"][offset_of!(triangleapi_s, Fog) - 52usize]; + ["Offset of field: triangleapi_s::ScreenToWorld"] + [offset_of!(triangleapi_s, ScreenToWorld) - 56usize]; + ["Offset of field: triangleapi_s::GetMatrix"][offset_of!(triangleapi_s, GetMatrix) - 60usize]; + ["Offset of field: triangleapi_s::BoxInPVS"][offset_of!(triangleapi_s, BoxInPVS) - 64usize]; + ["Offset of field: triangleapi_s::LightAtPoint"] + [offset_of!(triangleapi_s, LightAtPoint) - 68usize]; + ["Offset of field: triangleapi_s::Color4fRendermode"] + [offset_of!(triangleapi_s, Color4fRendermode) - 72usize]; + ["Offset of field: triangleapi_s::FogParams"][offset_of!(triangleapi_s, FogParams) - 76usize]; +}; diff --git a/src/ffi/usercmd.rs b/src/ffi/usercmd.rs index 634bb80c..86eba795 100644 --- a/src/ffi/usercmd.rs +++ b/src/ffi/usercmd.rs @@ -1,156 +1,45 @@ -#![allow(unused, deref_nullptr)] +// `usercmd_s` struct is from generated bindgen in playermove.rs -use std::mem::{align_of, size_of}; +#![allow(unused, nonstandard_style, deref_nullptr)] + +use std::mem::{align_of, offset_of, size_of}; use std::os::raw::*; -use std::ptr::null; +pub type byte = c_uchar; + +// this type is expected to have Clone and Copy because of +// `my_CmdStart` in server.rs #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct usercmd_s { pub lerp_msec: c_short, - pub msec: c_uchar, - pub viewangles: [f32; 3usize], + pub msec: byte, + pub viewangles: [f32; 3], pub forwardmove: f32, pub sidemove: f32, pub upmove: f32, - pub lightlevel: c_uchar, + pub lightlevel: byte, pub buttons: c_ushort, - pub impulse: c_uchar, - pub weaponselect: c_uchar, + pub impulse: byte, + pub weaponselect: byte, pub impact_index: c_int, - pub impact_position: [f32; 3usize], -} - -#[test] -fn bindgen_test_layout_usercmd_s() { - assert_eq!( - size_of::(), - 52usize, - concat!("Size of: ", stringify!(usercmd_s)) - ); - assert_eq!( - align_of::(), - 4usize, - concat!("Alignment of ", stringify!(usercmd_s)) - ); - assert_eq!( - unsafe { &(*(null::())).lerp_msec as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(usercmd_s), - "::", - stringify!(lerp_msec) - ) - ); - assert_eq!( - unsafe { &(*(null::())).msec as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(usercmd_s), - "::", - stringify!(msec) - ) - ); - assert_eq!( - unsafe { &(*(null::())).viewangles as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(usercmd_s), - "::", - stringify!(viewangles) - ) - ); - assert_eq!( - unsafe { &(*(null::())).forwardmove as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(usercmd_s), - "::", - stringify!(forwardmove) - ) - ); - assert_eq!( - unsafe { &(*(null::())).sidemove as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(usercmd_s), - "::", - stringify!(sidemove) - ) - ); - assert_eq!( - unsafe { &(*(null::())).upmove as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(usercmd_s), - "::", - stringify!(upmove) - ) - ); - assert_eq!( - unsafe { &(*(null::())).lightlevel as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(usercmd_s), - "::", - stringify!(lightlevel) - ) - ); - assert_eq!( - unsafe { &(*(null::())).buttons as *const _ as usize }, - 30usize, - concat!( - "Offset of field: ", - stringify!(usercmd_s), - "::", - stringify!(buttons) - ) - ); - assert_eq!( - unsafe { &(*(null::())).impulse as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(usercmd_s), - "::", - stringify!(impulse) - ) - ); - assert_eq!( - unsafe { &(*(null::())).weaponselect as *const _ as usize }, - 33usize, - concat!( - "Offset of field: ", - stringify!(usercmd_s), - "::", - stringify!(weaponselect) - ) - ); - assert_eq!( - unsafe { &(*(null::())).impact_index as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(usercmd_s), - "::", - stringify!(impact_index) - ) - ); - assert_eq!( - unsafe { &(*(null::())).impact_position as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(usercmd_s), - "::", - stringify!(impact_position) - ) - ); + pub impact_position: [f32; 3], } +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of usercmd_s"][size_of::() - 52usize]; + ["Alignment of usercmd_s"][align_of::() - 4usize]; + ["Offset of field: usercmd_s::lerp_msec"][offset_of!(usercmd_s, lerp_msec) - 0usize]; + ["Offset of field: usercmd_s::msec"][offset_of!(usercmd_s, msec) - 2usize]; + ["Offset of field: usercmd_s::viewangles"][offset_of!(usercmd_s, viewangles) - 4usize]; + ["Offset of field: usercmd_s::forwardmove"][offset_of!(usercmd_s, forwardmove) - 16usize]; + ["Offset of field: usercmd_s::sidemove"][offset_of!(usercmd_s, sidemove) - 20usize]; + ["Offset of field: usercmd_s::upmove"][offset_of!(usercmd_s, upmove) - 24usize]; + ["Offset of field: usercmd_s::lightlevel"][offset_of!(usercmd_s, lightlevel) - 28usize]; + ["Offset of field: usercmd_s::buttons"][offset_of!(usercmd_s, buttons) - 30usize]; + ["Offset of field: usercmd_s::impulse"][offset_of!(usercmd_s, impulse) - 32usize]; + ["Offset of field: usercmd_s::weaponselect"][offset_of!(usercmd_s, weaponselect) - 33usize]; + ["Offset of field: usercmd_s::impact_index"][offset_of!(usercmd_s, impact_index) - 36usize]; + ["Offset of field: usercmd_s::impact_position"] + [offset_of!(usercmd_s, impact_position) - 40usize]; +};