From 68e75a55f0cfbadbf6e08a9fd388fba8ca5c9749 Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 27 Apr 2020 22:53:05 -0600 Subject: [PATCH] don't rely on map file data to have monster area --- src/ship/map.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ship/map.rs b/src/ship/map.rs index 52e297e..8d8375c 100644 --- a/src/ship/map.rs +++ b/src/ship/map.rs @@ -85,7 +85,7 @@ pub struct MapEnemy { } impl MapEnemy { - fn from_raw(enemy: RawMapEnemy, episode: &Episode /*, battleparam */) -> Result { + fn from_raw(enemy: RawMapEnemy, episode: &Episode, map_area: &MapArea /*, battleparam */) -> Result { let monster = match (enemy, episode) { (RawMapEnemy {id: 64, ..}, _) => MonsterType::Hildebear, (RawMapEnemy {id: 65, ..}, Episode::Four) => MonsterType::SandRappy, @@ -174,7 +174,7 @@ impl MapEnemy { Ok(MapEnemy { monster: monster, - map_area: MapArea::from_value(&episode, enemy.map_area as u32)?, + map_area: map_area.clone(), hp: 0, dropped_item: false, gave_exp: false, @@ -534,11 +534,12 @@ fn objects_from_map_data(path: PathBuf, episode: &Episode) -> Vec Vec> { +fn enemy_data_from_map_data(map_variant: &MapVariant, episode: &Episode) -> Vec> { + let path = map_variant.dat_file(); let mut cursor = File::open(path).unwrap(); let mut enemy_data = Vec::new(); while let Ok(enemy) = RawMapEnemy::from_byte_stream(&mut cursor) { - let new_enemy = MapEnemy::from_raw(enemy, episode); + let new_enemy = MapEnemy::from_raw(enemy, episode, &map_variant.map); enemy_data.append(&mut new_enemy .map_or(vec![None], |monster| { let mut monsters = Vec::new(); @@ -666,7 +667,7 @@ impl Maps { let mut maps = Maps { enemy_data: map_variants.iter().fold(Vec::new(), |mut enemy_data, map_variant| { - enemy_data.append(&mut enemy_data_from_map_data(map_variant.dat_file().into(), &episode)); + enemy_data.append(&mut enemy_data_from_map_data(&map_variant, &episode)); enemy_data }), object_data: map_variants.iter().map(|map_variant| {