error handling for endings

This commit is contained in:
2020-10-18 12:27:54 +01:00
parent 7896ef1232
commit dba84e01fa
2 changed files with 11 additions and 11 deletions

View File

@@ -2,7 +2,6 @@ use crate::{Dialogue, Ending, Font, Image, Item, Palette, Room, Sprite, TextDire
use loe::TransformMode;
use std::str::FromStr;
use std::collections::HashMap;
use std::borrow::BorrowMut;
use std::fmt;
@@ -226,8 +225,11 @@ impl Game {
} else if segment.starts_with("DLG ") {
dialogues.push(Dialogue::from(segment));
} else if segment.starts_with("END ") {
if let Ok(ending) = Ending::from_str(&segment) {
let result = Ending::from_str(&segment);
if let Ok(ending) = result {
endings.push(ending);
} else {
warnings.push(result.unwrap_err());
}
} else if segment.starts_with("VAR ") {
variables.push(Variable::from(segment));