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