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