Fix bug in nametable exporter
parent
37f82daca1
commit
8d4ade5f8e
|
@ -76,8 +76,9 @@ pub fn get_tilemap( tilemap: &TiledTilemap ) -> Result<Vec<u8>, Box<dyn Error>>
|
|||
let layer_a: Option<&Layer> = tilemap.layers.iter().find( | layer | matches!( layer, Layer::Tile { system_plane: SystemPlane::MdPlaneA, tiles: _ } ) );
|
||||
|
||||
// Each entry in a `--system md` tilemap is 16 bits
|
||||
let mut nametable: Vec<u16> = vec![ 0; tilemap.width * tilemap.height ];
|
||||
let mut total_nametable: Vec<u16> = Vec::new();
|
||||
|
||||
let mut nametable: Vec<u16> = vec![ 0; tilemap.width * tilemap.height ];
|
||||
if let Some( layer_b ) = layer_b {
|
||||
let layer_b = match layer_b {
|
||||
Layer::Tile { system_plane: _, tiles } => tiles,
|
||||
|
@ -103,9 +104,11 @@ pub fn get_tilemap( tilemap: &TiledTilemap ) -> Result<Vec<u8>, Box<dyn Error>>
|
|||
}
|
||||
}
|
||||
}
|
||||
total_nametable.extend( nametable.iter() );
|
||||
|
||||
// Just do the same for layer a
|
||||
// Copy pasted because i'm lazy and tired
|
||||
let mut nametable: Vec<u16> = vec![ 0; tilemap.width * tilemap.height ];
|
||||
if let Some( layer_a ) = layer_a {
|
||||
let layer_a = match layer_a {
|
||||
Layer::Tile { system_plane: _, tiles } => tiles,
|
||||
|
@ -131,11 +134,12 @@ pub fn get_tilemap( tilemap: &TiledTilemap ) -> Result<Vec<u8>, Box<dyn Error>>
|
|||
}
|
||||
}
|
||||
}
|
||||
total_nametable.extend( nametable.iter() );
|
||||
|
||||
// Convert the u16's to a series of u8 data
|
||||
let mut result: Vec<u8> = Vec::new();
|
||||
for i in 0..nametable.len() {
|
||||
let bytes = nametable[ i ].to_be_bytes();
|
||||
for i in 0..total_nametable.len() {
|
||||
let bytes = total_nametable[ i ].to_be_bytes();
|
||||
for i in 0..2 {
|
||||
result.push( bytes[ i ] );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue