Skip to content

Commit

Permalink
Fix dead ends deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
deathgrindfreak committed Apr 6, 2022
1 parent 04fc0fc commit ce4d9ef
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ impl Dungeon {

while !dead_ends.is_empty() {
let cell = dead_ends.pop().unwrap();

// If we have a door as a neighbor, just skip filling this in
if Direction::iterator().any(|&d| self.get_tile(cell + d.dir()) == Tile::Door) {
continue;
}

self.fill_cell(cell);

if self.animate {
Expand All @@ -144,10 +150,7 @@ impl Dungeon {
let next_cell = cell + d.dir();

let number_of_floors = Direction::iterator().map(|&d| {
match self.get_tile(next_cell + d.dir()) {
Tile::Floor | Tile::Door => 1,
_ => 0,
}
if self.get_tile(next_cell + d.dir()) == Tile::Floor { 1 } else { 0 }
}).sum::<i32>();

// If we're still in a single, long corridor keep removing
Expand Down

0 comments on commit ce4d9ef

Please sign in to comment.