1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.pri.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.pri.c,v 1.5 1999/11/16 10:26:37 marcel Exp $ */
4 /* $DragonFly: src/games/hack/hack.pri.c,v 1.4 2005/05/22 03:37:05 y0netan1 Exp $ */
8 xchar scrlx, scrhx, scrly, scrhy; /* corners of new area on screen */
14 char ulook[] = {"|@|"};
19 fputs("/-\\", stdout);
25 fputs("\\-/", stdout);
36 panic(str,a1,a2,a3,a4,a5,a6)
39 if(panicking++) exit(1); /* avoid loops - this should never happen*/
41 puts(" Suddenly, the dungeon collapses.");
42 fputs(" ERROR: ", stdout);
43 printf(str,a1,a2,a3,a4,a5,a6);
47 abort(); /* generate core dump */
50 more(); /* contains a fflush() */
57 struct rm *crm = &levl[x][y];
59 if(x<0 || x>COLNO-1 || y<0 || y>ROWNO-1){
60 impossible("atl(%d,%d,%c)",x,y,ch);
63 if(crm->seen && crm->scrsym == ch) return;
72 if(x < scrlx) scrlx = x;
73 if(x > scrhx) scrhx = x;
74 if(y < scrly) scrly = y;
75 if(y > scrhy) scrhy = y;
78 /* call: (x,y) - display
79 (-1,0) - close (leave last symbol)
80 (-1,-1)- close (undo last symbol)
81 (-1,let)-open: initialize symbol
85 tmp_at(x,y) schar x,y; {
86 static schar prevx, prevy;
88 if((int)x == -2){ /* change let call */
92 if((int)x == -1 && (int)y >= 0){ /* open or close call */
97 if(prevx >= 0 && cansee(prevx,prevy)) {
99 prl(prevx, prevy); /* in case there was a monster */
100 at(prevx, prevy, levl[prevx][prevy].scrsym);
102 if(x >= 0){ /* normal call */
103 if(cansee(x,y)) at(x,y,let);
106 } else { /* close call */
112 /* like the previous, but the symbols are first erased on completion */
113 Tmp_at(x,y) schar x,y; {
116 static coord tc[COLNO]; /* but watch reflecting beams! */
119 if(y > 0) { /* open call */
124 /* close call (do not distinguish y==0 and y==-1) */
129 at(xx, yy, levl[xx][yy].scrsym);
131 cnt = let = 0; /* superfluous */
134 if((int)x == -2) { /* change let call */
140 if(cnt) delay_output(50);
144 if(++cnt >= COLNO) panic("Tmp_at overflow?");
145 levl[x][y].new = 0; /* prevent pline-nscr erasing --- */
150 error("Hack needs a screen of size at least %d by %d.\n",
159 /* if xchar is unsigned, lint will complain about if(x < 0) */
160 if(x < 0 || x > COLNO-1 || y < 0 || y > ROWNO-1) {
161 impossible("At gets 0%o at %d %d.", ch, x, y);
166 impossible("At gets null at %d %d.", x, y);
176 if(!Invisible) at(u.ux,u.uy,u.usym);
197 /* Some ridiculous code to get display of @ and monsters (almost) right */
199 levl[(u.udisx = u.ux)][(u.udisy = u.uy)].scrsym = u.usym;
200 levl[u.udisx][u.udisy].seen = 1;
204 seemons(); /* reset old positions */
205 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
207 seemons(); /* force new positions to be shown */
208 /* This nonsense should disappear soon --------------------------------- */
210 for(y = 0; y < ROWNO; y++)
211 for(x = 0; x < COLNO; x++)
212 if((room = &levl[x][y])->new) {
214 at(x,y,room->scrsym);
215 } else if(room->seen)
216 at(x,y,room->scrsym);
224 docorner(xmin,ymax) int xmin,ymax; {
229 if(u.uswallow) { /* Can be done more efficiently */
234 seemons(); /* reset old positions */
235 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
236 if(mtmp->mx >= xmin && mtmp->my < ymax)
238 seemons(); /* force new positions to be shown */
240 for(y = 0; y < ymax; y++) {
241 if(y > ROWNO && CD) break;
245 for(x = xmin; x < COLNO; x++) {
246 if((room = &levl[x][y])->new) {
248 at(x,y,room->scrsym);
251 at(x,y,room->scrsym);
257 if(ymax > ROWNO+1 && CD) {
270 if(u.udispl && (Invisible || u.udisx != u.ux || u.udisy != u.uy))
271 /* if(! levl[u.udisx][u.udisy].new) */
272 if(!vism_at(u.udisx, u.udisy))
273 newsym(u.udisx, u.udisy);
278 if(!u.udispl || u.udisx != u.ux || u.udisy != u.uy) {
279 atl(u.ux, u.uy, u.usym);
284 levl[u.ux][u.uy].seen = 1;
288 #include "def.wseg.h"
289 extern struct wseg *m_atseg;
292 /* print a position that is visible for @ */
299 if(x == u.ux && y == u.uy && (!Invisible)) {
303 if(!isok(x,y)) return;
306 (IS_ROCK(room->typ) && levl[u.ux][u.uy].typ == CORR))
308 if((mtmp = m_at(x,y)) && !mtmp->mhide &&
309 (!mtmp->minvis || See_invisible)) {
317 else if((otmp = o_at(x,y)) && room->typ != POOL)
319 else if(mtmp && (!mtmp->minvis || See_invisible)) {
320 /* must be a hiding monster, but not hiding right now */
321 /* assume for the moment that long worms do not hide */
324 else if(g_at(x,y) && room->typ != POOL)
326 else if(!room->seen || room->scrsym == ' ') {
327 room->new = room->seen = 1;
344 if(!room->seen) tmp = ' ';
345 else if(room->typ == POOL) tmp = POOL_SYM;
346 else if(!Blind && (otmp = o_at(x,y))) tmp = otmp->olet;
347 else if(!Blind && g_at(x,y)) tmp = '$';
348 else if(x == xupstair && y == yupstair) tmp = '<';
349 else if(x == xdnstair && y == ydnstair) tmp = '>';
350 else if((ttmp = t_at(x,y)) && ttmp->tseen) tmp = '^';
351 else switch(room->typ) {
354 tmp = room->scrsym; /* %% wrong after killing mimic ! */
370 if(room->lit || cansee(x,y) || Blind) tmp = '.';
390 /* used with wand of digging (or pick-axe): fill scrsym and force display */
391 /* also when a POOL evaporates */
400 newscrsym = news0(x,y);
401 if(room->scrsym != newscrsym) {
402 room->scrsym = newscrsym;
413 if(!isok(x,y)) return;
415 if(room->scrsym == '.' && !room->lit && !Blind) {
473 return((x == u.ux && y == u.uy && !Invisible)
476 ? ((Blind && Telepat) || canseemon(mtmp)) :
481 pobj(obj) struct obj *obj; {
482 int show = (!obj->oinvis || See_invisible) &&
483 cansee(obj->ox,obj->oy);
485 if(obj->odx != obj->ox || obj->ody != obj->oy || !show)
486 if(!vism_at(obj->odx,obj->ody)){
487 newsym(obj->odx, obj->ody);
491 if(show && !vism_at(obj->ox,obj->oy)){
492 atl(obj->ox,obj->oy,obj->olet);
500 unpobj(obj) struct obj *obj; {
502 if(!vism_at(obj->odx, obj->ody))
503 newsym(obj->odx, obj->ody);
507 if(!vism_at(obj->ox,obj->oy))
508 newsym(obj->ox,obj->oy);
512 struct obj *obj, *obj2;
513 for(obj = fobj; obj; obj = obj2) {
515 if(obj->olet == FOOD_SYM && obj->otyp >= CORPSE
516 && obj->age + 250 < moves)
519 for(obj = invent; obj; obj = obj2) {
521 if(obj->olet == FOOD_SYM && obj->otyp >= CORPSE
522 && obj->age + 250 < moves)
529 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon){
530 if(mtmp->data->mlet == ';')
531 mtmp->minvis = (u.ustuck != mtmp &&
532 levl[mtmp->mx][mtmp->my].typ == POOL);
535 if(mtmp->wormno) wormsee(mtmp->wormno);
540 pmon(mon) struct monst *mon; {
541 int show = (Blind && Telepat) || canseemon(mon);
543 if(mon->mdx != mon->mx || mon->mdy != mon->my || !show)
546 if(show && !mon->mdispl){
549 || u.uprops[PROP(RIN_PROTECTION_FROM_SHAPE_CHANGERS)].p_flgs
550 ) ? mon->data->mlet : mon->mappearance);
557 unpmon(mon) struct monst *mon; {
559 newsym(mon->mdx, mon->mdy);
569 if(u.uswallow || u.ux == FAR || flags.nscrinh) return;
571 for(y = scrly; y <= scrhy; y++)
572 for(x = scrlx; x <= scrhx; x++)
573 if((room = &levl[x][y])->new) {
575 at(x,y,room->scrsym);
582 /* 100 suffices for bot(); no relation with COLNO */
583 char oldbot[100], newbot[100];
587 if(lth < sizeof(oldbot)) {
595 char *ob = oldbot, *nb = newbot;
598 if(flags.botlx) *ob = 0;
599 flags.botl = flags.botlx = 0;
601 (void) sprintf(newbot,
602 "Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Str ",
603 dlevel, u.ugold, u.uhp, u.uhpmax, u.uac);
605 (void) sprintf(newbot,
606 "Level %-2d Hp %3d(%d) Ac %-2d Str ",
607 dlevel, u.uhp, u.uhpmax, u.uac);
608 #endif /* GOLD_ON_BOTL */
611 (void) strcat(newbot,"18/**");
613 (void) sprintf(eos(newbot), "18/%02d",u.ustr-18);
615 (void) sprintf(eos(newbot), "%-2d ",u.ustr);
617 (void) sprintf(eos(newbot), " Exp %2d/%-5lu ", u.ulevel,u.uexp);
619 (void) sprintf(eos(newbot), " Exp %2u ", u.ulevel);
620 #endif /* EXP_ON_BOTL */
621 (void) strcat(newbot, hu_stat[u.uhs]);
623 (void) sprintf(eos(newbot), " %ld", moves);
624 if(strlen(newbot) >= COLNO) {
628 if(*bp0 != ' ' || bp0[1] != ' ' || bp0[2] != ' ')
632 for(i = 1; i<COLNO; i++) {
635 (void) putchar(*nb ? *nb : ' ');
641 (void) strcpy(oldbot, newbot);
645 mstatusline(mtmp) struct monst *mtmp; {
646 pline("Status of %s: ", monnam(mtmp));
647 pline("Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Dam %d",
648 mtmp->data->mlevel, mtmp->mgold, mtmp->mhp, mtmp->mhpmax,
649 mtmp->data->ac, (mtmp->data->damn + 1) * (mtmp->data->damd + 1));
651 #endif /* WAN_PROBING */
654 if(flags.toplin == 1)