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

Function parse_map_data

src/cache.rs:542–575  ·  view source on GitHub ↗
(path: P, meta: MapHead)

Source from the content-addressed store, hash-verified

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");
544 let mut maps = Vec::new();
545
546 for pointer in meta.pointers {
547 let pointer = pointer as usize;
548 let header = MapLevelHeader::new(&raw_data[pointer..(pointer + 38)]);
549
550 if header.offset_plane0 == 0 {
551 continue;
552 }
553
554 assert_eq!(64, header.width_n_tiles);
555 assert_eq!(64, header.height_n_tiles);
556
557 // plane2 is unused in wolf, skipping
558 maps.push(Map::new(
559 get_plane(
560 &raw_data,
561 header.offset_plane0,
562 header.length_plane0,
563 &meta.magic,
564 ),
565 get_plane(
566 &raw_data,
567 header.offset_plane1,
568 header.length_plane1,
569 &meta.magic,
570 ),
571 header.name,
572 ));
573 }
574 maps
575}
576
577#[cfg(test)]
578mod tests {

Callers 1

load_mapsFunction · 0.85

Calls 1

get_planeFunction · 0.85

Tested by

no test coverage detected