git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7389 c06c8d41-db1a-0410-9941-cceddc491573
ADNUOKDM2BLXCMGW6FOI3KYKDPIUUDJJXESMWDVSXXR5TZCGQ5YQC
// Similar to the above, checks whether turning a wall grid into floor
// would create a short "dead-end" of only 1 grid.
//
// In the example below, X would create dead-ends at positions a and b,
// but both Y and Z avoid this, and the resulting mini-mazes looks better.
//
// ######## (A) ######## (B) ######## (C) ########
// #.....#. #....a#. #.....#. #.....#.
// #.#YXZ#. #.##.##. #.#.###. #.###.#.
// #.#..... #.#b.... #.#..... #.#.....
//
// In general, if a floor grid horizontally or vertically adjacent to the
// change target has a floor neighbour diagonally adjacent to the change
// target, the next neighbour in the same direction needs to be floor,
// as well.
static bool _deadend_check_floor(const coord_def &p)
{
if (grid_is_wall(grd[p.x-1][p.y]))
{
for (int i = -1; i <= 1; i++)
{
if (i == 0)
continue;
const coord_def a(p.x, p.y+2*i);
if (!in_bounds(a) || _is_floor(grd(a)))
continue;
for (int j = -1; j <= 1; j++)
{
if (j == 0)
continue;
const coord_def b(p.x+2*j, p.y+i);
if (!in_bounds(b))
continue;
const coord_def c(p.x+j, p.y+i);
if (_is_floor(grd(c)) && !_is_floor(grd(b)))
return (false);
}
}
}
else
{
for (int i = -1; i <= 1; i++)
{
if (i == 0)
continue;
const coord_def a(p.x+2*i, p.y);
if (!in_bounds(a) || _is_floor(grd(a)))
continue;
for (int j = -1; j <= 1; j++)
{
if (j == 0)
continue;
const coord_def b(p.x+i, p.y+2*j);
if (!in_bounds(b))
continue;
const coord_def c(p.x+i, p.y+j);
if (_is_floor(grd(c)) && !_is_floor(grd(b)))
return (false);
}
}
}
return (true);
}
(int) grd(c), c.x, c.y,
(int) grd(points[pick]), points[pick].x, points[pick].y);
(int) old_grid, c.x, c.y, (int) grd(p), p.x, p.y);
}
// Rather than use old_grid directly, replace with the adjacent
// wall type.
old_grid = grd[p.x-1][p.y];
if (!grid_is_wall(old_grid))
{
old_grid = grd[p.x][p.y-1];
if (!grid_is_wall(old_grid))
{
if (msg)
{
mprf(MSGCH_DIAGNOSTICS,
"No adjacent walls at pos (%d, %d)?", p.x, p.y);
}
old_grid = DNGN_STONE_WALL;
}