Home | History | Annotate | Line # | Download | only in hack
hack.pri.c revision 1.7
      1  1.7       wiz /*	$NetBSD: hack.pri.c,v 1.7 2002/05/26 00:12:12 wiz Exp $	*/
      2  1.5  christos 
      3  1.2   mycroft /*
      4  1.2   mycroft  * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
      5  1.2   mycroft  */
      6  1.2   mycroft 
      7  1.5  christos #include <sys/cdefs.h>
      8  1.2   mycroft #ifndef lint
      9  1.7       wiz __RCSID("$NetBSD: hack.pri.c,v 1.7 2002/05/26 00:12:12 wiz Exp $");
     10  1.5  christos #endif				/* not lint */
     11  1.1       cgd 
     12  1.1       cgd #include "hack.h"
     13  1.5  christos #include "extern.h"
     14  1.5  christos xchar           scrlx, scrhx, scrly, scrhy;	/* corners of new area on
     15  1.5  christos 						 * screen */
     16  1.1       cgd 
     17  1.5  christos void
     18  1.1       cgd swallowed()
     19  1.1       cgd {
     20  1.5  christos 	char            ulook[] = "|@|";
     21  1.1       cgd 	ulook[1] = u.usym;
     22  1.1       cgd 
     23  1.1       cgd 	cls();
     24  1.5  christos 	curs(u.ux - 1, u.uy + 1);
     25  1.1       cgd 	fputs("/-\\", stdout);
     26  1.5  christos 	curx = u.ux + 2;
     27  1.5  christos 	curs(u.ux - 1, u.uy + 2);
     28  1.1       cgd 	fputs(ulook, stdout);
     29  1.5  christos 	curx = u.ux + 2;
     30  1.5  christos 	curs(u.ux - 1, u.uy + 3);
     31  1.1       cgd 	fputs("\\-/", stdout);
     32  1.5  christos 	curx = u.ux + 2;
     33  1.1       cgd 	u.udispl = 1;
     34  1.1       cgd 	u.udisx = u.ux;
     35  1.1       cgd 	u.udisy = u.uy;
     36  1.1       cgd }
     37  1.1       cgd 
     38  1.1       cgd 
     39  1.5  christos /* VARARGS1 */
     40  1.5  christos boolean         panicking;
     41  1.1       cgd 
     42  1.5  christos void
     43  1.5  christos panic(const char *fmt, ...)
     44  1.5  christos {
     45  1.5  christos 	va_list ap;
     46  1.7       wiz 
     47  1.5  christos 	va_start(ap, fmt);
     48  1.5  christos 	if (panicking++)
     49  1.5  christos 		exit(1);	/* avoid loops - this should never happen */
     50  1.1       cgd 	home();
     51  1.1       cgd 	puts(" Suddenly, the dungeon collapses.");
     52  1.1       cgd 	fputs(" ERROR:  ", stdout);
     53  1.5  christos 	vprintf(fmt, ap);
     54  1.5  christos 	va_end(ap);
     55  1.1       cgd #ifdef DEBUG
     56  1.1       cgd #ifdef UNIX
     57  1.5  christos 	if (!fork())
     58  1.1       cgd 		abort();	/* generate core dump */
     59  1.5  christos #endif	/* UNIX */
     60  1.5  christos #endif	/* DEBUG */
     61  1.1       cgd 	more();			/* contains a fflush() */
     62  1.1       cgd 	done("panicked");
     63  1.1       cgd }
     64  1.1       cgd 
     65  1.5  christos void
     66  1.5  christos atl(x, y, ch)
     67  1.5  christos int x, y, ch;
     68  1.1       cgd {
     69  1.5  christos 	struct rm      *crm = &levl[x][y];
     70  1.1       cgd 
     71  1.5  christos 	if (x < 0 || x > COLNO - 1 || y < 0 || y > ROWNO - 1) {
     72  1.5  christos 		impossible("atl(%d,%d,%c)", x, y, ch);
     73  1.1       cgd 		return;
     74  1.1       cgd 	}
     75  1.5  christos 	if (crm->seen && crm->scrsym == ch)
     76  1.5  christos 		return;
     77  1.1       cgd 	crm->scrsym = ch;
     78  1.1       cgd 	crm->new = 1;
     79  1.5  christos 	on_scr(x, y);
     80  1.1       cgd }
     81  1.1       cgd 
     82  1.5  christos void
     83  1.5  christos on_scr(x, y)
     84  1.5  christos int x, y;
     85  1.5  christos {
     86  1.5  christos 	if (x < scrlx)
     87  1.5  christos 		scrlx = x;
     88  1.5  christos 	if (x > scrhx)
     89  1.5  christos 		scrhx = x;
     90  1.5  christos 	if (y < scrly)
     91  1.5  christos 		scrly = y;
     92  1.5  christos 	if (y > scrhy)
     93  1.5  christos 		scrhy = y;
     94  1.1       cgd }
     95  1.1       cgd 
     96  1.5  christos /*
     97  1.5  christos  * call: (x,y) - display (-1,0) - close (leave last symbol) (-1,-1)- close
     98  1.5  christos  * (undo last symbol) (-1,let)-open: initialize symbol (-2,let)-change let
     99  1.5  christos  */
    100  1.1       cgd 
    101  1.5  christos void
    102  1.5  christos tmp_at(x, y)
    103  1.5  christos 	schar           x, y;
    104  1.5  christos {
    105  1.5  christos 	static schar    prevx, prevy;
    106  1.5  christos 	static char     let;
    107  1.5  christos 	if ((int) x == -2) {	/* change let call */
    108  1.1       cgd 		let = y;
    109  1.1       cgd 		return;
    110  1.1       cgd 	}
    111  1.5  christos 	if ((int) x == -1 && (int) y >= 0) {	/* open or close call */
    112  1.1       cgd 		let = y;
    113  1.1       cgd 		prevx = -1;
    114  1.1       cgd 		return;
    115  1.1       cgd 	}
    116  1.5  christos 	if (prevx >= 0 && cansee(prevx, prevy)) {
    117  1.1       cgd 		delay_output();
    118  1.1       cgd 		prl(prevx, prevy);	/* in case there was a monster */
    119  1.1       cgd 		at(prevx, prevy, levl[prevx][prevy].scrsym);
    120  1.1       cgd 	}
    121  1.5  christos 	if (x >= 0) {		/* normal call */
    122  1.5  christos 		if (cansee(x, y))
    123  1.5  christos 			at(x, y, let);
    124  1.1       cgd 		prevx = x;
    125  1.1       cgd 		prevy = y;
    126  1.5  christos 	} else {		/* close call */
    127  1.1       cgd 		let = 0;
    128  1.1       cgd 		prevx = -1;
    129  1.1       cgd 	}
    130  1.1       cgd }
    131  1.1       cgd 
    132  1.1       cgd /* like the previous, but the symbols are first erased on completion */
    133  1.5  christos void
    134  1.5  christos Tmp_at(x, y)
    135  1.5  christos 	schar           x, y;
    136  1.5  christos {
    137  1.5  christos 	static char     let;
    138  1.5  christos 	static xchar    cnt;
    139  1.5  christos 	static coord    tc[COLNO];	/* but watch reflecting beams! */
    140  1.5  christos 	int xx, yy;
    141  1.5  christos 	if ((int) x == -1) {
    142  1.5  christos 		if (y > 0) {	/* open call */
    143  1.1       cgd 			let = y;
    144  1.1       cgd 			cnt = 0;
    145  1.1       cgd 			return;
    146  1.1       cgd 		}
    147  1.1       cgd 		/* close call (do not distinguish y==0 and y==-1) */
    148  1.5  christos 		while (cnt--) {
    149  1.1       cgd 			xx = tc[cnt].x;
    150  1.1       cgd 			yy = tc[cnt].y;
    151  1.1       cgd 			prl(xx, yy);
    152  1.1       cgd 			at(xx, yy, levl[xx][yy].scrsym);
    153  1.1       cgd 		}
    154  1.1       cgd 		cnt = let = 0;	/* superfluous */
    155  1.1       cgd 		return;
    156  1.1       cgd 	}
    157  1.5  christos 	if ((int) x == -2) {	/* change let call */
    158  1.1       cgd 		let = y;
    159  1.1       cgd 		return;
    160  1.1       cgd 	}
    161  1.1       cgd 	/* normal call */
    162  1.5  christos 	if (cansee(x, y)) {
    163  1.5  christos 		if (cnt)
    164  1.5  christos 			delay_output();
    165  1.5  christos 		at(x, y, let);
    166  1.1       cgd 		tc[cnt].x = x;
    167  1.1       cgd 		tc[cnt].y = y;
    168  1.5  christos 		if (++cnt >= COLNO)
    169  1.5  christos 			panic("Tmp_at overflow?");
    170  1.1       cgd 		levl[x][y].new = 0;	/* prevent pline-nscr erasing --- */
    171  1.1       cgd 	}
    172  1.1       cgd }
    173  1.1       cgd 
    174  1.5  christos void
    175  1.5  christos setclipped()
    176  1.5  christos {
    177  1.1       cgd 	error("Hack needs a screen of size at least %d by %d.\n",
    178  1.5  christos 	      ROWNO + 2, COLNO);
    179  1.1       cgd }
    180  1.1       cgd 
    181  1.5  christos void
    182  1.5  christos at(x, y, ch)
    183  1.5  christos 	xchar           x, y;
    184  1.5  christos 	char            ch;
    185  1.1       cgd {
    186  1.1       cgd #ifndef lint
    187  1.1       cgd 	/* if xchar is unsigned, lint will complain about  if(x < 0)  */
    188  1.5  christos 	if (x < 0 || x > COLNO - 1 || y < 0 || y > ROWNO - 1) {
    189  1.1       cgd 		impossible("At gets 0%o at %d %d.", ch, x, y);
    190  1.1       cgd 		return;
    191  1.1       cgd 	}
    192  1.5  christos #endif	/* lint */
    193  1.5  christos 	if (!ch) {
    194  1.1       cgd 		impossible("At gets null at %d %d.", x, y);
    195  1.1       cgd 		return;
    196  1.1       cgd 	}
    197  1.1       cgd 	y += 2;
    198  1.5  christos 	curs(x, y);
    199  1.1       cgd 	(void) putchar(ch);
    200  1.1       cgd 	curx++;
    201  1.1       cgd }
    202  1.1       cgd 
    203  1.5  christos void
    204  1.5  christos prme()
    205  1.5  christos {
    206  1.5  christos 	if (!Invisible)
    207  1.5  christos 		at(u.ux, u.uy, u.usym);
    208  1.1       cgd }
    209  1.1       cgd 
    210  1.5  christos int
    211  1.1       cgd doredraw()
    212  1.1       cgd {
    213  1.1       cgd 	docrt();
    214  1.5  christos 	return (0);
    215  1.1       cgd }
    216  1.1       cgd 
    217  1.5  christos void
    218  1.1       cgd docrt()
    219  1.1       cgd {
    220  1.5  christos 	int x, y;
    221  1.5  christos 	struct rm      *room;
    222  1.5  christos 	struct monst   *mtmp;
    223  1.1       cgd 
    224  1.5  christos 	if (u.uswallow) {
    225  1.1       cgd 		swallowed();
    226  1.1       cgd 		return;
    227  1.1       cgd 	}
    228  1.1       cgd 	cls();
    229  1.1       cgd 
    230  1.5  christos 	/*
    231  1.5  christos 	 * Some ridiculous code to get display of @ and monsters (almost)
    232  1.5  christos 	 * right
    233  1.5  christos 	 */
    234  1.5  christos 	if (!Invisible) {
    235  1.1       cgd 		levl[(u.udisx = u.ux)][(u.udisy = u.uy)].scrsym = u.usym;
    236  1.1       cgd 		levl[u.udisx][u.udisy].seen = 1;
    237  1.1       cgd 		u.udispl = 1;
    238  1.5  christos 	} else
    239  1.5  christos 		u.udispl = 0;
    240  1.1       cgd 
    241  1.5  christos 	seemons();		/* reset old positions */
    242  1.5  christos 	for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
    243  1.1       cgd 		mtmp->mdispl = 0;
    244  1.5  christos 	seemons();		/* force new positions to be shown */
    245  1.5  christos 	/*
    246  1.5  christos 	 * This nonsense should disappear soon
    247  1.5  christos 	 * ---------------------------------
    248  1.5  christos 	 */
    249  1.5  christos 
    250  1.5  christos 	for (y = 0; y < ROWNO; y++)
    251  1.5  christos 		for (x = 0; x < COLNO; x++)
    252  1.5  christos 			if ((room = &levl[x][y])->new) {
    253  1.1       cgd 				room->new = 0;
    254  1.5  christos 				at(x, y, room->scrsym);
    255  1.5  christos 			} else if (room->seen)
    256  1.5  christos 				at(x, y, room->scrsym);
    257  1.1       cgd 	scrlx = COLNO;
    258  1.1       cgd 	scrly = ROWNO;
    259  1.1       cgd 	scrhx = scrhy = 0;
    260  1.1       cgd 	flags.botlx = 1;
    261  1.1       cgd 	bot();
    262  1.1       cgd }
    263  1.1       cgd 
    264  1.5  christos void
    265  1.5  christos docorner(xmin, ymax)
    266  1.5  christos 	int xmin, ymax;
    267  1.5  christos {
    268  1.5  christos 	int x, y;
    269  1.5  christos 	struct rm      *room;
    270  1.5  christos 	struct monst   *mtmp;
    271  1.1       cgd 
    272  1.5  christos 	if (u.uswallow) {	/* Can be done more efficiently */
    273  1.1       cgd 		swallowed();
    274  1.1       cgd 		return;
    275  1.1       cgd 	}
    276  1.5  christos 	seemons();		/* reset old positions */
    277  1.5  christos 	for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
    278  1.5  christos 		if (mtmp->mx >= xmin && mtmp->my < ymax)
    279  1.5  christos 			mtmp->mdispl = 0;
    280  1.5  christos 	seemons();		/* force new positions to be shown */
    281  1.5  christos 
    282  1.5  christos 	for (y = 0; y < ymax; y++) {
    283  1.5  christos 		if (y > ROWNO && CD)
    284  1.5  christos 			break;
    285  1.5  christos 		curs(xmin, y + 2);
    286  1.1       cgd 		cl_end();
    287  1.5  christos 		if (y < ROWNO) {
    288  1.5  christos 			for (x = xmin; x < COLNO; x++) {
    289  1.5  christos 				if ((room = &levl[x][y])->new) {
    290  1.5  christos 					room->new = 0;
    291  1.5  christos 					at(x, y, room->scrsym);
    292  1.5  christos 				} else if (room->seen)
    293  1.5  christos 					at(x, y, room->scrsym);
    294  1.5  christos 			}
    295  1.1       cgd 		}
    296  1.1       cgd 	}
    297  1.5  christos 	if (ymax > ROWNO) {
    298  1.5  christos 		cornbot(xmin - 1);
    299  1.5  christos 		if (ymax > ROWNO + 1 && CD) {
    300  1.5  christos 			curs(1, ROWNO + 3);
    301  1.1       cgd 			cl_eos();
    302  1.1       cgd 		}
    303  1.1       cgd 	}
    304  1.1       cgd }
    305  1.1       cgd 
    306  1.5  christos void
    307  1.5  christos curs_on_u()
    308  1.5  christos {
    309  1.5  christos 	curs(u.ux, u.uy + 2);
    310  1.1       cgd }
    311  1.1       cgd 
    312  1.5  christos void
    313  1.1       cgd pru()
    314  1.1       cgd {
    315  1.5  christos 	if (u.udispl && (Invisible || u.udisx != u.ux || u.udisy != u.uy))
    316  1.1       cgd 		/* if(! levl[u.udisx][u.udisy].new) */
    317  1.5  christos 		if (!vism_at(u.udisx, u.udisy))
    318  1.5  christos 			newsym(u.udisx, u.udisy);
    319  1.5  christos 	if (Invisible) {
    320  1.1       cgd 		u.udispl = 0;
    321  1.5  christos 		prl(u.ux, u.uy);
    322  1.5  christos 	} else if (!u.udispl || u.udisx != u.ux || u.udisy != u.uy) {
    323  1.1       cgd 		atl(u.ux, u.uy, u.usym);
    324  1.1       cgd 		u.udispl = 1;
    325  1.1       cgd 		u.udisx = u.ux;
    326  1.1       cgd 		u.udisy = u.uy;
    327  1.1       cgd 	}
    328  1.1       cgd 	levl[u.ux][u.uy].seen = 1;
    329  1.1       cgd }
    330  1.1       cgd 
    331  1.1       cgd #ifndef NOWORM
    332  1.1       cgd #include	"def.wseg.h"
    333  1.5  christos #endif	/* NOWORM */
    334  1.1       cgd 
    335  1.1       cgd /* print a position that is visible for @ */
    336  1.5  christos void
    337  1.6       jsm prl(int x, int y)
    338  1.1       cgd {
    339  1.5  christos 	struct rm      *room;
    340  1.5  christos 	struct monst   *mtmp;
    341  1.5  christos 	struct obj     *otmp;
    342  1.1       cgd 
    343  1.5  christos 	if (x == u.ux && y == u.uy && (!Invisible)) {
    344  1.1       cgd 		pru();
    345  1.1       cgd 		return;
    346  1.1       cgd 	}
    347  1.5  christos 	if (!isok(x, y))
    348  1.5  christos 		return;
    349  1.1       cgd 	room = &levl[x][y];
    350  1.5  christos 	if ((!room->typ) ||
    351  1.5  christos 	    (IS_ROCK(room->typ) && levl[u.ux][u.uy].typ == CORR))
    352  1.1       cgd 		return;
    353  1.5  christos 	if ((mtmp = m_at(x, y)) && !mtmp->mhide &&
    354  1.5  christos 	    (!mtmp->minvis || See_invisible)) {
    355  1.1       cgd #ifndef NOWORM
    356  1.5  christos 		if (m_atseg)
    357  1.1       cgd 			pwseg(m_atseg);
    358  1.1       cgd 		else
    359  1.5  christos #endif	/* NOWORM */
    360  1.5  christos 			pmon(mtmp);
    361  1.5  christos 	} else if ((otmp = o_at(x, y)) && room->typ != POOL)
    362  1.5  christos 		atl(x, y, otmp->olet);
    363  1.5  christos 	else if (mtmp && (!mtmp->minvis || See_invisible)) {
    364  1.1       cgd 		/* must be a hiding monster, but not hiding right now */
    365  1.1       cgd 		/* assume for the moment that long worms do not hide */
    366  1.1       cgd 		pmon(mtmp);
    367  1.5  christos 	} else if (g_at(x, y) && room->typ != POOL)
    368  1.5  christos 		atl(x, y, '$');
    369  1.5  christos 	else if (!room->seen || room->scrsym == ' ') {
    370  1.1       cgd 		room->new = room->seen = 1;
    371  1.5  christos 		newsym(x, y);
    372  1.5  christos 		on_scr(x, y);
    373  1.1       cgd 	}
    374  1.1       cgd 	room->seen = 1;
    375  1.1       cgd }
    376  1.1       cgd 
    377  1.1       cgd char
    378  1.5  christos news0(x, y)
    379  1.5  christos 	xchar           x, y;
    380  1.1       cgd {
    381  1.5  christos 	struct obj     *otmp;
    382  1.5  christos 	struct trap    *ttmp;
    383  1.5  christos 	struct rm      *room;
    384  1.5  christos 	char            tmp;
    385  1.1       cgd 
    386  1.1       cgd 	room = &levl[x][y];
    387  1.5  christos 	if (!room->seen)
    388  1.5  christos 		tmp = ' ';
    389  1.5  christos 	else if (room->typ == POOL)
    390  1.1       cgd 		tmp = POOL_SYM;
    391  1.5  christos 	else if (!Blind && (otmp = o_at(x, y)))
    392  1.5  christos 		tmp = otmp->olet;
    393  1.5  christos 	else if (!Blind && g_at(x, y))
    394  1.5  christos 		tmp = '$';
    395  1.5  christos 	else if (x == xupstair && y == yupstair)
    396  1.5  christos 		tmp = '<';
    397  1.5  christos 	else if (x == xdnstair && y == ydnstair)
    398  1.5  christos 		tmp = '>';
    399  1.5  christos 	else if ((ttmp = t_at(x, y)) && ttmp->tseen)
    400  1.5  christos 		tmp = '^';
    401  1.5  christos 	else
    402  1.5  christos 		switch (room->typ) {
    403  1.5  christos 		case SCORR:
    404  1.5  christos 		case SDOOR:
    405  1.5  christos 			tmp = room->scrsym;	/* %% wrong after killing
    406  1.5  christos 						 * mimic ! */
    407  1.5  christos 			break;
    408  1.5  christos 		case HWALL:
    409  1.5  christos 			tmp = '-';
    410  1.5  christos 			break;
    411  1.5  christos 		case VWALL:
    412  1.5  christos 			tmp = '|';
    413  1.5  christos 			break;
    414  1.5  christos 		case LDOOR:
    415  1.5  christos 		case DOOR:
    416  1.5  christos 			tmp = '+';
    417  1.5  christos 			break;
    418  1.5  christos 		case CORR:
    419  1.5  christos 			tmp = CORR_SYM;
    420  1.5  christos 			break;
    421  1.5  christos 		case ROOM:
    422  1.5  christos 			if (room->lit || cansee(x, y) || Blind)
    423  1.5  christos 				tmp = '.';
    424  1.5  christos 			else
    425  1.5  christos 				tmp = ' ';
    426  1.5  christos 			break;
    427  1.5  christos 			/*
    428  1.5  christos 				case POOL:
    429  1.5  christos 					tmp = POOL_SYM;
    430  1.5  christos 					break;
    431  1.5  christos 			*/
    432  1.5  christos 		default:
    433  1.5  christos 			tmp = ERRCHAR;
    434  1.5  christos 		}
    435  1.5  christos 	return (tmp);
    436  1.1       cgd }
    437  1.1       cgd 
    438  1.5  christos void
    439  1.5  christos newsym(x, y)
    440  1.5  christos 	int x, y;
    441  1.1       cgd {
    442  1.5  christos 	atl(x, y, news0(x, y));
    443  1.1       cgd }
    444  1.1       cgd 
    445  1.1       cgd /* used with wand of digging (or pick-axe): fill scrsym and force display */
    446  1.1       cgd /* also when a POOL evaporates */
    447  1.5  christos void
    448  1.5  christos mnewsym(x, y)
    449  1.5  christos 	int x, y;
    450  1.1       cgd {
    451  1.5  christos 	struct rm      *room;
    452  1.5  christos 	char            newscrsym;
    453  1.1       cgd 
    454  1.5  christos 	if (!vism_at(x, y)) {
    455  1.1       cgd 		room = &levl[x][y];
    456  1.5  christos 		newscrsym = news0(x, y);
    457  1.5  christos 		if (room->scrsym != newscrsym) {
    458  1.1       cgd 			room->scrsym = newscrsym;
    459  1.1       cgd 			room->seen = 0;
    460  1.1       cgd 		}
    461  1.1       cgd 	}
    462  1.1       cgd }
    463  1.1       cgd 
    464  1.5  christos void
    465  1.5  christos nosee(x, y)
    466  1.5  christos 	int x, y;
    467  1.1       cgd {
    468  1.5  christos 	struct rm      *room;
    469  1.1       cgd 
    470  1.5  christos 	if (!isok(x, y))
    471  1.5  christos 		return;
    472  1.1       cgd 	room = &levl[x][y];
    473  1.5  christos 	if (room->scrsym == '.' && !room->lit && !Blind) {
    474  1.1       cgd 		room->scrsym = ' ';
    475  1.1       cgd 		room->new = 1;
    476  1.5  christos 		on_scr(x, y);
    477  1.1       cgd 	}
    478  1.1       cgd }
    479  1.1       cgd 
    480  1.1       cgd #ifndef QUEST
    481  1.5  christos void
    482  1.5  christos prl1(x, y)
    483  1.5  christos 	int x, y;
    484  1.5  christos {
    485  1.5  christos 	if (u.dx) {
    486  1.5  christos 		if (u.dy) {
    487  1.5  christos 			prl(x - (2 * u.dx), y);
    488  1.5  christos 			prl(x - u.dx, y);
    489  1.5  christos 			prl(x, y);
    490  1.5  christos 			prl(x, y - u.dy);
    491  1.5  christos 			prl(x, y - (2 * u.dy));
    492  1.1       cgd 		} else {
    493  1.5  christos 			prl(x, y - 1);
    494  1.5  christos 			prl(x, y);
    495  1.5  christos 			prl(x, y + 1);
    496  1.1       cgd 		}
    497  1.1       cgd 	} else {
    498  1.5  christos 		prl(x - 1, y);
    499  1.5  christos 		prl(x, y);
    500  1.5  christos 		prl(x + 1, y);
    501  1.1       cgd 	}
    502  1.1       cgd }
    503  1.1       cgd 
    504  1.5  christos void
    505  1.5  christos nose1(x, y)
    506  1.5  christos 	int x, y;
    507  1.5  christos {
    508  1.5  christos 	if (u.dx) {
    509  1.5  christos 		if (u.dy) {
    510  1.5  christos 			nosee(x, u.uy);
    511  1.5  christos 			nosee(x, u.uy - u.dy);
    512  1.5  christos 			nosee(x, y);
    513  1.5  christos 			nosee(u.ux - u.dx, y);
    514  1.5  christos 			nosee(u.ux, y);
    515  1.1       cgd 		} else {
    516  1.5  christos 			nosee(x, y - 1);
    517  1.5  christos 			nosee(x, y);
    518  1.5  christos 			nosee(x, y + 1);
    519  1.1       cgd 		}
    520  1.1       cgd 	} else {
    521  1.5  christos 		nosee(x - 1, y);
    522  1.5  christos 		nosee(x, y);
    523  1.5  christos 		nosee(x + 1, y);
    524  1.1       cgd 	}
    525  1.1       cgd }
    526  1.5  christos #endif	/* QUEST */
    527  1.1       cgd 
    528  1.5  christos int
    529  1.5  christos vism_at(x, y)
    530  1.5  christos 	int x, y;
    531  1.1       cgd {
    532  1.5  christos 	struct monst   *mtmp;
    533  1.1       cgd 
    534  1.5  christos 	return ((x == u.ux && y == u.uy && !Invisible)
    535  1.5  christos 		? 1 :
    536  1.5  christos 		(mtmp = m_at(x, y))
    537  1.5  christos 		? ((Blind && Telepat) || canseemon(mtmp)) :
    538  1.1       cgd 		0);
    539  1.1       cgd }
    540  1.1       cgd 
    541  1.1       cgd #ifdef NEWSCR
    542  1.5  christos void
    543  1.5  christos pobj(obj)
    544  1.5  christos 	struct obj     *obj;
    545  1.5  christos {
    546  1.5  christos 	int             show = (!obj->oinvis || See_invisible) &&
    547  1.5  christos 	cansee(obj->ox, obj->oy);
    548  1.5  christos 	if (obj->odispl) {
    549  1.5  christos 		if (obj->odx != obj->ox || obj->ody != obj->oy || !show)
    550  1.5  christos 			if (!vism_at(obj->odx, obj->ody)) {
    551  1.5  christos 				newsym(obj->odx, obj->ody);
    552  1.5  christos 				obj->odispl = 0;
    553  1.5  christos 			}
    554  1.1       cgd 	}
    555  1.5  christos 	if (show && !vism_at(obj->ox, obj->oy)) {
    556  1.5  christos 		atl(obj->ox, obj->oy, obj->olet);
    557  1.1       cgd 		obj->odispl = 1;
    558  1.1       cgd 		obj->odx = obj->ox;
    559  1.1       cgd 		obj->ody = obj->oy;
    560  1.1       cgd 	}
    561  1.1       cgd }
    562  1.5  christos #endif	/* NEWSCR */
    563  1.1       cgd 
    564  1.5  christos void
    565  1.5  christos unpobj(obj)
    566  1.5  christos 	struct obj     *obj;
    567  1.5  christos {
    568  1.5  christos 	/*
    569  1.5  christos 	 * if(obj->odispl){ if(!vism_at(obj->odx, obj->ody)) newsym(obj->odx,
    570  1.5  christos 	 * obj->ody); obj->odispl = 0; }
    571  1.5  christos 	 */
    572  1.5  christos 	if (!vism_at(obj->ox, obj->oy))
    573  1.5  christos 		newsym(obj->ox, obj->oy);
    574  1.5  christos }
    575  1.5  christos 
    576  1.5  christos void
    577  1.5  christos seeobjs()
    578  1.5  christos {
    579  1.5  christos 	struct obj     *obj, *obj2;
    580  1.5  christos 	for (obj = fobj; obj; obj = obj2) {
    581  1.1       cgd 		obj2 = obj->nobj;
    582  1.5  christos 		if (obj->olet == FOOD_SYM && obj->otyp >= CORPSE
    583  1.5  christos 		    && obj->age + 250 < moves)
    584  1.5  christos 			delobj(obj);
    585  1.1       cgd 	}
    586  1.5  christos 	for (obj = invent; obj; obj = obj2) {
    587  1.1       cgd 		obj2 = obj->nobj;
    588  1.5  christos 		if (obj->olet == FOOD_SYM && obj->otyp >= CORPSE
    589  1.5  christos 		    && obj->age + 250 < moves)
    590  1.5  christos 			useup(obj);
    591  1.1       cgd 	}
    592  1.1       cgd }
    593  1.1       cgd 
    594  1.5  christos void
    595  1.5  christos seemons()
    596  1.5  christos {
    597  1.5  christos 	struct monst   *mtmp;
    598  1.5  christos 	for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
    599  1.5  christos 		if (mtmp->data->mlet == ';')
    600  1.1       cgd 			mtmp->minvis = (u.ustuck != mtmp &&
    601  1.5  christos 				      levl[mtmp->mx][mtmp->my].typ == POOL);
    602  1.1       cgd 		pmon(mtmp);
    603  1.1       cgd #ifndef NOWORM
    604  1.5  christos 		if (mtmp->wormno)
    605  1.5  christos 			wormsee(mtmp->wormno);
    606  1.5  christos #endif	/* NOWORM */
    607  1.1       cgd 	}
    608  1.1       cgd }
    609  1.1       cgd 
    610  1.5  christos void
    611  1.5  christos pmon(mon)
    612  1.5  christos 	struct monst   *mon;
    613  1.5  christos {
    614  1.5  christos 	int             show = (Blind && Telepat) || canseemon(mon);
    615  1.5  christos 	if (mon->mdispl) {
    616  1.5  christos 		if (mon->mdx != mon->mx || mon->mdy != mon->my || !show)
    617  1.1       cgd 			unpmon(mon);
    618  1.1       cgd 	}
    619  1.5  christos 	if (show && !mon->mdispl) {
    620  1.5  christos 		atl(mon->mx, mon->my,
    621  1.5  christos 		    (!mon->mappearance
    622  1.5  christos 		|| u.uprops[PROP(RIN_PROTECTION_FROM_SHAPE_CHANGERS)].p_flgs
    623  1.5  christos 		     ) ? mon->data->mlet : mon->mappearance);
    624  1.1       cgd 		mon->mdispl = 1;
    625  1.1       cgd 		mon->mdx = mon->mx;
    626  1.1       cgd 		mon->mdy = mon->my;
    627  1.1       cgd 	}
    628  1.1       cgd }
    629  1.1       cgd 
    630  1.5  christos void
    631  1.5  christos unpmon(mon)
    632  1.5  christos 	struct monst   *mon;
    633  1.5  christos {
    634  1.5  christos 	if (mon->mdispl) {
    635  1.1       cgd 		newsym(mon->mdx, mon->mdy);
    636  1.1       cgd 		mon->mdispl = 0;
    637  1.1       cgd 	}
    638  1.1       cgd }
    639  1.1       cgd 
    640  1.5  christos void
    641  1.1       cgd nscr()
    642  1.1       cgd {
    643  1.5  christos 	int x, y;
    644  1.5  christos 	struct rm      *room;
    645  1.1       cgd 
    646  1.5  christos 	if (u.uswallow || u.ux == FAR || flags.nscrinh)
    647  1.5  christos 		return;
    648  1.1       cgd 	pru();
    649  1.5  christos 	for (y = scrly; y <= scrhy; y++)
    650  1.5  christos 		for (x = scrlx; x <= scrhx; x++)
    651  1.5  christos 			if ((room = &levl[x][y])->new) {
    652  1.1       cgd 				room->new = 0;
    653  1.5  christos 				at(x, y, room->scrsym);
    654  1.1       cgd 			}
    655  1.1       cgd 	scrhx = scrhy = 0;
    656  1.1       cgd 	scrlx = COLNO;
    657  1.1       cgd 	scrly = ROWNO;
    658  1.1       cgd }
    659  1.1       cgd 
    660  1.1       cgd /* 100 suffices for bot(); no relation with COLNO */
    661  1.5  christos char            oldbot[100], newbot[100];
    662  1.5  christos void
    663  1.1       cgd cornbot(lth)
    664  1.5  christos 	int             lth;
    665  1.1       cgd {
    666  1.5  christos 	if (lth < sizeof(oldbot)) {
    667  1.1       cgd 		oldbot[lth] = 0;
    668  1.1       cgd 		flags.botl = 1;
    669  1.1       cgd 	}
    670  1.1       cgd }
    671  1.1       cgd 
    672  1.5  christos void
    673  1.1       cgd bot()
    674  1.1       cgd {
    675  1.5  christos 	char           *ob = oldbot, *nb = newbot;
    676  1.5  christos 	int             i;
    677  1.5  christos 	if (flags.botlx)
    678  1.5  christos 		*ob = 0;
    679  1.1       cgd 	flags.botl = flags.botlx = 0;
    680  1.1       cgd #ifdef GOLD_ON_BOTL
    681  1.1       cgd 	(void) sprintf(newbot,
    682  1.5  christos 		       "Level %-2d  Gold %-5lu  Hp %3d(%d)  Ac %-2d  Str ",
    683  1.5  christos 		       dlevel, u.ugold, u.uhp, u.uhpmax, u.uac);
    684  1.1       cgd #else
    685  1.1       cgd 	(void) sprintf(newbot,
    686  1.5  christos 		       "Level %-2d   Hp %3d(%d)   Ac %-2d   Str ",
    687  1.5  christos 		       dlevel, u.uhp, u.uhpmax, u.uac);
    688  1.5  christos #endif	/* GOLD_ON_BOTL */
    689  1.5  christos 	if (u.ustr > 18) {
    690  1.5  christos 		if (u.ustr > 117)
    691  1.5  christos 			(void) strcat(newbot, "18/**");
    692  1.5  christos 		else
    693  1.5  christos 			(void) sprintf(eos(newbot), "18/%02d", u.ustr - 18);
    694  1.1       cgd 	} else
    695  1.5  christos 		(void) sprintf(eos(newbot), "%-2d   ", u.ustr);
    696  1.1       cgd #ifdef EXP_ON_BOTL
    697  1.5  christos 	(void) sprintf(eos(newbot), "  Exp %2d/%-5lu ", u.ulevel, u.uexp);
    698  1.1       cgd #else
    699  1.1       cgd 	(void) sprintf(eos(newbot), "   Exp %2u  ", u.ulevel);
    700  1.5  christos #endif	/* EXP_ON_BOTL */
    701  1.1       cgd 	(void) strcat(newbot, hu_stat[u.uhs]);
    702  1.5  christos 	if (flags.time)
    703  1.5  christos 		(void) sprintf(eos(newbot), "  %ld", moves);
    704  1.5  christos 	if (strlen(newbot) >= COLNO) {
    705  1.5  christos 		char           *bp0, *bp1;
    706  1.1       cgd 		bp0 = bp1 = newbot;
    707  1.1       cgd 		do {
    708  1.5  christos 			if (*bp0 != ' ' || bp0[1] != ' ' || bp0[2] != ' ')
    709  1.1       cgd 				*bp1++ = *bp0;
    710  1.5  christos 		} while (*bp0++);
    711  1.1       cgd 	}
    712  1.5  christos 	for (i = 1; i < COLNO; i++) {
    713  1.5  christos 		if (*ob != *nb) {
    714  1.5  christos 			curs(i, ROWNO + 2);
    715  1.1       cgd 			(void) putchar(*nb ? *nb : ' ');
    716  1.1       cgd 			curx++;
    717  1.1       cgd 		}
    718  1.5  christos 		if (*ob)
    719  1.5  christos 			ob++;
    720  1.5  christos 		if (*nb)
    721  1.5  christos 			nb++;
    722  1.1       cgd 	}
    723  1.1       cgd 	(void) strcpy(oldbot, newbot);
    724  1.1       cgd }
    725  1.1       cgd 
    726  1.1       cgd #ifdef WAN_PROBING
    727  1.5  christos void
    728  1.5  christos mstatusline(mtmp)
    729  1.5  christos 	struct monst   *mtmp;
    730  1.5  christos {
    731  1.1       cgd 	pline("Status of %s: ", monnam(mtmp));
    732  1.1       cgd 	pline("Level %-2d  Gold %-5lu  Hp %3d(%d)  Ac %-2d  Dam %d",
    733  1.5  christos 	      mtmp->data->mlevel, mtmp->mgold, mtmp->mhp, mtmp->mhpmax,
    734  1.5  christos 	   mtmp->data->ac, (mtmp->data->damn + 1) * (mtmp->data->damd + 1));
    735  1.1       cgd }
    736  1.5  christos #endif	/* WAN_PROBING */
    737  1.1       cgd 
    738  1.5  christos void
    739  1.5  christos cls()
    740  1.5  christos {
    741  1.5  christos 	if (flags.toplin == 1)
    742  1.1       cgd 		more();
    743  1.1       cgd 	flags.toplin = 0;
    744  1.1       cgd 
    745  1.1       cgd 	clear_screen();
    746  1.1       cgd 
    747  1.1       cgd 	flags.botlx = 1;
    748  1.1       cgd }
    749