hack.pri.c 16 KB

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