diff --git a/src/game.rs b/src/game.rs index bcd7d00..6878c15 100644 --- a/src/game.rs +++ b/src/game.rs @@ -95,23 +95,26 @@ impl Game { } let string = string.trim_start_matches("\n").to_string(); - let segments = segments_from_string(string); + let mut segments = segments_from_string(string); let mut name = "".to_string(); if - ! segments[0].starts_with("# BITSY VERSION") + ! segments[0].starts_with("# BITSY VERSION ") && - ! segments[0].starts_with("! ROOM_FORMAT") + ! segments[0].starts_with("! ROOM_FORMAT ") && - ! segments[0].starts_with("PAL") + ! segments[0].starts_with("PAL ") && - ! segments[0].starts_with("DEFAULT_FONT") + ! segments[0].starts_with("DEFAULT_FONT ") && - ! segments[0].starts_with("TEXT_DIRECTION") { + ! segments[0].starts_with("TEXT_DIRECTION ") { name = segments[0].to_string(); + segments = segments[1..].to_owned(); } + let segments = segments; + let name = name; let mut dialogues: Vec = Vec::new(); let mut endings: Vec = Vec::new(); @@ -148,28 +151,28 @@ impl Game { } } else if segment.trim() == "TEXT_DIRECTION RTL".to_string() { text_direction = TextDirection::RightToLeft; - } else if segment.starts_with("PAL") { + } else if segment.starts_with("PAL ") { palettes.push(Palette::from(segment)); - } else if segment.starts_with("ROOM") || segment.starts_with("SET") { - if segment.starts_with("SET") { + } else if segment.starts_with("ROOM ") || segment.starts_with("SET ") { + if segment.starts_with("SET ") { room_type = RoomType::Set; } rooms.push(Room::from(segment)); - } else if segment.starts_with("TIL") { + } else if segment.starts_with("TIL ") { tiles.push(Tile::from(segment)); } else if segment.starts_with("SPR A") { avatar = Some(Sprite::from(segment)); } else if segment.starts_with("SPR ") { sprites.push(Sprite::from(segment)); - } else if segment.starts_with("ITM") { + } else if segment.starts_with("ITM ") { items.push(Item::from(segment)); - } else if segment.starts_with("DLG") { + } else if segment.starts_with("DLG ") { dialogues.push(Dialogue::from(segment)); - } else if segment.starts_with("END") { + } else if segment.starts_with("END ") { endings.push(Ending::from(segment)); - } else if segment.starts_with("VAR") { + } else if segment.starts_with("VAR ") { variables.push(Variable::from(segment)); - } else if segment.starts_with("FONT") { + } else if segment.starts_with("FONT ") { font_data = Some(segment); } }