be a bit more fussy about checking for segment names - game title "PALACE" was being parsed as a palette... :(

This commit is contained in:
Max Bradbury 2020-04-26 13:33:04 +01:00
parent cf1ca6f1b5
commit daa46e26ee
1 changed files with 18 additions and 15 deletions

View File

@ -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<Dialogue> = Vec::new();
let mut endings: Vec<Ending> = 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);
}
}