check if line is numeric before appending it to pixel data; check if colour ID is ok
This commit is contained in:
parent
5184060372
commit
f18b0de251
|
@ -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;
|
use std::error::Error;
|
||||||
|
|
||||||
/// avatar is a "sprite" in the game data but with a specific id
|
/// 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") {
|
} else if last_line.starts_with("NAME") {
|
||||||
name = Some(last_line.replace("NAME ", ""));
|
name = Some(last_line.replace("NAME ", ""));
|
||||||
} else if last_line.starts_with("COL") {
|
} else if last_line.starts_with("COL") {
|
||||||
colour_id = Some(last_line.replace("COL ", "").parse().unwrap());
|
let last_line = last_line.replace("COL ", "");
|
||||||
|
let result = last_line.parse();
|
||||||
|
if result.is_ok() {
|
||||||
|
colour_id = Some(result.unwrap());
|
||||||
} else {
|
} else {
|
||||||
|
println!("Bad colour id: {}", last_line)
|
||||||
|
}
|
||||||
|
} else if is_string_numeric(last_line.to_string()) {
|
||||||
lines.push(last_line);
|
lines.push(last_line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue