Browse Source

Merge pull request 'don't rely on map file data to have monster area' (#117) from fix_monster_area_gaps into master

pbs
jake 5 years ago
parent
commit
d1ec1d7359
  1. 11
      src/ship/map.rs

11
src/ship/map.rs

@ -85,7 +85,7 @@ pub struct MapEnemy {
}
impl MapEnemy {
fn from_raw(enemy: RawMapEnemy, episode: &Episode /*, battleparam */) -> Result<MapEnemy, MapEnemyError> {
fn from_raw(enemy: RawMapEnemy, episode: &Episode, map_area: &MapArea /*, battleparam */) -> Result<MapEnemy, MapEnemyError> {
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<Option<MapObje
}
fn enemy_data_from_map_data(path: PathBuf, episode: &Episode) -> Vec<Option<MapEnemy>> {
fn enemy_data_from_map_data(map_variant: &MapVariant, episode: &Episode) -> Vec<Option<MapEnemy>> {
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| {

Loading…
Cancel
Save