11use  crate :: modules:: { Module ,  ModuleCtx } ; 
22use  crate :: { WorldSync ,  my_peer_id} ; 
33use  eyre:: { ContextCompat ,  eyre} ; 
4- use  noita_api:: heap; 
54use  noita_api:: noita:: types:: { CellType ,  FireCell ,  GasCell ,  LiquidCell ,  Vec2i } ; 
65use  noita_api:: noita:: world:: ParticleWorldState ; 
6+ use  noita_api:: { game_print,  heap} ; 
77use  rayon:: iter:: { IntoParallelIterator ,  ParallelIterator } ; 
88use  shared:: NoitaOutbound ; 
99use  shared:: world_sync:: { 
@@ -110,7 +110,6 @@ impl WorldData for ParticleWorldState {
110110        Ok ( ( ) ) 
111111    } 
112112    unsafe  fn  decode_world ( & self ,  chunk :  NoitaWorldUpdate )  -> eyre:: Result < ( ) >  { 
113-         return  Ok ( ( ) ) ;  // TODO 
114113        let  chunk_coord = chunk. coord ; 
115114        let  ( cx,  cy)  = ( chunk_coord. 0  as  isize ,  chunk_coord. 1  as  isize ) ; 
116115        let  Some ( pixel_array)  = unsafe  {  self . world_ptr . as_mut ( )  } 
@@ -129,35 +128,39 @@ impl WorldData for ParticleWorldState {
129128            let  cell = pixel_array. get_mut_raw ( shift_x + x,  shift_y + y) ; 
130129            let  xs = start_x + x; 
131130            let  ys = start_y + y; 
132-             let  Some ( mat)  = self . material_list . get_static ( pixel. mat ( )  as  usize )  else  { 
133-                 return  Err ( eyre ! ( "mat does not exist" ) ) ; 
134-             } ; 
135-             match  mat. cell_type  { 
136-                 CellType :: None  => { 
137-                     * cell = ptr:: null_mut ( ) ; 
138-                 } 
139-                 CellType :: Liquid  => { 
140-                     let  mut  liquid = unsafe  { 
141-                         LiquidCell :: create ( mat,  self . cell_vtables . liquid ( ) ,  self . world_ptr ) 
142-                     } ; 
143-                     liquid. x  = xs; 
144-                     liquid. y  = ys; 
145-                     * cell = heap:: place_new ( liquid) . cast ( ) ; 
146-                 } 
147-                 CellType :: Gas  => { 
148-                     let  mut  gas =
149-                         unsafe  {  GasCell :: create ( mat,  self . cell_vtables . gas ( ) ,  self . world_ptr )  } ; 
150-                     gas. x  = xs; 
151-                     gas. y  = ys; 
152-                     * cell = heap:: place_new ( gas) . cast ( ) ; 
153-                 } 
154-                 CellType :: Solid  => { } 
155-                 CellType :: Fire  => { 
156-                     let  mut  fire =
157-                         unsafe  {  FireCell :: create ( mat,  self . cell_vtables . fire ( ) ,  self . world_ptr )  } ; 
158-                     fire. x  = xs; 
159-                     fire. y  = ys; 
160-                     * cell = heap:: place_new ( fire) . cast ( ) ; 
131+             if  pixel. is_air ( )  { 
132+                 * cell = ptr:: null_mut ( ) ; 
133+             }  else  { 
134+                 let  Some ( mat)  = self . material_list . get_static ( pixel. mat ( )  as  usize )  else  { 
135+                     return  Err ( eyre ! ( "mat does not exist" ) ) ; 
136+                 } ; 
137+                 match  mat. cell_type  { 
138+                     CellType :: None  => { } 
139+                     CellType :: Liquid  => { 
140+                         let  mut  liquid = unsafe  { 
141+                             LiquidCell :: create ( mat,  self . cell_vtables . liquid ( ) ,  self . world_ptr ) 
142+                         } ; 
143+                         liquid. x  = xs; 
144+                         liquid. y  = ys; 
145+                         * cell = heap:: place_new ( liquid) . cast ( ) ; 
146+                     } 
147+                     CellType :: Gas  => { 
148+                         let  mut  gas = unsafe  { 
149+                             GasCell :: create ( mat,  self . cell_vtables . gas ( ) ,  self . world_ptr ) 
150+                         } ; 
151+                         gas. x  = xs; 
152+                         gas. y  = ys; 
153+                         * cell = heap:: place_new ( gas) . cast ( ) ; 
154+                     } 
155+                     CellType :: Solid  => { } 
156+                     CellType :: Fire  => { 
157+                         let  mut  fire = unsafe  { 
158+                             FireCell :: create ( mat,  self . cell_vtables . fire ( ) ,  self . world_ptr ) 
159+                         } ; 
160+                         fire. x  = xs; 
161+                         fire. y  = ys; 
162+                         * cell = heap:: place_new ( fire) . cast ( ) ; 
163+                     } 
161164                } 
162165            } 
163166        } 
0 commit comments