Browse Source

lint src/ship/quests.rs

pull/42/head
jake 3 years ago
parent
commit
c3c0f031ed
  1. 15
      src/ship/quests.rs

15
src/ship/quests.rs

@ -73,18 +73,18 @@ fn read_dat_section_header<T: Read + Seek>(cursor: &mut T, episode: &Episode, ma
match header {
DAT_OBJECT_HEADER_ID => {
let mut obj_data = vec![0u8; length as usize];
cursor.read(&mut obj_data)?;
cursor.read_exact(&mut obj_data)?;
let mut obj_cursor = Cursor::new(obj_data);
let objects = objects_from_stream(&mut obj_cursor, episode, &map_area);
let objects = objects_from_stream(&mut obj_cursor, episode, map_area);
Ok(DatBlock::Object(objects))
},
DAT_ENEMY_HEADER_ID => {
let mut enemy_data = vec![0u8; length as usize];
cursor.read(&mut enemy_data)?;
cursor.read_exact(&mut enemy_data)?;
let mut enemy_cursor = Cursor::new(enemy_data);
let enemies = enemy_data_from_stream(&mut enemy_cursor, &map_area, episode);
let enemies = enemy_data_from_stream(&mut enemy_cursor, map_area, episode);
Ok(DatBlock::Enemy(enemies))
},
@ -100,7 +100,7 @@ fn quest_episode(bin: &[u8]) -> Option<Episode> {
for bytes in bin.windows(3) {
// set_episode
if bytes[0] == 0xF8 && bytes[1] == 0xBC {
return Some(Episode::from_quest(bytes[2]).ok()?)
return Episode::from_quest(bytes[2]).ok()
}
}
None
@ -121,6 +121,7 @@ fn map_area_mappings(bin: &[u8]) -> MapAreaLookup {
map_areas.build()
}
#[allow(clippy::type_complexity)]
fn parse_dat(dat: &[u8], episode: &Episode, map_areas: &MapAreaLookup) -> Result<(Vec<Option<MapEnemy>>, Vec<Option<MapObject>>), ParseDatError> {
let mut cursor = Cursor::new(dat);
@ -185,9 +186,9 @@ impl Quest {
let (enemies, objects) = parse_dat(&dat, &episode, &map_areas)?;
let mut prs_bin = LegacyPrsEncoder::new(Vec::new());
prs_bin.write(&bin)?;
prs_bin.write_all(&bin)?;
let mut prs_dat = LegacyPrsEncoder::new(Vec::new());
prs_dat.write(&dat)?;
prs_dat.write_all(&dat)?;
Ok(Quest {
name: name,

Loading…
Cancel
Save