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.2 2003/06/17 04:25:24 dillon Exp $ */
8 xchar scrlx, scrhx, scrly, scrhy; /* corners of new area on screen */
10 extern char *hu_stat[]; /* in eat.c */
20 fputs("/-\\", stdout);
26 fputs("\\-/", stdout);
37 panic(str,a1,a2,a3,a4,a5,a6)
40 if(panicking++) exit(1); /* avoid loops - this should never happen*/
42 puts(" Suddenly, the dungeon collapses.");
43 fputs(" ERROR: ", stdout);
44 printf(str,a1,a2,a3,a4,a5,a6);
48 abort(); /* generate core dump */
51 more(); /* contains a fflush() */
58 struct rm *crm = &levl[x][y];
60 if(x<0 || x>COLNO-1 || y<0 || y>ROWNO-1){
61 impossible("atl(%d,%d,%c)",x,y,ch);
64 if(crm->seen && crm->scrsym == ch) return;
73 if(x < scrlx) scrlx = x;
74 if(x > scrhx) scrhx = x;
75 if(y < scrly) scrly = y;
76 if(y > scrhy) scrhy = y;
79 /* call: (x,y) - display
80 (-1,0) - close (leave last symbol)
81 (-1,-1)- close (undo last symbol)
82 (-1,let)-open: initialize symbol
86 tmp_at(x,y) schar x,y; {
87 static schar prevx, prevy;
89 if((int)x == -2){ /* change let call */
93 if((int)x == -1 && (int)y >= 0){ /* open or close call */
98 if(prevx >= 0 && cansee(prevx,prevy)) {
100 prl(prevx, prevy); /* in case there was a monster */
101 at(prevx, prevy, levl[prevx][prevy].scrsym);
103 if(x >= 0){ /* normal call */
104 if(cansee(x,y)) at(x,y,let);
107 } else { /* close call */
113 /* like the previous, but the symbols are first erased on completion */
114 Tmp_at(x,y) schar x,y; {
117 static coord tc[COLNO]; /* but watch reflecting beams! */
120 if(y > 0) { /* open call */
125 /* close call (do not distinguish y==0 and y==-1) */
130 at(xx, yy, levl[xx][yy].scrsym);
132 cnt = let = 0; /* superfluous */
135 if((int)x == -2) { /* change let call */
141 if(cnt) delay_output(50);
145 if(++cnt >= COLNO) panic("Tmp_at overflow?");
146 levl[x][y].new = 0; /* prevent pline-nscr erasing --- */
151 error("Hack needs a screen of size at least %d by %d.\n",
160 /* if xchar is unsigned, lint will complain about if(x < 0) */
161 if(x < 0 || x > COLNO-1 || y < 0 || y > ROWNO-1) {
162 impossible("At gets 0%o at %d %d.", ch, x, y);
167 impossible("At gets null at %d %d.", x, y);
177 if(!Invisible) at(u.ux,u.uy,u.usym);
198 /* Some ridiculous code to get display of @ and monsters (almost) right */
200 levl[(u.udisx = u.ux)][(u.udisy = u.uy)].scrsym = u.usym;
201 levl[u.udisx][u.udisy].seen = 1;
205 seemons(); /* reset old positions */
206 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
208 seemons(); /* force new positions to be shown */
209 /* This nonsense should disappear soon --------------------------------- */
211 for(y = 0; y < ROWNO; y++)
212 for(x = 0; x < COLNO; x++)
213 if((room = &levl[x][y])->new) {
215 at(x,y,room->scrsym);
216 } else if(room->seen)
217 at(x,y,room->scrsym);
225 docorner(xmin,ymax) int xmin,ymax; {
230 if(u.uswallow) { /* Can be done more efficiently */
235 seemons(); /* reset old positions */
236 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
237 if(mtmp->mx >= xmin && mtmp->my < ymax)
239 seemons(); /* force new positions to be shown */
241 for(y = 0; y < ymax; y++) {
242 if(y > ROWNO && CD) break;
246 for(x = xmin; x < COLNO; x++) {
247 if((room = &levl[x][y])->new) {
249 at(x,y,room->scrsym);
252 at(x,y,room->scrsym);
258 if(ymax > ROWNO+1 && CD) {
271 if(u.udispl && (Invisible || u.udisx != u.ux || u.udisy != u.uy))
272 /* if(! levl[u.udisx][u.udisy].new) */
273 if(!vism_at(u.udisx, u.udisy))
274 newsym(u.udisx, u.udisy);
279 if(!u.udispl || u.udisx != u.ux || u.udisy != u.uy) {
280 atl(u.ux, u.uy, u.usym);
285 levl[u.ux][u.uy].seen = 1;
289 #include "def.wseg.h"
290 extern struct wseg *m_atseg;
293 /* print a position that is visible for @ */
300 if(x == u.ux && y == u.uy && (!Invisible)) {
304 if(!isok(x,y)) return;
307 (IS_ROCK(room->typ) && levl[u.ux][u.uy].typ == CORR))
309 if((mtmp = m_at(x,y)) && !mtmp->mhide &&
310 (!mtmp->minvis || See_invisible)) {
318 else if((otmp = o_at(x,y)) && room->typ != POOL)
320 else if(mtmp && (!mtmp->minvis || See_invisible)) {
321 /* must be a hiding monster, but not hiding right now */
322 /* assume for the moment that long worms do not hide */
325 else if(g_at(x,y) && room->typ != POOL)
327 else if(!room->seen || room->scrsym == ' ') {
328 room->new = room->seen = 1;
345 if(!room->seen) tmp = ' ';
346 else if(room->typ == POOL) tmp = POOL_SYM;
347 else if(!Blind && (otmp = o_at(x,y))) tmp = otmp->olet;
348 else if(!Blind && g_at(x,y)) tmp = '$';
349 else if(x == xupstair && y == yupstair) tmp = '<';
350 else if(x == xdnstair && y == ydnstair) tmp = '>';
351 else if((ttmp = t_at(x,y)) && ttmp->tseen) tmp = '^';
352 else switch(room->typ) {
355 tmp = room->scrsym; /* %% wrong after killing mimic ! */
371 if(room->lit || cansee(x,y) || Blind) tmp = '.';
391 /* used with wand of digging (or pick-axe): fill scrsym and force display */
392 /* also when a POOL evaporates */
401 newscrsym = news0(x,y);
402 if(room->scrsym != newscrsym) {
403 room->scrsym = newscrsym;
414 if(!isok(x,y)) return;
416 if(room->scrsym == '.' && !room->lit && !Blind) {
474 return((x == u.ux && y == u.uy && !Invisible)
477 ? ((Blind && Telepat) || canseemon(mtmp)) :
482 pobj(obj) struct obj *obj; {
483 int show = (!obj->oinvis || See_invisible) &&
484 cansee(obj->ox,obj->oy);
486 if(obj->odx != obj->ox || obj->ody != obj->oy || !show)
487 if(!vism_at(obj->odx,obj->ody)){
488 newsym(obj->odx, obj->ody);
492 if(show && !vism_at(obj->ox,obj->oy)){
493 atl(obj->ox,obj->oy,obj->olet);
501 unpobj(obj) struct obj *obj; {
503 if(!vism_at(obj->odx, obj->ody))
504 newsym(obj->odx, obj->ody);
508 if(!vism_at(obj->ox,obj->oy))
509 newsym(obj->ox,obj->oy);
513 struct obj *obj, *obj2;
514 for(obj = fobj; obj; obj = obj2) {
516 if(obj->olet == FOOD_SYM && obj->otyp >= CORPSE
517 && obj->age + 250 < moves)
520 for(obj = invent; obj; obj = obj2) {
522 if(obj->olet == FOOD_SYM && obj->otyp >= CORPSE
523 && obj->age + 250 < moves)
530 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon){
531 if(mtmp->data->mlet == ';')
532 mtmp->minvis = (u.ustuck != mtmp &&
533 levl[mtmp->mx][mtmp->my].typ == POOL);
536 if(mtmp->wormno) wormsee(mtmp->wormno);
541 pmon(mon) struct monst *mon; {
542 int show = (Blind && Telepat) || canseemon(mon);
544 if(mon->mdx != mon->mx || mon->mdy != mon->my || !show)
547 if(show && !mon->mdispl){
550 || u.uprops[PROP(RIN_PROTECTION_FROM_SHAPE_CHANGERS)].p_flgs
551 ) ? mon->data->mlet : mon->mappearance);
558 unpmon(mon) struct monst *mon; {
560 newsym(mon->mdx, mon->mdy);
570 if(u.uswallow || u.ux == FAR || flags.nscrinh) return;
572 for(y = scrly; y <= scrhy; y++)
573 for(x = scrlx; x <= scrhx; x++)
574 if((room = &levl[x][y])->new) {
576 at(x,y,room->scrsym);
583 /* 100 suffices for bot(); no relation with COLNO */
584 char oldbot[100], newbot[100];
588 if(lth < sizeof(oldbot)) {
596 char *ob = oldbot, *nb = newbot;
599 if(flags.botlx) *ob = 0;
600 flags.botl = flags.botlx = 0;
602 (void) sprintf(newbot,
603 "Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Str ",
604 dlevel, u.ugold, u.uhp, u.uhpmax, u.uac);
606 (void) sprintf(newbot,
607 "Level %-2d Hp %3d(%d) Ac %-2d Str ",
608 dlevel, u.uhp, u.uhpmax, u.uac);
612 (void) strcat(newbot,"18/**");
614 (void) sprintf(eos(newbot), "18/%02d",u.ustr-18);
616 (void) sprintf(eos(newbot), "%-2d ",u.ustr);
618 (void) sprintf(eos(newbot), " Exp %2d/%-5lu ", u.ulevel,u.uexp);
620 (void) sprintf(eos(newbot), " Exp %2u ", u.ulevel);
622 (void) strcat(newbot, hu_stat[u.uhs]);
624 (void) sprintf(eos(newbot), " %ld", moves);
625 if(strlen(newbot) >= COLNO) {
629 if(*bp0 != ' ' || bp0[1] != ' ' || bp0[2] != ' ')
633 for(i = 1; i<COLNO; i++) {
636 (void) putchar(*nb ? *nb : ' ');
642 (void) strcpy(oldbot, newbot);
646 mstatusline(mtmp) struct monst *mtmp; {
647 pline("Status of %s: ", monnam(mtmp));
648 pline("Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Dam %d",
649 mtmp->data->mlevel, mtmp->mgold, mtmp->mhp, mtmp->mhpmax,
650 mtmp->data->ac, (mtmp->data->damn + 1) * (mtmp->data->damd + 1));
655 if(flags.toplin == 1)