1 /* $NetBSD: hack.pri.c,v 1.5 1997/10/19 16:58:50 christos Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.pri.c,v 1.5 1997/10/19 16:58:50 christos Exp $");
14 xchar scrlx
, scrhx
, scrly
, scrhy
; /* corners of new area on
24 curs(u
.ux
- 1, u
.uy
+ 1);
25 fputs("/-\\", stdout
);
27 curs(u
.ux
- 1, u
.uy
+ 2);
30 curs(u
.ux
- 1, u
.uy
+ 3);
31 fputs("\\-/", stdout
);
44 panic(const char *fmt
, ...)
54 fmt
= va_arg(ap
, const char *);
59 exit(1); /* avoid loops - this should never happen */
61 puts(" Suddenly, the dungeon collapses.");
62 fputs(" ERROR: ", stdout
);
68 abort(); /* generate core dump */
71 more(); /* contains a fflush() */
79 struct rm
*crm
= &levl
[x
][y
];
81 if (x
< 0 || x
> COLNO
- 1 || y
< 0 || y
> ROWNO
- 1) {
82 impossible("atl(%d,%d,%c)", x
, y
, ch
);
85 if (crm
->seen
&& crm
->scrsym
== ch
)
107 * call: (x,y) - display (-1,0) - close (leave last symbol) (-1,-1)- close
108 * (undo last symbol) (-1,let)-open: initialize symbol (-2,let)-change let
115 static schar prevx
, prevy
;
117 if ((int) x
== -2) { /* change let call */
121 if ((int) x
== -1 && (int) y
>= 0) { /* open or close call */
126 if (prevx
>= 0 && cansee(prevx
, prevy
)) {
128 prl(prevx
, prevy
); /* in case there was a monster */
129 at(prevx
, prevy
, levl
[prevx
][prevy
].scrsym
);
131 if (x
>= 0) { /* normal call */
136 } else { /* close call */
142 /* like the previous, but the symbols are first erased on completion */
149 static coord tc
[COLNO
]; /* but watch reflecting beams! */
152 if (y
> 0) { /* open call */
157 /* close call (do not distinguish y==0 and y==-1) */
162 at(xx
, yy
, levl
[xx
][yy
].scrsym
);
164 cnt
= let
= 0; /* superfluous */
167 if ((int) x
== -2) { /* change let call */
179 panic("Tmp_at overflow?");
180 levl
[x
][y
].new = 0; /* prevent pline-nscr erasing --- */
187 error("Hack needs a screen of size at least %d by %d.\n",
197 /* if xchar is unsigned, lint will complain about if(x < 0) */
198 if (x
< 0 || x
> COLNO
- 1 || y
< 0 || y
> ROWNO
- 1) {
199 impossible("At gets 0%o at %d %d.", ch
, x
, y
);
204 impossible("At gets null at %d %d.", x
, y
);
217 at(u
.ux
, u
.uy
, u
.usym
);
241 * Some ridiculous code to get display of @ and monsters (almost)
245 levl
[(u
.udisx
= u
.ux
)][(u
.udisy
= u
.uy
)].scrsym
= u
.usym
;
246 levl
[u
.udisx
][u
.udisy
].seen
= 1;
251 seemons(); /* reset old positions */
252 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
254 seemons(); /* force new positions to be shown */
256 * This nonsense should disappear soon
257 * ---------------------------------
260 for (y
= 0; y
< ROWNO
; y
++)
261 for (x
= 0; x
< COLNO
; x
++)
262 if ((room
= &levl
[x
][y
])->new) {
264 at(x
, y
, room
->scrsym
);
265 } else if (room
->seen
)
266 at(x
, y
, room
->scrsym
);
282 if (u
.uswallow
) { /* Can be done more efficiently */
286 seemons(); /* reset old positions */
287 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
288 if (mtmp
->mx
>= xmin
&& mtmp
->my
< ymax
)
290 seemons(); /* force new positions to be shown */
292 for (y
= 0; y
< ymax
; y
++) {
298 for (x
= xmin
; x
< COLNO
; x
++) {
299 if ((room
= &levl
[x
][y
])->new) {
301 at(x
, y
, room
->scrsym
);
302 } else if (room
->seen
)
303 at(x
, y
, room
->scrsym
);
309 if (ymax
> ROWNO
+ 1 && CD
) {
319 curs(u
.ux
, u
.uy
+ 2);
325 if (u
.udispl
&& (Invisible
|| u
.udisx
!= u
.ux
|| u
.udisy
!= u
.uy
))
326 /* if(! levl[u.udisx][u.udisy].new) */
327 if (!vism_at(u
.udisx
, u
.udisy
))
328 newsym(u
.udisx
, u
.udisy
);
332 } else if (!u
.udispl
|| u
.udisx
!= u
.ux
|| u
.udisy
!= u
.uy
) {
333 atl(u
.ux
, u
.uy
, u
.usym
);
338 levl
[u
.ux
][u
.uy
].seen
= 1;
342 #include "def.wseg.h"
345 /* print a position that is visible for @ */
353 if (x
== u
.ux
&& y
== u
.uy
&& (!Invisible
)) {
361 (IS_ROCK(room
->typ
) && levl
[u
.ux
][u
.uy
].typ
== CORR
))
363 if ((mtmp
= m_at(x
, y
)) && !mtmp
->mhide
&&
364 (!mtmp
->minvis
|| See_invisible
)) {
371 } else if ((otmp
= o_at(x
, y
)) && room
->typ
!= POOL
)
372 atl(x
, y
, otmp
->olet
);
373 else if (mtmp
&& (!mtmp
->minvis
|| See_invisible
)) {
374 /* must be a hiding monster, but not hiding right now */
375 /* assume for the moment that long worms do not hide */
377 } else if (g_at(x
, y
) && room
->typ
!= POOL
)
379 else if (!room
->seen
|| room
->scrsym
== ' ') {
380 room
->new = room
->seen
= 1;
399 else if (room
->typ
== POOL
)
401 else if (!Blind
&& (otmp
= o_at(x
, y
)))
403 else if (!Blind
&& g_at(x
, y
))
405 else if (x
== xupstair
&& y
== yupstair
)
407 else if (x
== xdnstair
&& y
== ydnstair
)
409 else if ((ttmp
= t_at(x
, y
)) && ttmp
->tseen
)
415 tmp
= room
->scrsym
; /* %% wrong after killing
432 if (room
->lit
|| cansee(x
, y
) || Blind
)
452 atl(x
, y
, news0(x
, y
));
455 /* used with wand of digging (or pick-axe): fill scrsym and force display */
456 /* also when a POOL evaporates */
464 if (!vism_at(x
, y
)) {
466 newscrsym
= news0(x
, y
);
467 if (room
->scrsym
!= newscrsym
) {
468 room
->scrsym
= newscrsym
;
483 if (room
->scrsym
== '.' && !room
->lit
&& !Blind
) {
497 prl(x
- (2 * u
.dx
), y
);
501 prl(x
, y
- (2 * u
.dy
));
521 nosee(x
, u
.uy
- u
.dy
);
523 nosee(u
.ux
- u
.dx
, y
);
544 return ((x
== u
.ux
&& y
== u
.uy
&& !Invisible
)
547 ? ((Blind
&& Telepat
) || canseemon(mtmp
)) :
556 int show
= (!obj
->oinvis
|| See_invisible
) &&
557 cansee(obj
->ox
, obj
->oy
);
559 if (obj
->odx
!= obj
->ox
|| obj
->ody
!= obj
->oy
|| !show
)
560 if (!vism_at(obj
->odx
, obj
->ody
)) {
561 newsym(obj
->odx
, obj
->ody
);
565 if (show
&& !vism_at(obj
->ox
, obj
->oy
)) {
566 atl(obj
->ox
, obj
->oy
, obj
->olet
);
579 * if(obj->odispl){ if(!vism_at(obj->odx, obj->ody)) newsym(obj->odx,
580 * obj->ody); obj->odispl = 0; }
582 if (!vism_at(obj
->ox
, obj
->oy
))
583 newsym(obj
->ox
, obj
->oy
);
589 struct obj
*obj
, *obj2
;
590 for (obj
= fobj
; obj
; obj
= obj2
) {
592 if (obj
->olet
== FOOD_SYM
&& obj
->otyp
>= CORPSE
593 && obj
->age
+ 250 < moves
)
596 for (obj
= invent
; obj
; obj
= obj2
) {
598 if (obj
->olet
== FOOD_SYM
&& obj
->otyp
>= CORPSE
599 && obj
->age
+ 250 < moves
)
608 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
) {
609 if (mtmp
->data
->mlet
== ';')
610 mtmp
->minvis
= (u
.ustuck
!= mtmp
&&
611 levl
[mtmp
->mx
][mtmp
->my
].typ
== POOL
);
615 wormsee(mtmp
->wormno
);
624 int show
= (Blind
&& Telepat
) || canseemon(mon
);
626 if (mon
->mdx
!= mon
->mx
|| mon
->mdy
!= mon
->my
|| !show
)
629 if (show
&& !mon
->mdispl
) {
630 atl(mon
->mx
, mon
->my
,
632 || u
.uprops
[PROP(RIN_PROTECTION_FROM_SHAPE_CHANGERS
)].p_flgs
633 ) ? mon
->data
->mlet
: mon
->mappearance
);
645 newsym(mon
->mdx
, mon
->mdy
);
656 if (u
.uswallow
|| u
.ux
== FAR
|| flags
.nscrinh
)
659 for (y
= scrly
; y
<= scrhy
; y
++)
660 for (x
= scrlx
; x
<= scrhx
; x
++)
661 if ((room
= &levl
[x
][y
])->new) {
663 at(x
, y
, room
->scrsym
);
670 /* 100 suffices for bot(); no relation with COLNO */
671 char oldbot
[100], newbot
[100];
676 if (lth
< sizeof(oldbot
)) {
685 char *ob
= oldbot
, *nb
= newbot
;
689 flags
.botl
= flags
.botlx
= 0;
691 (void) sprintf(newbot
,
692 "Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Str ",
693 dlevel
, u
.ugold
, u
.uhp
, u
.uhpmax
, u
.uac
);
695 (void) sprintf(newbot
,
696 "Level %-2d Hp %3d(%d) Ac %-2d Str ",
697 dlevel
, u
.uhp
, u
.uhpmax
, u
.uac
);
698 #endif /* GOLD_ON_BOTL */
701 (void) strcat(newbot
, "18/**");
703 (void) sprintf(eos(newbot
), "18/%02d", u
.ustr
- 18);
705 (void) sprintf(eos(newbot
), "%-2d ", u
.ustr
);
707 (void) sprintf(eos(newbot
), " Exp %2d/%-5lu ", u
.ulevel
, u
.uexp
);
709 (void) sprintf(eos(newbot
), " Exp %2u ", u
.ulevel
);
710 #endif /* EXP_ON_BOTL */
711 (void) strcat(newbot
, hu_stat
[u
.uhs
]);
713 (void) sprintf(eos(newbot
), " %ld", moves
);
714 if (strlen(newbot
) >= COLNO
) {
718 if (*bp0
!= ' ' || bp0
[1] != ' ' || bp0
[2] != ' ')
722 for (i
= 1; i
< COLNO
; i
++) {
725 (void) putchar(*nb
? *nb
: ' ');
733 (void) strcpy(oldbot
, newbot
);
741 pline("Status of %s: ", monnam(mtmp
));
742 pline("Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Dam %d",
743 mtmp
->data
->mlevel
, mtmp
->mgold
, mtmp
->mhp
, mtmp
->mhpmax
,
744 mtmp
->data
->ac
, (mtmp
->data
->damn
+ 1) * (mtmp
->data
->damd
+ 1));
746 #endif /* WAN_PROBING */
751 if (flags
.toplin
== 1)