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