-/* NetHack 3.7 display.c $NHDT-Date: 1654931503 2022/06/11 07:11:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.184 $ */
+/* NetHack 3.7 display.c $NHDT-Date: 1657918092 2022/07/15 20:48:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.190 $ */
/* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
/* and Dave Cohrs, 1990. */
/* NetHack may be freely redistributed. See license for details. */
static boolean more_than_one(coordxy, coordxy, coordxy, coordxy, coordxy);
#endif
-static int set_twall(coordxy, coordxy, coordxy, coordxy, coordxy, coordxy, coordxy, coordxy);
+static int set_twall(coordxy, coordxy, coordxy, coordxy,
+ coordxy, coordxy, coordxy, coordxy);
static int set_wall(coordxy, coordxy, int);
-static int set_corn(coordxy, coordxy, coordxy, coordxy, coordxy, coordxy, coordxy, coordxy);
+static int set_corn(coordxy, coordxy, coordxy, coordxy,
+ coordxy, coordxy, coordxy, coordxy);
static int set_crosswall(coordxy, coordxy);
static void set_seenv(struct rm *, coordxy, coordxy, coordxy, coordxy);
static void t_warn(struct rm *);
/* ------------------------------------------------------------------------ */
/* This matrix is used here and in vision.c. */
-unsigned char seenv_matrix[3][3] = { { SV2, SV1, SV0 },
- { SV3, SVALL, SV7 },
- { SV4, SV5, SV6 } };
+const seenV seenv_matrix[3][3] = {
+ { SV2, SV1, SV0 },
+ { SV3, SVALL, SV7 },
+ { SV4, SV5, SV6 }
+};
#define sign(z) ((z) < 0 ? -1 : ((z) > 0 ? 1 : 0))
/* Set the seen vector of lev as if seen from (x0,y0) to (x,y). */
static void
-set_seenv(struct rm *lev,
- coordxy x0, coordxy y0, coordxy x, coordxy y) /* from, to */
+set_seenv(
+ struct rm *lev,
+ coordxy x0, coordxy y0, /* from */
+ coordxy x, coordxy y) /* to */
{
coordxy dx = x - x0, dy = y0 - y;
/* Called by blackout(vault.c) when vault guard removes temporary corridor,
turning spot <x0,y0> back coordxyo stone; <x1,y1> is an adjacent spot. */
void
-unset_seenv(struct rm *lev, /* &levl[x1][y1] */
- coordxy x0, coordxy y0,
- coordxy x1, coordxy y1) /* from, to; abs(x1-x0)==1
- && abs(y0-y1)==1 */
+unset_seenv(
+ struct rm *lev, /* &levl[x1][y1] */
+ coordxy x0, coordxy y0, /* from */
+ coordxy x1, coordxy y1) /* to; abs(x1-x0)==1 && abs(y0-y1)==1 */
+
{
coordxy dx = x1 - x0, dy = y0 - y1;
-/* NetHack 3.7 vision.c $NHDT-Date: 1596498225 2020/08/03 23:43:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.38 $ */
+/* NetHack 3.7 vision.c $NHDT-Date: 1657918095 2022/07/15 20:48:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.49 $ */
/* Copyright (c) Dean Luick, with acknowledgements to Dave Cohrs, 1990. */
/* NetHack may be freely redistributed. See license for details. */
/*------ local variables ------*/
-static coordxy could_see[2][ROWNO][COLNO]; /* vision work space */
-static coordxy *cs_rows0[ROWNO], *cs_rows1[ROWNO];
+static seenV could_see[2][ROWNO][COLNO]; /* vision work space */
+static seenV *cs_rows0[ROWNO], *cs_rows1[ROWNO];
static coordxy cs_rmin0[ROWNO], cs_rmax0[ROWNO];
static coordxy cs_rmin1[ROWNO], cs_rmax1[ROWNO];
static void fill_point(int, int);
static void dig_point(int, int);
static void view_init(void);
-static void view_from(coordxy, coordxy, coordxy **, coordxy *, coordxy *, int,
+static void view_from(coordxy, coordxy, seenV **, coordxy *, coordxy *, int,
void (*)(coordxy, coordxy, genericptr_t),
genericptr_t);
-static void get_unused_cs(coordxy ***, coordxy **, coordxy **);
-static void rogue_vision(coordxy **, coordxy *, coordxy *);
+static void get_unused_cs(seenV ***, coordxy **, coordxy **);
+static void rogue_vision(seenV **, coordxy *, coordxy *);
/* Macro definitions that I can't find anywhere. */
#define sign(z) ((z) < 0 ? -1 : ((z) ? 1 : 0))
* to the unused vision work area.
*/
static void
-get_unused_cs(coordxy ***rows, coordxy **rmin, coordxy **rmax)
+get_unused_cs(seenV ***rows, coordxy **rmin, coordxy **rmax)
{
register int row;
register coordxy *nrmin, *nrmax;
nrmin = *rmin;
nrmax = *rmax;
- (void) memset((genericptr_t) **rows, 0, sizeof(coordxy) * (ROWNO * COLNO)); /* see nothing */
+ (void) memset((genericptr_t) **rows, 0,
+ ROWNO * COLNO * sizeof (seenV)); /* see nothing */
for (row = 0; row < ROWNO; row++) { /* set row min & max */
*nrmin++ = COLNO - 1;
*nrmax++ = 1;
* due to the one-sided lit wall hack.
*/
static void
-rogue_vision(coordxy **next, coordxy *rmin, coordxy *rmax)
+rogue_vision(seenV **next, coordxy *rmin, coordxy *rmax)
{
int rnum = levl[u.ux][u.uy].roomno - ROOMOFFSET; /* no SHARED... */
int start, stop, in_door, xhi, xlo, yhi, ylo;
void
vision_recalc(int control)
{
- extern unsigned char seenv_matrix[3][3]; /* from display.c */
- static unsigned char colbump[COLNO + 1]; /* cols to bump sv */
- coordxy **temp_array; /* points to the old vision array */
- coordxy **next_array; /* points to the new vision array */
- coordxy *next_row; /* row pointer for the new array */
- coordxy *old_row; /* row pointer for the old array */
- coordxy *next_rmin; /* min pointer for the new array */
- coordxy *next_rmax; /* max pointer for the new array */
+ extern const seenV seenv_matrix[3][3]; /* from display.c */
+ static coordxy colbump[COLNO + 1]; /* cols to bump sv */
+ seenV **temp_array; /* points to the old vision array */
+ seenV **next_array; /* points to the new vision array */
+ seenV *next_row; /* row pointer for the new array */
+ seenV *old_row; /* row pointer for the old array */
+ coordxy *next_rmin; /* min pointer for the new array */
+ coordxy *next_rmax; /* max pointer for the new array */
const coordxy *ranges; /* circle ranges -- used for xray & night vision */
int row = 0; /* row counter (outer loop) */
int start, stop; /* inner loop starting/stopping index */
register int col; /* inner loop counter */
register struct rm *lev; /* pointer to current pos */
struct rm *flev; /* pointer to position in "front" of current pos */
- unsigned char *sv; /* ptr to seen angle bits */
+ const seenV *sv; /* ptr to seen angle bits */
int oldseenv; /* previous seenv value */
g.vision_full_recalc = 0; /* reset flag */
static int start_row;
static int start_col;
static int step;
-static coordxy **cs_rows;
+static seenV **cs_rows;
static coordxy *cs_left;
static coordxy *cs_right;
* limits points at range limit for current row, or NULL
*/
static void
-right_side(int row, int left, int right_mark, const coordxy *limits)
+right_side(
+ int row,
+ int left,
+ int right_mark,
+ const coordxy *limits)
{
int right; /* right limit of "could see" */
int right_edge; /* right edge of an opening */
int deeper; /* if TRUE, call self as needed */
int result; /* set by q?_path() */
register int i; /* loop counter */
- register coordxy *rowp = NULL; /* row optimization */
- coordxy *row_min = NULL; /* left most [used by macro set_min()] */
- coordxy *row_max = NULL; /* right most [used by macro set_max()] */
+ register seenV *rowp = NULL; /* row optimization */
+ coordxy *row_min = NULL; /* left most [used by macro set_min()] */
+ coordxy *row_max = NULL; /* right most [used by macro set_max()] */
int lim_max; /* right most limit of circle */
nrow = row + step;
* extensive comments.
*/
static void
-left_side(int row, int left_mark, int right, const coordxy *limits)
+left_side(
+ int row,
+ int left_mark,
+ int right,
+ const coordxy *limits)
{
int left, left_edge, nrow, deeper, result;
register int i;
- register coordxy *rowp = NULL;
+ register seenV *rowp = NULL;
coordxy *row_min = NULL;
coordxy *row_max = NULL;
int lim_min;
-#ifdef GCC_WARN
- rowp = row_min = row_max = 0;
-#endif
nrow = row + step;
deeper = good_row(nrow) && (!limits || (*limits >= *(limits + 1)));
if (!vis_func) {
* arg argument for func
*/
static void
-view_from(coordxy srow, coordxy scol, coordxy **loc_cs_rows,
- coordxy *left_most, coordxy *right_most, int range,
- void (*func)(coordxy, coordxy, genericptr_t), genericptr_t arg)
+view_from(
+ coordxy srow, coordxy scol,
+ seenV **loc_cs_rows,
+ coordxy *left_most, coordxy *right_most,
+ int range,
+ void (*func)(coordxy, coordxy, genericptr_t),
+ genericptr_t arg)
{
register int i; /* loop counter */
- coordxy *rowp; /* optimization for setting could_see */
+ seenV *rowp; /* optimization for setting could_see */
int nrow; /* the next row */
int left; /* the left-most visible column */
int right; /* the right-most visible column */
* vision matrix and reduce extra work.
*/
void
-do_clear_area(coordxy scol, coordxy srow, int range,
- void (*func)(coordxy, coordxy, genericptr_t), genericptr_t arg)
+do_clear_area(
+ coordxy scol, coordxy srow,
+ int range,
+ void (*func)(coordxy, coordxy, genericptr_t),
+ genericptr_t arg)
{
/* If not centered on hero, do the hard work of figuring the area */
if (scol != u.ux || srow != u.uy) {
- view_from(srow, scol, (coordxy **) 0, (coordxy *) 0, (coordxy *) 0, range,
- func, arg);
+ view_from(srow, scol, (seenV **) 0, (coordxy *) 0, (coordxy *) 0,
+ range, func, arg);
} else {
register int x;
int y, min_x, max_x, max_y, offset;