1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.pri.c - version 1.0.3 */
6 xchar scrlx, scrhx, scrly, scrhy; /* corners of new area on screen */
8 extern char *hu_stat[]; /* in eat.c */
18 fputs("/-\\", stdout);
24 fputs("\\-/", stdout);
35 panic(str,a1,a2,a3,a4,a5,a6)
38 if(panicking++) exit(1); /* avoid loops - this should never happen*/
40 puts(" Suddenly, the dungeon collapses.");
41 fputs(" ERROR: ", stdout);
42 printf(str,a1,a2,a3,a4,a5,a6);
46 abort(); /* generate core dump */
49 more(); /* contains a fflush() */
56 register struct rm *crm = &levl[x][y];
58 if(x<0 || x>COLNO-1 || y<0 || y>ROWNO-1){
59 impossible("atl(%d,%d,%c)",x,y,ch);
62 if(crm->seen && crm->scrsym == ch) return;
71 if(x < scrlx) scrlx = x;
72 if(x > scrhx) scrhx = x;
73 if(y < scrly) scrly = y;
74 if(y > scrhy) scrhy = y;
77 /* call: (x,y) - display
78 (-1,0) - close (leave last symbol)
79 (-1,-1)- close (undo last symbol)
80 (-1,let)-open: initialize symbol
84 tmp_at(x,y) schar x,y; {
85 static schar prevx, prevy;
87 if((int)x == -2){ /* change let call */
91 if((int)x == -1 && (int)y >= 0){ /* open or close call */
96 if(prevx >= 0 && cansee(prevx,prevy)) {
98 prl(prevx, prevy); /* in case there was a monster */
99 at(prevx, prevy, levl[prevx][prevy].scrsym);
101 if(x >= 0){ /* normal call */
102 if(cansee(x,y)) at(x,y,let);
105 } else { /* close call */
111 /* like the previous, but the symbols are first erased on completion */
112 Tmp_at(x,y) schar x,y; {
115 static coord tc[COLNO]; /* but watch reflecting beams! */
118 if(y > 0) { /* open call */
123 /* close call (do not distinguish y==0 and y==-1) */
128 at(xx, yy, levl[xx][yy].scrsym);
130 cnt = let = 0; /* superfluous */
133 if((int)x == -2) { /* change let call */
139 if(cnt) delay_output();
143 if(++cnt >= COLNO) panic("Tmp_at overflow?");
144 levl[x][y].new = 0; /* prevent pline-nscr erasing --- */
149 error("Hack needs a screen of size at least %d by %d.\n",
158 /* if xchar is unsigned, lint will complain about if(x < 0) */
159 if(x < 0 || x > COLNO-1 || y < 0 || y > ROWNO-1) {
160 impossible("At gets 0%o at %d %d.", ch, x, y);
165 impossible("At gets null at %d %d.", x, y);
175 if(!Invisible) at(u.ux,u.uy,u.usym);
187 register struct rm *room;
188 register struct monst *mtmp;
196 /* Some ridiculous code to get display of @ and monsters (almost) right */
198 levl[(u.udisx = u.ux)][(u.udisy = u.uy)].scrsym = u.usym;
199 levl[u.udisx][u.udisy].seen = 1;
203 seemons(); /* reset old positions */
204 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
206 seemons(); /* force new positions to be shown */
207 /* This nonsense should disappear soon --------------------------------- */
209 for(y = 0; y < ROWNO; y++)
210 for(x = 0; x < COLNO; x++)
211 if((room = &levl[x][y])->new) {
213 at(x,y,room->scrsym);
214 } else if(room->seen)
215 at(x,y,room->scrsym);
223 docorner(xmin,ymax) register xmin,ymax; {
225 register struct rm *room;
226 register struct monst *mtmp;
228 if(u.uswallow) { /* Can be done more efficiently */
233 seemons(); /* reset old positions */
234 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
235 if(mtmp->mx >= xmin && mtmp->my < ymax)
237 seemons(); /* force new positions to be shown */
239 for(y = 0; y < ymax; y++) {
240 if(y > ROWNO && CD) break;
244 for(x = xmin; x < COLNO; x++) {
245 if((room = &levl[x][y])->new) {
247 at(x,y,room->scrsym);
250 at(x,y,room->scrsym);
256 if(ymax > ROWNO+1 && CD) {
269 if(u.udispl && (Invisible || u.udisx != u.ux || u.udisy != u.uy))
270 /* if(! levl[u.udisx][u.udisy].new) */
271 if(!vism_at(u.udisx, u.udisy))
272 newsym(u.udisx, u.udisy);
277 if(!u.udispl || u.udisx != u.ux || u.udisy != u.uy) {
278 atl(u.ux, u.uy, u.usym);
283 levl[u.ux][u.uy].seen = 1;
287 #include "def.wseg.h"
288 extern struct wseg *m_atseg;
291 /* print a position that is visible for @ */
294 register struct rm *room;
295 register struct monst *mtmp;
296 register struct obj *otmp;
298 if(x == u.ux && y == u.uy && (!Invisible)) {
302 if(!isok(x,y)) return;
305 (IS_ROCK(room->typ) && levl[u.ux][u.uy].typ == CORR))
307 if((mtmp = m_at(x,y)) && !mtmp->mhide &&
308 (!mtmp->minvis || See_invisible)) {
316 else if((otmp = o_at(x,y)) && room->typ != POOL)
318 else if(mtmp && (!mtmp->minvis || See_invisible)) {
319 /* must be a hiding monster, but not hiding right now */
320 /* assume for the moment that long worms do not hide */
323 else if(g_at(x,y) && room->typ != POOL)
325 else if(!room->seen || room->scrsym == ' ') {
326 room->new = room->seen = 1;
337 register struct obj *otmp;
338 register struct trap *ttmp;
343 if(!room->seen) tmp = ' ';
344 else if(room->typ == POOL) tmp = POOL_SYM;
345 else if(!Blind && (otmp = o_at(x,y))) tmp = otmp->olet;
346 else if(!Blind && g_at(x,y)) tmp = '$';
347 else if(x == xupstair && y == yupstair) tmp = '<';
348 else if(x == xdnstair && y == ydnstair) tmp = '>';
349 else if((ttmp = t_at(x,y)) && ttmp->tseen) tmp = '^';
350 else switch(room->typ) {
353 tmp = room->scrsym; /* %% wrong after killing mimic ! */
369 if(room->lit || cansee(x,y) || Blind) tmp = '.';
389 /* used with wand of digging (or pick-axe): fill scrsym and force display */
390 /* also when a POOL evaporates */
394 register struct rm *room;
399 newscrsym = news0(x,y);
400 if(room->scrsym != newscrsym) {
401 room->scrsym = newscrsym;
410 register struct rm *room;
412 if(!isok(x,y)) return;
414 if(room->scrsym == '.' && !room->lit && !Blind) {
470 register struct monst *mtmp;
472 return((x == u.ux && y == u.uy && !Invisible)
475 ? ((Blind && Telepat) || canseemon(mtmp)) :
480 pobj(obj) register struct obj *obj; {
481 register int show = (!obj->oinvis || See_invisible) &&
482 cansee(obj->ox,obj->oy);
484 if(obj->odx != obj->ox || obj->ody != obj->oy || !show)
485 if(!vism_at(obj->odx,obj->ody)){
486 newsym(obj->odx, obj->ody);
490 if(show && !vism_at(obj->ox,obj->oy)){
491 atl(obj->ox,obj->oy,obj->olet);
499 unpobj(obj) register struct obj *obj; {
501 if(!vism_at(obj->odx, obj->ody))
502 newsym(obj->odx, obj->ody);
506 if(!vism_at(obj->ox,obj->oy))
507 newsym(obj->ox,obj->oy);
511 register struct obj *obj, *obj2;
512 for(obj = fobj; obj; obj = obj2) {
514 if(obj->olet == FOOD_SYM && obj->otyp >= CORPSE
515 && obj->age + 250 < moves)
518 for(obj = invent; obj; obj = obj2) {
520 if(obj->olet == FOOD_SYM && obj->otyp >= CORPSE
521 && obj->age + 250 < moves)
527 register struct monst *mtmp;
528 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon){
529 if(mtmp->data->mlet == ';')
530 mtmp->minvis = (u.ustuck != mtmp &&
531 levl[mtmp->mx][mtmp->my].typ == POOL);
534 if(mtmp->wormno) wormsee(mtmp->wormno);
539 pmon(mon) register struct monst *mon; {
540 register int show = (Blind && Telepat) || canseemon(mon);
542 if(mon->mdx != mon->mx || mon->mdy != mon->my || !show)
545 if(show && !mon->mdispl){
548 || u.uprops[PROP(RIN_PROTECTION_FROM_SHAPE_CHANGERS)].p_flgs
549 ) ? mon->data->mlet : mon->mappearance);
556 unpmon(mon) register struct monst *mon; {
558 newsym(mon->mdx, mon->mdy);
566 register struct rm *room;
568 if(u.uswallow || u.ux == FAR || flags.nscrinh) return;
570 for(y = scrly; y <= scrhy; y++)
571 for(x = scrlx; x <= scrhx; x++)
572 if((room = &levl[x][y])->new) {
574 at(x,y,room->scrsym);
581 /* 100 suffices for bot(); no relation with COLNO */
582 char oldbot[100], newbot[100];
586 if(lth < sizeof(oldbot)) {
594 register char *ob = oldbot, *nb = newbot;
597 if(flags.botlx) *ob = 0;
598 flags.botl = flags.botlx = 0;
600 (void) sprintf(newbot,
601 "Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Str ",
602 dlevel, u.ugold, u.uhp, u.uhpmax, u.uac);
604 (void) sprintf(newbot,
605 "Level %-2d Hp %3d(%d) Ac %-2d Str ",
606 dlevel, u.uhp, u.uhpmax, u.uac);
610 (void) strcat(newbot,"18/**");
612 (void) sprintf(eos(newbot), "18/%02d",u.ustr-18);
614 (void) sprintf(eos(newbot), "%-2d ",u.ustr);
616 (void) sprintf(eos(newbot), " Exp %2d/%-5lu ", u.ulevel,u.uexp);
618 (void) sprintf(eos(newbot), " Exp %2u ", u.ulevel);
620 (void) strcat(newbot, hu_stat[u.uhs]);
622 (void) sprintf(eos(newbot), " %ld", moves);
623 if(strlen(newbot) >= COLNO) {
624 register char *bp0, *bp1;
627 if(*bp0 != ' ' || bp0[1] != ' ' || bp0[2] != ' ')
631 for(i = 1; i<COLNO; i++) {
634 (void) putchar(*nb ? *nb : ' ');
640 (void) strcpy(oldbot, newbot);
644 mstatusline(mtmp) register struct monst *mtmp; {
645 pline("Status of %s: ", monnam(mtmp));
646 pline("Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Dam %d",
647 mtmp->data->mlevel, mtmp->mgold, mtmp->mhp, mtmp->mhpmax,
648 mtmp->data->ac, (mtmp->data->damn + 1) * (mtmp->data->damd + 1));
653 if(flags.toplin == 1)