diff --git a/src/avatar.rs b/src/avatar.rs index 3357ec4..a4c3939 100644 --- a/src/avatar.rs +++ b/src/avatar.rs @@ -1,4 +1,4 @@ -use crate::{from_base36, optional_data_line, AnimationFrames, Image, Position, ToBase36}; +use crate::{from_base36, optional_data_line, AnimationFrames, Image, Position, ToBase36, is_string_numeric}; use std::error::Error; /// avatar is a "sprite" in the game data but with a specific id @@ -51,8 +51,14 @@ impl Avatar { } else if last_line.starts_with("NAME") { name = Some(last_line.replace("NAME ", "")); } else if last_line.starts_with("COL") { - colour_id = Some(last_line.replace("COL ", "").parse().unwrap()); - } else { + let last_line = last_line.replace("COL ", ""); + let result = last_line.parse(); + if result.is_ok() { + colour_id = Some(result.unwrap()); + } else { + println!("Bad colour id: {}", last_line) + } + } else if is_string_numeric(last_line.to_string()) { lines.push(last_line); break; }