Skip to content

Commit

Permalink
fix: InfiniteTileLayerData index of out bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
smackysnacks committed May 29, 2024
1 parent 49881df commit d2a7933
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/layers/tile/infinite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ impl InfiniteTileLayerData {
let internal_pos = (x - chunk.x, y - chunk.y);
let internal_index = (internal_pos.0 + internal_pos.1 * chunk.width as i32) as usize;

if internal_index >= chunk.tiles.len() {
return Err(Error::InvalidTileFound);
}

chunks.entry(chunk_pos).or_insert_with(ChunkData::new).tiles[chunk_index] = chunk.tiles[internal_index];
}
}
Expand Down

0 comments on commit d2a7933

Please sign in to comment.