Skip to content

Commit

Permalink
FIX: Assign interior cell flags based on the actual prop value and no…
Browse files Browse the repository at this point in the history
…t just whether it exists in the set
  • Loading branch information
magicaldave committed Oct 15, 2024
1 parent a46daf7 commit 7bfe1de
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/game_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,18 @@ pub fn book(entity_props: &HashMap<&String, &String>, ref_id: &str, mesh_name: &
pub fn cell(entity_props: &HashMap<&String, &String>, ref_id: &str) -> Cell {
let mut flags = CellFlags::default() | CellFlags::IS_INTERIOR;

if let Ok(_) = get_prop("FakeExterior", entity_props).parse::<u32>() {
flags |= CellFlags::BEHAVES_LIKE_EXTERIOR;
}

if let Ok(_) = get_prop("HasWater", entity_props).parse::<u32>() {
flags |= CellFlags::HAS_WATER;
};

if let Ok(_) = get_prop("RestIsIllegal", entity_props).parse::<u32>() {
flags |= CellFlags::RESTING_IS_ILLEGAL;
};
flags |= [
("FakeExterior", CellFlags::BEHAVES_LIKE_EXTERIOR),
("RestIsIllegal", CellFlags::RESTING_IS_ILLEGAL),
("HasWater", CellFlags::HAS_WATER),
]
.iter()
.fold(CellFlags::empty(), |acc, &(prop, flag)| {
acc | match get_prop(prop, entity_props).parse::<u32>() {
Ok(1) => flag,
_ => CellFlags::empty(),
}
});

Cell {
flags: ObjectFlags::default(),
Expand Down

0 comments on commit 7bfe1de

Please sign in to comment.