special levels 'grow selection'

Fixes #132

This is based on the commit for github pull request #132, which
indicates that the 'grow' pattern is reversed from what the .des
file specifies.  I don't understand how this is really supposed
to work and the only place nethack uses it is on the Valkyrie Home
level, which seems to be created roughly the same both before and
after this change.
This commit is contained in:
PatR
2018-09-20 15:19:50 -07:00
parent 3edc6d3147
commit 49e4330cb2

View File

@@ -3827,7 +3827,7 @@ selection_do_grow(ov, dir)
struct opvar *ov;
int dir;
{
int x, y, c;
int x, y;
char tmp[COLNO][ROWNO];
if (ov->spovartyp != SPOVAR_SEL)
@@ -3835,40 +3835,31 @@ int dir;
if (!ov)
return;
(void) memset(tmp, 0, sizeof(tmp));
(void) memset(tmp, 0, sizeof tmp);
for (x = 0; x < COLNO; x++)
for (x = 1; x < COLNO; x++)
for (y = 0; y < ROWNO; y++) {
c = 0;
if ((dir & W_WEST) && (x > 0)
&& (selection_getpoint(x - 1, y, ov)))
c++;
if ((dir & (W_WEST | W_NORTH)) && (x > 0) && (y > 0)
&& (selection_getpoint(x - 1, y - 1, ov)))
c++;
if ((dir & W_NORTH) && (y > 0)
&& (selection_getpoint(x, y - 1, ov)))
c++;
if ((dir & (W_NORTH | W_EAST)) && (y > 0) && (x < COLNO - 1)
&& (selection_getpoint(x + 1, y - 1, ov)))
c++;
if ((dir & W_EAST) && (x < COLNO - 1)
&& (selection_getpoint(x + 1, y, ov)))
c++;
if ((dir & (W_EAST | W_SOUTH)) && (x < COLNO - 1)
&& (y < ROWNO - 1) && (selection_getpoint(x + 1, y + 1, ov)))
c++;
if ((dir & W_SOUTH) && (y < ROWNO - 1)
&& (selection_getpoint(x, y + 1, ov)))
c++;
if ((dir & (W_SOUTH | W_WEST)) && (y < ROWNO - 1) && (x > 0)
&& (selection_getpoint(x - 1, y + 1, ov)))
c++;
if (c)
/* note: dir is a mask of multiple directions, but the only
way to specify diagonals is by including the two adjacent
orthogonal directions, which effectively specifies three-
way growth [WEST|NORTH => WEST plus WEST|NORTH plus NORTH] */
if (((dir & W_WEST) && selection_getpoint(x + 1, y, ov))
|| (((dir & (W_WEST | W_NORTH)) == (W_WEST | W_NORTH))
&& selection_getpoint(x + 1, y + 1, ov))
|| ((dir & W_NORTH) && selection_getpoint(x, y + 1, ov))
|| (((dir & (W_NORTH | W_EAST)) == (W_NORTH | W_EAST))
&& selection_getpoint(x - 1, y + 1, ov))
|| ((dir & W_EAST) && selection_getpoint(x - 1, y, ov))
|| (((dir & (W_EAST | W_SOUTH)) == (W_EAST | W_SOUTH))
&& selection_getpoint(x - 1, y - 1, ov))
|| ((dir & W_SOUTH) && selection_getpoint(x, y - 1, ov))
|| (((dir & (W_SOUTH | W_WEST)) == (W_SOUTH | W_WEST))
&& selection_getpoint(x + 1, y - 1, ov))) {
tmp[x][y] = 1;
}
}
for (x = 0; x < COLNO; x++)
for (x = 1; x < COLNO; x++)
for (y = 0; y < ROWNO; y++)
if (tmp[x][y])
selection_setpoint(x, y, ov, 1);