MCPcopy Create free account
hub / github.com/AdRoll/rustenstein / get_plane

Function get_plane

src/cache.rs:525–540  ·  view source on GitHub ↗
(data: &[u8], offset: i32, length: u16, magic_rlew_word: &[u8; 2])

Source from the content-addressed store, hash-verified

523}
524
525fn get_plane(data: &[u8], offset: i32, length: u16, magic_rlew_word: &[u8; 2]) -> [[u16; 64]; 64] {
526 let plane_start = offset as usize;
527 let plane_end = plane_start + length as usize;
528 let decarmackized = carmack_decompress(&data[plane_start..plane_end]);
529 let bytes = rlew_decompress(&decarmackized[4..], magic_rlew_word);
530 let mut bytes = bytes
531 .chunks_exact(2)
532 .map(|word| u16::from_le_bytes(word.try_into().unwrap()));
533 let mut result = [[0; MAP_HEIGHT]; MAP_WIDTH];
534 for y in 0..MAP_HEIGHT {
535 for x in result.iter_mut().take(MAP_WIDTH) {
536 x[y] = bytes.next().unwrap();
537 }
538 }
539 result
540}
541
542fn parse_map_data<P: AsRef<Path>>(path: P, meta: MapHead) -> Vec<Map> {
543 let raw_data = fs::read(path).expect("could not read GAMEMAPS file");

Callers 1

parse_map_dataFunction · 0.85

Calls 2

carmack_decompressFunction · 0.85
rlew_decompressFunction · 0.85

Tested by

no test coverage detected