return error instead of panicking on sprite missing position

This commit is contained in:
Max Bradbury 2020-10-16 16:04:55 +01:00
parent eede24b13c
commit 1967be3635
1 changed files with 5 additions and 1 deletions

View File

@ -84,7 +84,11 @@ impl Sprite {
return Err(SpriteMissingRoomPosition);
}
position = Some(Position::from_str(room_position[1]).unwrap());
if let Ok(pos) = Position::from_str(room_position[1]) {
position = Some(pos);
} else {
return Err(SpriteMissingRoomPosition);
}
} else if last_line.starts_with("COL") {
colour_id = Some(last_line.replace("COL ", "").parse().unwrap());
} else if last_line.starts_with("ITM") {