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