Skip to content

Commit

Permalink
Guarantee that town stair without wilderness overwrites a floor
Browse files Browse the repository at this point in the history
Resolves #401 .
  • Loading branch information
backwardsEric authored and NickMcConnell committed May 12, 2024
1 parent acd5524 commit d77a08e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/gen-cave.c
Original file line number Diff line number Diff line change
Expand Up @@ -2533,13 +2533,16 @@ static struct loc place_town_stairs(struct chunk *c, struct player *p,
}
} else {
/* Dungeon towns just have a single down stair */
grid.x = rand_spread(c->width / 2, c->width / 12);
grid.y = c->height / 2;
while (square_isfloor(c, grid) && (grid.y > 2)) {
grid.y--;
}
if (square_isfloor(c, next_grid(grid, DIR_N)) && (grid.y == 2)) {
grid.y--;
while (1) {
grid.x = rand_spread(c->width / 2, c->width / 12);
grid.y = 0;
while (!square_isfloor(c, grid)
&& grid.y < c->height / 2) {
++grid.y;
}
if (grid.y < c->height / 2) {
break;
}
}

/* Clear previous contents, add down stairs */
Expand Down

0 comments on commit d77a08e

Please sign in to comment.