mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
use ntypes::CellData type for mat list ptr and blob ptr
This commit is contained in:
parent
d7bad41632
commit
07bdcd64b3
2 changed files with 11 additions and 10 deletions
|
@ -54,7 +54,7 @@ fn init_particle_world_state(lua: LuaState) -> eyre::Result<()> {
|
|||
#[cfg(target_arch = "x86")]
|
||||
let world_ptr = lua.to_integer(1) as *const c_void;
|
||||
let chunk_map_ptr = unsafe { (lua.to_integer(2) as *const c_void).offset(8) };
|
||||
let material_list_ptr = lua.to_integer(3) as *const c_void;
|
||||
let material_list_ptr = lua.to_integer(3) as *const noita::ntypes::CellData;
|
||||
#[cfg(target_arch = "x86")]
|
||||
let construct_ptr = lua.to_integer(4) as *const c_void;
|
||||
#[cfg(target_arch = "x86")]
|
||||
|
@ -67,10 +67,7 @@ fn init_particle_world_state(lua: LuaState) -> eyre::Result<()> {
|
|||
chunk_map_ptr,
|
||||
material_list_ptr,
|
||||
blob_guy,
|
||||
blob_ptr: unsafe {
|
||||
material_list_ptr
|
||||
.offset(size_of::<noita::ntypes::CellData>() as isize * blob_guy as isize)
|
||||
},
|
||||
blob_ptr: unsafe { material_list_ptr.offset(blob_guy as isize) },
|
||||
#[cfg(target_arch = "x86")]
|
||||
construct_ptr,
|
||||
#[cfg(target_arch = "x86")]
|
||||
|
|
|
@ -10,9 +10,9 @@ pub(crate) struct ParticleWorldState {
|
|||
#[cfg(target_arch = "x86")]
|
||||
pub(crate) world_ptr: *const c_void,
|
||||
pub(crate) chunk_map_ptr: *const c_void,
|
||||
pub(crate) material_list_ptr: *const c_void,
|
||||
pub(crate) material_list_ptr: *const ntypes::CellData,
|
||||
pub(crate) blob_guy: u16,
|
||||
pub(crate) blob_ptr: *const c_void,
|
||||
pub(crate) blob_ptr: *const ntypes::CellData,
|
||||
#[cfg(target_arch = "x86")]
|
||||
pub(crate) construct_ptr: *const c_void,
|
||||
#[cfg(target_arch = "x86")]
|
||||
|
@ -25,7 +25,7 @@ impl ParticleWorldState {
|
|||
&self,
|
||||
x: isize,
|
||||
y: isize,
|
||||
material: *const c_void,
|
||||
material: *const ntypes::CellData,
|
||||
//_memory: *const c_void,
|
||||
) -> *const ntypes::Cell {
|
||||
#[cfg(target_arch = "x86")]
|
||||
|
@ -132,8 +132,12 @@ impl ParticleWorldState {
|
|||
}
|
||||
fn get_cell_material_id(&self, cell: &ntypes::Cell) -> u16 {
|
||||
let mat_ptr = cell.material_ptr();
|
||||
let offset = unsafe { mat_ptr.cast::<c_void>().offset_from(self.material_list_ptr) };
|
||||
(offset / size_of::<ntypes::CellData>() as isize) as u16
|
||||
let offset = unsafe {
|
||||
mat_ptr
|
||||
.cast::<ntypes::CellData>()
|
||||
.offset_from(self.material_list_ptr)
|
||||
};
|
||||
offset as u16
|
||||
}
|
||||
|
||||
fn get_cell_type(&self, cell: &ntypes::Cell) -> Option<ntypes::CellType> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue