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