home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume16 / nethck31 / part72 < prev    next >
Encoding:
Internet Message Format  |  1993-02-05  |  58.2 KB

  1. Path: uunet!news.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v16i080:  nethack31 - display oriented dungeons & dragons (Ver. 3.1), Part72/108
  5. Message-ID: <4443@master.CNA.TEK.COM>
  6. Date: 5 Feb 93 19:19:41 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 2201
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1631
  11.  
  12. Submitted-by: izchak@linc.cis.upenn.edu (Izchak Miller)
  13. Posting-number: Volume 16, Issue 80
  14. Archive-name: nethack31/Part72
  15. Supersedes: nethack3p9: Volume 10, Issue 46-102
  16. Environment: Amiga, Atari, Mac, MS-DOS, OS2, Unix, VMS, X11
  17.  
  18.  
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 72 (of 108)."
  27. # Contents:  dat/wizhelp src/engrave.c sys/share/lev_yacc.c2
  28. # Wrapped by billr@saab on Wed Jan 27 16:09:15 1993
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. if test -f 'dat/wizhelp' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'dat/wizhelp'\"
  32. else
  33. echo shar: Extracting \"'dat/wizhelp'\" \(312 characters\)
  34. sed "s/^X//" >'dat/wizhelp' <<'END_OF_FILE'
  35. XDebug-Mode Quick Reference:
  36. X
  37. X^E  ==  detect secret doors and traps.
  38. X^F  ==  do magic mapping.
  39. X^G  ==  create monster.
  40. X^I  ==  identify items in pack.
  41. X^O  ==  tell locations of special levels.
  42. X^T  ==  do intra-level teleport.
  43. X^V  ==  do trans-level teleport.
  44. X^W  ==  make wish.
  45. X^X  ==  show intrinsic attributes.
  46. END_OF_FILE
  47. if test 312 -ne `wc -c <'dat/wizhelp'`; then
  48.     echo shar: \"'dat/wizhelp'\" unpacked with wrong size!
  49. fi
  50. # end of 'dat/wizhelp'
  51. fi
  52. if test -f 'src/engrave.c' -a "${1}" != "-c" ; then 
  53.   echo shar: Will not clobber existing file \"'src/engrave.c'\"
  54. else
  55. echo shar: Extracting \"'src/engrave.c'\" \(23761 characters\)
  56. sed "s/^X//" >'src/engrave.c' <<'END_OF_FILE'
  57. X/*    SCCS Id: @(#)engrave.c    3.1    92/02/25    */
  58. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  59. X/* NetHack may be freely redistributed.  See license for details. */
  60. X
  61. X#include "hack.h"
  62. X#include "lev.h"
  63. X#include <ctype.h>
  64. X
  65. XSTATIC_VAR struct engr NEARDATA *head_engr;
  66. X
  67. XSTATIC_DCL void FDECL(del_engr, (struct engr *));
  68. X
  69. X#ifdef OVLB
  70. X/* random engravings */
  71. Xconst char *random_mesg[] = {
  72. X    "Elbereth", "ad ae?ar um",
  73. X    "?la? ?as he??",
  74. X    /* take-offs and other famous engravings */
  75. X    "Owlbreath", "?ala??iel",
  76. X    "?ilroy wa? h?re",
  77. X    "A.S. ->", "<- A.S.", /* Journey to the Center of the Earth */
  78. X    "Y?u won t get i? up ?he ste?s", /* Adventure */
  79. X    "Lasc?ate o?ni sp?ranz? o vo? c?'en?rate", /* Inferno */
  80. X    "Well Come", /* Prisoner */
  81. X    "W? ap?l???ze for t?e inc?nve??e?ce", /* So Long... */
  82. X    "S?e you n?xt Wed?esd?y", /* Thriller */
  83. X    "Fo? a ?ood time c?ll 8?7-53?9",
  84. X};
  85. X
  86. Xconst char *
  87. Xrandom_engraving()
  88. X{
  89. X    char *rumor, *s;
  90. X
  91. X/* a random engraving may come from the "rumors" file, or from the
  92. X   list above */
  93. X    rumor = getrumor(0);
  94. X    if (rn2(4) && *rumor) {
  95. X        for (s = rumor; *s; s++)
  96. X            if (!rn2(7) && *s != ' ') *s = '?';
  97. X        if (s[-1] == '.') s[-1] = 0;
  98. X        return (const char *)rumor;
  99. X    }
  100. X    else
  101. X        return random_mesg[rn2(SIZE(random_mesg))];
  102. X}
  103. X#endif /* OVLB */
  104. X#ifdef OVL0
  105. X
  106. Xstruct engr *
  107. Xengr_at(x,y) register xchar x,y; {
  108. Xregister struct engr *ep = head_engr;
  109. X    while(ep) {
  110. X        if(x == ep->engr_x && y == ep->engr_y)
  111. X            return(ep);
  112. X        ep = ep->nxt_engr;
  113. X    }
  114. X    return((struct engr *) 0);
  115. X}
  116. X
  117. X#ifdef ELBERETH
  118. Xint
  119. Xsengr_at(s,x,y)
  120. X    register const char *s;
  121. X    register xchar x,y;
  122. X{
  123. X    register struct engr *ep = engr_at(x,y);
  124. X    register char *t;
  125. X    register int n;
  126. X
  127. X    if(ep && ep->engr_time <= moves) {
  128. X        t = ep->engr_txt;
  129. X/*
  130. X        if(!strcmp(s,t)) return(1);
  131. X*/
  132. X        n = strlen(s);
  133. X        while(*t) {
  134. X            if(!strncmp(s,t,n)) return(1);
  135. X            t++;
  136. X        }
  137. X    }
  138. X    return(0);
  139. X}
  140. X#endif
  141. X
  142. X#endif /* OVL0 */
  143. X#ifdef OVL2
  144. X
  145. Xvoid
  146. Xu_wipe_engr(cnt)
  147. Xregister int cnt;
  148. X{
  149. X    if(!u.uswallow && !Levitation)
  150. X        wipe_engr_at(u.ux, u.uy, cnt);
  151. X}
  152. X
  153. X#endif /* OVL2 */
  154. X#ifdef OVL1
  155. X
  156. Xvoid
  157. Xwipe_engr_at(x,y,cnt) register xchar x,y,cnt; {
  158. Xregister struct engr *ep = engr_at(x,y);
  159. Xregister int lth,pos;
  160. Xchar ch;
  161. X    if(ep){
  162. X        if(ep->engr_type != BURN) {
  163. X        if(ep->engr_type != DUST && ep->engr_type != BLOOD) {
  164. X            cnt = rn2(1 + 50/(cnt+1)) ? 0 : 1;
  165. X        }
  166. X        lth = strlen(ep->engr_txt);
  167. X        if(lth && cnt > 0 ) {
  168. X            while(cnt--) {
  169. X                pos = rn2(lth);
  170. X                if((ch = ep->engr_txt[pos]) == ' ')
  171. X                    continue;
  172. X                ep->engr_txt[pos] = (ch != '?') ? '?' : ' ';
  173. X            }
  174. X        }
  175. X        while(lth && ep->engr_txt[lth-1] == ' ')
  176. X            ep->engr_txt[--lth] = 0;
  177. X        while(ep->engr_txt[0] == ' ')
  178. X            ep->engr_txt++;
  179. X        if(!ep->engr_txt[0]) del_engr(ep);
  180. X        }
  181. X    }
  182. X}
  183. X
  184. X#endif /* OVL1 */
  185. X#ifdef OVL2
  186. X
  187. Xvoid
  188. Xread_engr_at(x,y)
  189. Xregister int x,y;
  190. X{
  191. X    register struct engr *ep = engr_at(x,y);
  192. X    register int    sensed = 0;
  193. X
  194. X    if(ep && ep->engr_txt[0]) {
  195. X        switch(ep->engr_type) {
  196. X        case DUST:
  197. X        if(!Blind) {
  198. X            sensed = 1;
  199. X            pline("Something is written here in the dust.");
  200. X        }
  201. X        break;
  202. X        case ENGRAVE:
  203. X        if(!Blind || !Levitation) {
  204. X            sensed = 1;
  205. X            pline("Something is engraved here on the floor.");
  206. X        }
  207. X        break;
  208. X        case BURN:
  209. X        if(!Blind || !Levitation) {
  210. X            sensed = 1;
  211. X            pline("Some text has been burned into the floor here.");
  212. X        }
  213. X        break;
  214. X        case MARK:
  215. X        if(!Blind) {
  216. X            sensed = 1;
  217. X            pline("There's some graffiti on the floor here.");
  218. X        }
  219. X        break;
  220. X        case BLOOD:
  221. X        /* "It's a message!  Scrawled in blood!"
  222. X         * "What's it say?"
  223. X         * "It says... `See you next Wednesday.'" -- Thriller
  224. X         */
  225. X        if(!Blind) {
  226. X            sensed = 1;
  227. X            You("see a message scrawled in blood here.");
  228. X        }
  229. X        break;
  230. X        default:
  231. X        impossible("Something is written in a very strange way.");
  232. X        sensed = 1;
  233. X        }
  234. X        if (sensed) {
  235. X        You("%s: \"%s\".",
  236. X              (Blind) ? "feel the words" : "read",  ep->engr_txt);
  237. X        if(flags.run > 1) nomul(0);
  238. X        }
  239. X    }
  240. X}
  241. X
  242. X#endif /* OVL2 */
  243. X#ifdef OVLB
  244. X
  245. Xvoid
  246. Xmake_engr_at(x,y,s,e_time,e_type)
  247. Xregister int x,y;
  248. Xregister const char *s;
  249. Xregister long e_time;
  250. Xregister xchar e_type;
  251. X{
  252. X    register struct engr *ep;
  253. X
  254. X    if(ep = engr_at(x,y))
  255. X        del_engr(ep);
  256. X    ep = newengr(strlen(s) + 1);
  257. X    ep->nxt_engr = head_engr;
  258. X    head_engr = ep;
  259. X    ep->engr_x = x;
  260. X    ep->engr_y = y;
  261. X    ep->engr_txt = (char *)(ep + 1);
  262. X    Strcpy(ep->engr_txt, s);
  263. X    if(strcmp(s, "Elbereth")) exercise(A_WIS, TRUE);
  264. X    ep->engr_time = e_time;
  265. X    ep->engr_type = e_type > 0 ? e_type : rnd(N_ENGRAVE);
  266. X    ep->engr_lth = strlen(s) + 1;
  267. X}
  268. X
  269. X/*
  270. X *    freehand - returns true if player has a free hand
  271. X */
  272. Xint
  273. Xfreehand()
  274. X{
  275. X    return(!uwep || !welded(uwep) ||
  276. X       (!bimanual(uwep) && (!uarms || !uarms->cursed)));
  277. X/*    if ((uwep && bimanual(uwep)) ||
  278. X        (uwep && uarms))
  279. X        return(0);
  280. X    else
  281. X        return(1);*/
  282. X}
  283. X
  284. Xstatic const char NEARDATA styluses[] =
  285. X    { ALL_CLASSES, ALLOW_NONE, TOOL_CLASS, WEAPON_CLASS, WAND_CLASS,
  286. X      GEM_CLASS, RING_CLASS, 0 };
  287. X
  288. X/* Mohs' Hardness Scale:
  289. X *  1 - Talc         6 - Orthoclase
  290. X *  2 - Gypsum         7 - Quartz
  291. X *  3 - Calcite         8 - Topaz
  292. X *  4 - Fluorite     9 - Corundum
  293. X *  5 - Apatite        10 - Diamond
  294. X *
  295. X * Since granite is a igneous rock hardness ~ 7, anything >= 8 should
  296. X * probably be able to scratch the rock.
  297. X * Devaluation of less hard gems is not easily possible because obj struct
  298. X * does not contain individual oc_cost currently. 7/91
  299. X *
  300. X * dilithium  - ??            * jade        -  5-6    (nephrite)
  301. X * diamond    - 10            * turquoise -  5-6
  302. X * ruby          -  9    (corundum)    * opal        -  5-6
  303. X * sapphire   -  9    (corundum)    * iron        -  4-5
  304. X * topaz      -  8            * fluorite  -  4
  305. X * emerald    -  7.5-8    (beryl)        * brass     -  3-4
  306. X * aquamarine -  7.5-8    (beryl)        * gold        -  2.5-3
  307. X * garnet     -  7.25    (var. 6.5-8)    * silver    -  2.5-3
  308. X * agate      -  7    (quartz)    * copper    -  2.5-3
  309. X * amethyst   -  7    (quartz)    * amber     -  2-2.5
  310. X * jasper     -  7    (quartz)    *    
  311. X * onyx          -  7     (quartz)    * steel     -  5-8.5    (usu. weapon)
  312. X * moonstone  -  6    (orthoclase)    *
  313. X */
  314. X
  315. Xstatic const short NEARDATA hard_gems[] =
  316. X    { DIAMOND, RUBY, SAPPHIRE, TOPAZ, EMERALD, AQUAMARINE, GARNET, 0 };
  317. X
  318. Xstatic const char NEARDATA *hard_ring_names[] =
  319. X    {"diamond", "ruby", "sapphire", "emerald", "topaz", ""};
  320. X
  321. X/* return 1 if action took 1 (or more) moves, 0 if error or aborted */
  322. Xint
  323. Xdoengrave()
  324. X{
  325. X    boolean dengr = FALSE;    /* TRUE if we wipe out the current engraving */
  326. X    boolean doblind = FALSE;/* TRUE if engraving blinds the player */
  327. X    boolean doknown = FALSE;/* TRUE if we identify the stylus */
  328. X    boolean eow = FALSE;    /* TRUE if we are overwriting oep */
  329. X    boolean jello = FALSE;    /* TRUE if we are engraving in slime */
  330. X    boolean ptext = TRUE;    /* TRUE if we must prompt for engrave text */
  331. X    boolean teleengr =FALSE;/* TRUE if we move the old engraving */
  332. X    boolean zapwand = FALSE;/* TRUE if we remove a wand charge */
  333. X    xchar type = DUST;    /* Type of engraving made */
  334. X    char buf[BUFSZ];    /* Buffer for final/poly engraving text */
  335. X    char ebuf[BUFSZ];    /* Buffer for initial engraving text */
  336. X    char qbuf[QBUFSZ];    /* Buffer for query text */
  337. X    const char *everb;    /* Present tense of engraving type */
  338. X    const char *eloc;    /* Where the engraving is (ie dust/floor/...) */
  339. X    const char *post_engr_text; /* Text displayed after engraving prompt */
  340. X    register char *sp;    /* Place holder for space count of engr text */
  341. X    register int len;    /* # of nonspace chars of new engraving text */
  342. X    register int maxelen;    /* Max allowable length of new engraving text */
  343. X    register int spct;    /* # of spaces in new engraving text */
  344. X    register struct engr *oep = engr_at(u.ux,u.uy);
  345. X                /* The current engraving */
  346. X    register struct obj *otmp; /* Object selected with which to engrave */
  347. X
  348. X
  349. X    multi = 0;        /* moves consumed */
  350. X    nomovemsg = (char *)0;    /* occupation end message */
  351. X
  352. X    buf[0] = (char)0;
  353. X    ebuf[0] = (char)0;
  354. X    post_engr_text = (char *)0;
  355. X    maxelen = BUFSZ - 1;
  356. X
  357. X    /* Can the adventurer engrave at all? */
  358. X
  359. X    if(u.uswallow) {
  360. X        if (is_animal(u.ustuck->data)) {
  361. X            pline("What would you write?  \"Jonah was here\"?");
  362. X            return(0);
  363. X        } else if (is_whirly(u.ustuck->data)) {
  364. X            You("can't reach the ground.");
  365. X            return(0);
  366. X        } else 
  367. X            jello = TRUE;
  368. X        } else if (is_lava(u.ux, u.uy)) {
  369. X        You("can't write on the lava!");
  370. X        return(0);
  371. X    } else if (is_pool(u.ux,u.uy) || IS_FOUNTAIN(levl[u.ux][u.uy].typ)) {
  372. X        You("can't write on the water!");
  373. X        return(0);
  374. X    }
  375. X    if(Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)/* in bubble */) {
  376. X        You("can't write in thin air!");
  377. X        return(0);
  378. X    }
  379. X#ifdef POLYSELF
  380. X    if (cantwield(uasmon)) {
  381. X        You("can't even hold anything!");
  382. X        return(0);
  383. X    }
  384. X#endif
  385. X    if (check_capacity(NULL)) return (0);
  386. X
  387. X    /* One may write with finger, or weapon, or wand, or..., or...
  388. X     * Edited by GAN 10/20/86 so as not to change weapon wielded.
  389. X     */
  390. X
  391. X    otmp = getobj(styluses, "write with");
  392. X    if(!otmp) return(0);        /* otmp == zeroobj if fingers */
  393. X
  394. X    /* There's no reason you should be able to write with a wand
  395. X     * while both your hands are tied up.
  396. X     */
  397. X    if (!freehand() && otmp != uwep && !otmp->owornmask) {
  398. X        You("have no free %s to write with!", body_part(HAND));
  399. X        return(0);
  400. X    }
  401. X
  402. X    if (jello) {
  403. X        You("tickle %s with your %s.", mon_nam(u.ustuck), 
  404. X            (otmp == &zeroobj) ? makeplural(body_part(FINGER)) :
  405. X            xname(otmp));
  406. X        Your("message dissolves...");
  407. X        return(0);
  408. X    }
  409. X    if(Levitation && otmp->oclass != WAND_CLASS){        /* riv05!a3 */
  410. X        You("can't reach the floor!");
  411. X        return(0);
  412. X    }
  413. X
  414. X    /* SPFX for items */
  415. X
  416. X    switch (otmp->oclass) {
  417. X        default:
  418. X        case AMULET_CLASS:
  419. X        case CHAIN_CLASS:
  420. X        case POTION_CLASS:
  421. X        case GOLD_CLASS:
  422. X        break;
  423. X
  424. X        case RING_CLASS:
  425. X        /* "diamond" rings and others should work */
  426. X        {
  427. X            register int i, j;
  428. X
  429. X            for (i=0, j=strlen(hard_ring_names[i]); j; i++)
  430. X            if ( !strncmp(hard_ring_names[i],
  431. X                 OBJ_DESCR(objects[otmp->otyp]),
  432. X                 j=strlen(hard_ring_names[i])) ) {
  433. X                type = ENGRAVE;
  434. X                break;
  435. X            }
  436. X        }
  437. X        break;
  438. X
  439. X        case GEM_CLASS:
  440. X        /* diamonds & other gems should work */
  441. X        {
  442. X            register int i;
  443. X
  444. X            for (i=0; hard_gems[i]; i++)
  445. X            if (otmp->otyp == hard_gems[i]) {
  446. X                type = ENGRAVE;
  447. X                break;
  448. X            }
  449. X        }
  450. X        break;
  451. X
  452. X        /* Objects too large to engrave with */
  453. X        case BALL_CLASS:
  454. X        case ROCK_CLASS:
  455. X        case ARMOR_CLASS:
  456. X        You("can't engrave with such a large object!");
  457. X        ptext = FALSE;
  458. X        break;
  459. X
  460. X        /* Objects too silly to engrave with */
  461. X        case FOOD_CLASS:
  462. X        case SCROLL_CLASS:
  463. X        case SPBOOK_CLASS:
  464. X        Your("%s would get too dirty.", xname(otmp));
  465. X        ptext = FALSE;
  466. X        break;
  467. X
  468. X        case RANDOM_CLASS:    /* This should mean fingers */
  469. X        break;
  470. X
  471. X        /* The charge is removed from the wand before prompting for
  472. X         * the engraving text, because all kinds of setup decisions
  473. X         * and pre-engraving messages are based upon knowing what type
  474. X         * of engraving the wand is going to do.  Also, the player
  475. X         * will have potentially seen "You wrest .." message, and
  476. X         * therefore will know they are using a charge.
  477. X         */
  478. X        case WAND_CLASS:
  479. X        if (zappable(otmp)) {
  480. X            zapwand = TRUE;
  481. X            if (Levitation) ptext = FALSE;
  482. X
  483. X            switch (otmp->otyp) {
  484. X            /* DUST wands */
  485. X            default:
  486. X            break;
  487. X
  488. X            /* NODIR wands */
  489. X            case WAN_LIGHT:
  490. X            case WAN_SECRET_DOOR_DETECTION:
  491. X            case WAN_CREATE_MONSTER:
  492. X            case WAN_WISHING:
  493. X              zapnodir(otmp);
  494. X            break;
  495. X
  496. X            /* IMMEDIATE wands */
  497. X                /* If wand is "IMMEDIATE", remember to effect the
  498. X             * previous engraving even if turning to dust.,
  499. X             */
  500. X            case WAN_STRIKING:
  501. X            post_engr_text =
  502. X            "The wand unsuccessfully fights your attempt to write!";
  503. X            break;
  504. X            case WAN_SLOW_MONSTER:
  505. X            if (!Blind)
  506. X               post_engr_text = "The bugs on the ground slow down!";
  507. X            break;
  508. X            case WAN_SPEED_MONSTER:
  509. X            if (!Blind)
  510. X               post_engr_text = "The bugs on the ground speed up!";
  511. X            break;
  512. X            case WAN_POLYMORPH:
  513. X            if(oep)  {
  514. X                if (!Blind) {
  515. X                type = (xchar)0;    /* random */
  516. X                Strcpy(buf,random_engraving());
  517. X                }
  518. X                dengr = TRUE;
  519. X            }
  520. X            break;
  521. X            case WAN_NOTHING:
  522. X            case WAN_UNDEAD_TURNING:
  523. X            case WAN_OPENING:
  524. X            case WAN_LOCKING:
  525. X            case WAN_PROBING:
  526. X            break;
  527. X
  528. X            /* RAY wands */
  529. X            case WAN_MAGIC_MISSILE:
  530. X            ptext = TRUE;
  531. X            if (!Blind)
  532. X                post_engr_text =
  533. X                "The ground is riddled by bullet holes!";
  534. X            break;
  535. X
  536. X            /* can't tell sleep from death - Eric Backus */
  537. X            case WAN_SLEEP:
  538. X            case WAN_DEATH:
  539. X            if (!Blind)
  540. X                post_engr_text =
  541. X                "The bugs on the ground stop moving!";
  542. X            break;
  543. X
  544. X            case WAN_COLD:
  545. X            if (!Blind)
  546. X                post_engr_text =
  547. X                "A few ice cubes drop from the wand.";
  548. X            if(!oep || (oep->engr_type != BURN))
  549. X                break;
  550. X            case WAN_CANCELLATION:
  551. X            case WAN_MAKE_INVISIBLE:
  552. X            if(oep) {
  553. X                if (!Blind)
  554. X                pline("The engraving on the floor vanishes!");
  555. X                dengr = TRUE;
  556. X            }
  557. X            break;
  558. X            case WAN_TELEPORTATION:
  559. X            if (oep) {
  560. X                if (!Blind)
  561. X                pline("The engraving on the floor vanishes!");
  562. X                teleengr = TRUE;
  563. X            }
  564. X            break;
  565. X
  566. X            /* type = ENGRAVE wands */
  567. X            case WAN_DIGGING:
  568. X            ptext = TRUE;
  569. X            type  = ENGRAVE;
  570. X            if(!objects[otmp->otyp].oc_name_known) {
  571. X                    if (flags.verbose)
  572. X                pline("This %s is a wand of digging!",
  573. X                xname(otmp));
  574. X                doknown = TRUE;
  575. X            }
  576. X            if (!Blind)
  577. X                post_engr_text = "Gravel flies up from the floor.";
  578. X            else
  579. X                post_engr_text = "You hear drilling!";
  580. X            break;
  581. X
  582. X            /* type = BURN wands */
  583. X            case WAN_FIRE:
  584. X            ptext = TRUE;
  585. X            type  = BURN;
  586. X            if(!objects[otmp->otyp].oc_name_known) {
  587. X                if (flags.verbose)
  588. X                pline("This %s is a wand of fire!", xname(otmp));
  589. X                doknown = TRUE;
  590. X            }
  591. X            if (!Blind)
  592. X                post_engr_text = "Flames fly from the wand.";
  593. X            else
  594. X                post_engr_text = "You feel the wand heat up.";
  595. X            break;
  596. X            case WAN_LIGHTNING:
  597. X            ptext = TRUE;
  598. X            type  = BURN;
  599. X            if(!objects[otmp->otyp].oc_name_known) {
  600. X                    if (flags.verbose)
  601. X                pline("This %s is a wand of lightning!",
  602. X                    xname(otmp));
  603. X                doknown = TRUE;
  604. X            }
  605. X            if (!Blind) {
  606. X                post_engr_text = "Lightning arcs from the wand.";
  607. X                doblind = TRUE;
  608. X            } else
  609. X                post_engr_text = "You hear crackling!";
  610. X            break;
  611. X
  612. X            /* type = MARK wands */
  613. X            /* type = BLOOD wands */
  614. X            }
  615. X        } else /* end if zappable */
  616. X            if (Levitation) {
  617. X            You("can't reach the floor!");
  618. X            return(0);
  619. X            }
  620. X        break;
  621. X
  622. X        case WEAPON_CLASS:
  623. X        if(is_blade(otmp))
  624. X            if ((int)otmp->spe > -3)
  625. X            type = ENGRAVE;
  626. X            else
  627. X            Your("%s too dull for engraving.", aobjnam(otmp,"are"));
  628. X        break;
  629. X
  630. X        case TOOL_CLASS:
  631. X        if(otmp == ublindf) {
  632. X            pline(
  633. X        "That is a bit difficult to engrave with, don't you think?");
  634. X            return(0);
  635. X        }
  636. X        switch (otmp->otyp)  {
  637. X            case MAGIC_MARKER:
  638. X            if (otmp->spe <= 0)
  639. X                Your("marker has dried out.");
  640. X            else
  641. X                type = MARK;
  642. X            break;
  643. X            case TOWEL:
  644. X             /* Can't really engrave with a towel */
  645. X            ptext = FALSE;
  646. X            if (oep)
  647. X                if ((oep->engr_type == DUST ) ||
  648. X                (oep->engr_type == BLOOD) ||
  649. X                (oep->engr_type == MARK )) {
  650. X                if (!Blind)
  651. X                    You("wipe out the message here.");
  652. X                else
  653. X                    Your("%s gets dusty.", xname(otmp));
  654. X                dengr = TRUE;
  655. X                } else
  656. X                Your("%s can't wipe out this engraving.",
  657. X                     xname(otmp));
  658. X            else
  659. X                Your("%s gets dusty.", xname(otmp));
  660. X            break;
  661. X            default:
  662. X            break;
  663. X        }
  664. X        break;
  665. X
  666. X        case VENOM_CLASS:
  667. X#ifdef WIZARD
  668. X        if (wizard) {
  669. X            pline("Writing a poison pen letter??");
  670. X            break;
  671. X        }
  672. X#endif
  673. X        case ILLOBJ_CLASS:
  674. X        impossible("You're engraving with an illegal object!");
  675. X        break;
  676. X    }
  677. X
  678. X    /* End of implement setup */
  679. X
  680. X    /* Identify stylus */
  681. X    if (doknown) {
  682. X        makeknown(otmp->otyp);
  683. X        more_experienced(0,10);
  684. X    }
  685. X
  686. X    if (teleengr) {
  687. X        register int tx,ty;
  688. X
  689. X        do  {
  690. X         tx = rn1(COLNO-3,2);
  691. X        ty = rn2(ROWNO);
  692. X        } while(!goodpos(tx,ty, (struct monst *)0, (struct permonst *)0));
  693. X
  694. X        oep->engr_x = tx;
  695. X        oep->engr_y = ty;
  696. X
  697. X        oep = (struct engr *)0;
  698. X    }
  699. X
  700. X    if (dengr) {
  701. X        del_engr (oep);
  702. X        oep = (struct engr *)0;
  703. X    }
  704. X
  705. X    /* Something has changed the engraving here */
  706. X    if (*buf) {
  707. X        make_engr_at(u.ux, u.uy, buf, moves, type);
  708. X        pline("The engraving now reads: \"%s\".", buf);
  709. X        ptext = FALSE;
  710. X    }
  711. X
  712. X    if (zapwand && (otmp->spe < 0)) {
  713. X        pline("%s %sturns to dust.",
  714. X          The(xname(otmp)), Blind ? "" : "glows violently, then ");
  715. XYou("are not going to get anywhere trying to write in the dust with your dust.");
  716. X        useup(otmp);
  717. X        ptext = FALSE;
  718. X    }
  719. X
  720. X    if (!ptext) {        /* Early exit for some implements. */
  721. X        if (Levitation && (otmp->oclass == WAND_CLASS))
  722. X        You("can't reach the floor!");
  723. X        return(1);
  724. X    }
  725. X
  726. X    /* Special effects should have deleted the current engraving (if
  727. X     * possible) by now.
  728. X     */
  729. X
  730. X    if (oep) {
  731. X        register char c = 'n';
  732. X
  733. X        /* Give player the choice to add to engraving. */
  734. X
  735. X        if ( (type == oep->engr_type) && (!Blind ||
  736. X         (oep->engr_type == BURN) || (oep->engr_type == ENGRAVE)) ) {
  737. X            c = yn_function("Do you want to add to the current engraving?",
  738. X                ynqchars, 'y');
  739. X        if (c == 'q') {
  740. X            pline("Never mind.");
  741. X            return(0);
  742. X        }
  743. X        }
  744. X
  745. X        if (c == 'n' || Blind)
  746. X
  747. X        if( (oep->engr_type == DUST) || (oep->engr_type == BLOOD) ||
  748. X            (oep->engr_type == MARK) ) {
  749. X            if (!Blind) {
  750. X            You("wipe out the message that was %s here.",
  751. X                ((oep->engr_type == DUST)  ? "written in the dust" :
  752. X                ((oep->engr_type == BLOOD) ? "scrawled in blood"   :
  753. X                             "written")));
  754. X            del_engr(oep);
  755. X            oep = (struct engr *)0;
  756. X            } else
  757. X           /* Don't delete engr until after we *know* we're engraving */
  758. X            eow = TRUE;
  759. X        } else
  760. X            if ( (type == DUST) || (type == MARK) || (type == BLOOD) ) {
  761. X            You(
  762. X               "cannot wipe out the message that is %s the floor here.",
  763. X                    (oep->engr_type == BURN) ? "burned into" :
  764. X                "engraved in");
  765. X            return(1);
  766. X            } else
  767. X            if ( (type != oep->engr_type) || (c == 'n') ) {
  768. X                if (!Blind || !Levitation)
  769. X                You("will overwrite the current message.");
  770. X                eow = TRUE;
  771. X            }
  772. X    }
  773. X
  774. X    switch(type){
  775. X        default:
  776. X        everb = (oep && !eow ? "add to the weird writing on" :
  777. X                       "write strangely on");
  778. X        eloc  = "the floor";
  779. X        break;
  780. X        case DUST:
  781. X        everb = (oep && !eow ? "add to the writing in" :
  782. X                       "write in");
  783. X        eloc = "the dust";
  784. X        break;
  785. X        case ENGRAVE:
  786. X        everb = (oep && !eow ? "add to the engraving in" :
  787. X                       "engrave in");
  788. X        eloc = "the floor";
  789. X        break;
  790. X        case BURN:
  791. X        everb = (oep && !eow ? "add to the text burned into" :
  792. X                       "burn into");
  793. X        eloc = "the floor";
  794. X        break;
  795. X        case MARK:
  796. X        everb = (oep && !eow ? "add to the graffiti on" :
  797. X                       "scribble on");
  798. X        eloc = "the floor";
  799. X        break;
  800. X        case BLOOD:
  801. X        everb = (oep && !eow ? "add to the scrawl on" :
  802. X                       "scrawl on");
  803. X        eloc = "the floor";
  804. X        break;
  805. X    }
  806. X
  807. X    /* Tell adventurer what is going on */
  808. X    if (otmp != &zeroobj)
  809. X        You("%s %s with %s.", everb, eloc, doname(otmp));
  810. X    else
  811. X        You("%s %s with your %s.", everb, eloc,
  812. X        makeplural(body_part(FINGER)));
  813. X
  814. X    /* Prompt for engraving! */
  815. X    Sprintf(qbuf,"What do you want to %s %s here?", everb, eloc);
  816. X    getlin(qbuf, ebuf);
  817. X    clear_nhwindow(WIN_MESSAGE);
  818. X
  819. X    /* Mix up engraving if surface or state of mind is unsound.  */
  820. X    /* Original kludge by stewr 870708.  modified by njm 910722. */
  821. X    for (sp = ebuf; *sp; sp++)
  822. X        if ( ((type == DUST || type == BLOOD) && !rn2(25)) ||
  823. X         (Blind   && !rn2(9)) || (Confusion     && !rn2(12)) ||
  824. X         (Stunned && !rn2(4)) || (Hallucination && !rn2(1)) )
  825. X         *sp = '!' + rn2(93); /* ASCII-code only */
  826. X
  827. X    /* Count the actual # of chars engraved not including spaces */
  828. X    len = strlen(ebuf);
  829. X
  830. X    for (sp = ebuf, spct = 0; *sp; sp++) if (isspace(*sp)) spct++;
  831. X
  832. X    if ( (len == spct) || index(ebuf, '\033') ) {
  833. X        if (zapwand) {
  834. X        if (!Blind)
  835. X            pline("%s glows, then fades.", The(xname(otmp)));
  836. X            return(1);
  837. X        } else {
  838. X        pline("Never mind.");
  839. X        return(0);
  840. X        }
  841. X    }
  842. X
  843. X    len -= spct;
  844. X
  845. X    /* Previous engraving is overwritten */
  846. X    if (eow) {
  847. X        del_engr(oep);
  848. X        oep = (struct engr *)0;
  849. X    }
  850. X
  851. X    /* Figure out how long it took to engrave, and if player has
  852. X     * engraved too much.
  853. X     */
  854. X    switch(type){
  855. X        default:
  856. X        multi = -(len/10);
  857. X        if (multi) nomovemsg = "You finish your weird engraving.";
  858. X        break;
  859. X        case DUST:
  860. X        multi = -(len/10);
  861. X        if (multi) nomovemsg = "You finish writing in the dust.";
  862. X        break;
  863. X        case ENGRAVE:
  864. X        multi = -(len/10);
  865. X        if ((otmp->oclass == WEAPON_CLASS) &&
  866. X            ((otmp->otyp != ATHAME) || otmp->cursed)) {
  867. X            multi = -len;
  868. X            maxelen = ((otmp->spe + 3) * 2) + 1;
  869. X            /* -2 = 3, -1 = 5, 0 = 7, +1 = 9, +2 = 11
  870. X             * Note: this does not allow a +0 anything (except
  871. X             *     an athame) to engrave "Elbereth" all at once.
  872. X             *     However, you could now engrave "Elb", then
  873. X             *     "ere", then "th".
  874. X             */
  875. X            Your("%s dull.", aobjnam(otmp, "get"));
  876. X            if (len > maxelen) {
  877. X                multi = -maxelen;
  878. X            otmp->spe = -3;
  879. X            } else
  880. X            if (len > 1) otmp->spe -= len >> 1;
  881. X            else otmp->spe -= 1; /* Prevent infinite engraving */
  882. X        } else
  883. X            if ( (otmp->oclass == RING_CLASS) ||
  884. X             (otmp->oclass == GEM_CLASS) )
  885. X            multi = -len;
  886. X        if (multi) nomovemsg = "You finish engraving.";
  887. X        break;
  888. X        case BURN:
  889. X        multi = -(len/10);
  890. X        if (multi)
  891. X            nomovemsg =
  892. X            "You finish burning your message into the floor.";
  893. X        break;
  894. X        case MARK:
  895. X        multi = -(len/10);
  896. X        if ((otmp->oclass == TOOL_CLASS) &&
  897. X            (otmp->otyp == MAGIC_MARKER)) {
  898. X            maxelen = (otmp->spe) * 2; /* one charge / 2 letters */
  899. X            if (len > maxelen) {
  900. X            Your("marker dries out.");
  901. X            otmp->spe = 0;
  902. X            multi = -(maxelen/10);
  903. X            } else
  904. X            if (len > 1) otmp->spe -= len >> 1;
  905. X            else otmp->spe -= 1; /* Prevent infinite grafitti */
  906. X        }
  907. X        if (multi) nomovemsg = "You finish defacing the dungeon.";
  908. X        break;
  909. X        case BLOOD:
  910. X        multi = -(len/10);
  911. X        if (multi) nomovemsg = "You finish scrawling.";
  912. X        break;
  913. X    }
  914. X
  915. X    /* Chop engraving down to size if necessary */
  916. X    if (len > maxelen) {
  917. X        for (sp = ebuf; (maxelen && *sp); sp++)
  918. X        if (!isspace(*sp)) maxelen--;
  919. X        if (!maxelen && *sp) {
  920. X        *sp = (char)0;
  921. X        if (multi) nomovemsg = "You cannot write any more.";
  922. X        You("only are able to write \"%s\"", ebuf);
  923. X        }
  924. X    }
  925. X
  926. X    /* Add to existing engraving */
  927. X    if (oep) Strcpy(buf, oep->engr_txt);    
  928. X
  929. X    (void) strncat(buf, ebuf, (BUFSZ - (int)strlen(buf) - 1));
  930. X
  931. X    make_engr_at(u.ux, u.uy, buf, (moves - multi), type);
  932. X
  933. X    if (post_engr_text) pline(post_engr_text);
  934. X
  935. X    if (doblind) {
  936. X        You("are blinded by the flash!");
  937. X        make_blinded((long)rnd(50),FALSE);
  938. X    }
  939. X
  940. X    return(1);
  941. X}
  942. X
  943. Xvoid
  944. Xsave_engravings(fd, mode)
  945. Xint fd, mode;
  946. X{
  947. X    register struct engr *ep = head_engr;
  948. X    register struct engr *ep2;
  949. X#ifdef GCC_WARN
  950. X    static long nulls[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  951. X#endif
  952. X    while(ep) {
  953. X        ep2 = ep->nxt_engr;
  954. X        if(ep->engr_lth && ep->engr_txt[0]){
  955. X        bwrite(fd, (genericptr_t)&(ep->engr_lth), sizeof(ep->engr_lth));
  956. X        bwrite(fd, (genericptr_t)ep, sizeof(struct engr) + ep->engr_lth);
  957. X        }
  958. X        if (mode & FREE_SAVE)
  959. X        dealloc_engr(ep);
  960. X        ep = ep2;
  961. X    }
  962. X
  963. X#ifdef GCC_WARN
  964. X    bwrite(fd, (genericptr_t)nulls, sizeof(unsigned));
  965. X#else
  966. X    bwrite(fd, (genericptr_t)nul, sizeof(unsigned));
  967. X#endif
  968. X
  969. X    if (mode & FREE_SAVE)
  970. X        head_engr = 0;
  971. X}
  972. X
  973. Xvoid
  974. Xrest_engravings(fd) int fd; {
  975. Xregister struct engr *ep;
  976. Xunsigned lth;
  977. X    head_engr = 0;
  978. X    while(1) {
  979. X        mread(fd, (genericptr_t) <h, sizeof(unsigned));
  980. X        if(lth == 0) return;
  981. X        ep = newengr(lth);
  982. X        mread(fd, (genericptr_t) ep, sizeof(struct engr) + lth);
  983. X        ep->nxt_engr = head_engr;
  984. X        head_engr = ep;
  985. X        ep->engr_txt = (char *) (ep + 1);    /* Andreas Bormann */
  986. X        /* mark as finished for bones levels -- no problem for
  987. X         * normal levels as the player must have finished engraving
  988. X         * to be able to move again */
  989. X        ep->engr_time = moves;
  990. X    }
  991. X}
  992. X
  993. XSTATIC_OVL void
  994. Xdel_engr(ep) register struct engr *ep; {
  995. Xregister struct engr *ept;
  996. X    if(ep == head_engr)
  997. X        head_engr = ep->nxt_engr;
  998. X    else {
  999. X        for(ept = head_engr; ept; ept = ept->nxt_engr) {
  1000. X            if(ept->nxt_engr == ep) {
  1001. X                ept->nxt_engr = ep->nxt_engr;
  1002. X                goto fnd;
  1003. X            }
  1004. X        }
  1005. X        impossible("Error in del_engr?");
  1006. X        return;
  1007. X    fnd:    ;
  1008. X    }
  1009. X    dealloc_engr(ep);
  1010. X}
  1011. X
  1012. X#endif /* OVLB */
  1013. X
  1014. X/*engrave.c*/
  1015. END_OF_FILE
  1016. if test 23761 -ne `wc -c <'src/engrave.c'`; then
  1017.     echo shar: \"'src/engrave.c'\" unpacked with wrong size!
  1018. fi
  1019. # end of 'src/engrave.c'
  1020. fi
  1021. if test -f 'sys/share/lev_yacc.c2' -a "${1}" != "-c" ; then 
  1022.   echo shar: Will not clobber existing file \"'sys/share/lev_yacc.c2'\"
  1023. else
  1024. echo shar: Extracting \"'sys/share/lev_yacc.c2'\" \(30244 characters\)
  1025. sed "s/^X//" >'sys/share/lev_yacc.c2' <<'END_OF_FILE'
  1026. X    /*
  1027. X    ** code supplied by user is placed in this switch
  1028. X    */
  1029. X    switch( yytmp )
  1030. X    {
  1031. X        
  1032. Xcase 7:
  1033. X# line 193 "lev_comp.y"
  1034. X{
  1035. X              int fout, i;
  1036. X
  1037. X            if (fatal_error > 0) {
  1038. X                fprintf(stderr,
  1039. X                  "%s : %d errors detected. No output created!\n",
  1040. X                    fname, fatal_error);
  1041. X            } else {
  1042. X                char lbuf[20];
  1043. X                Strcpy(lbuf, yypvt[-4].map);
  1044. X                Strcat(lbuf, LEV_EXT);
  1045. X#ifdef MAC_THINKC5
  1046. X                fout = open(lbuf, O_WRONLY|O_CREAT|O_BINARY);
  1047. X#else
  1048. X                fout = open(lbuf, O_WRONLY|O_CREAT|O_BINARY, OMASK);
  1049. X#endif
  1050. X                if (fout < 0) {
  1051. X                    yyerror("Can't open output file!!");
  1052. X                    exit(1);
  1053. X                }
  1054. X                maze.flags = yypvt[-3].i;
  1055. X                memcpy(&(maze.init_lev), &(init_lev),
  1056. X                       sizeof(lev_init));
  1057. X                maze.numpart = npart;
  1058. X                maze.parts = NewTab(mazepart, npart);
  1059. X                for(i=0;i<npart;i++)
  1060. X                    maze.parts[i] = tmppart[i];
  1061. X                write_maze(fout, &maze);
  1062. X                (void) close(fout);
  1063. X                npart = 0;
  1064. X            }
  1065. X          } break;
  1066. Xcase 8:
  1067. X# line 228 "lev_comp.y"
  1068. X{
  1069. X            int fout, i;
  1070. X
  1071. X            if (fatal_error > 0) {
  1072. X                fprintf(stderr,
  1073. X                  "%s : %d errors detected. No output created!\n",
  1074. X                    fname, fatal_error);
  1075. X            } else {
  1076. X                char lbuf[20];
  1077. X                Strcpy(lbuf, yypvt[-6].map);
  1078. X                Strcat(lbuf, LEV_EXT);
  1079. X#ifdef MAC_THINKC5
  1080. X                fout = open(lbuf, O_WRONLY|O_CREAT|O_BINARY);
  1081. X#else
  1082. X                fout = open(lbuf, O_WRONLY|O_CREAT|O_BINARY, OMASK);
  1083. X#endif
  1084. X                if (fout < 0) {
  1085. X                    yyerror("Can't open output file!!");
  1086. X                    exit(1);
  1087. X                }
  1088. X                special_lev.flags = yypvt[-5].i;
  1089. X                memcpy(&(special_lev.init_lev), &(init_lev),
  1090. X                       sizeof(lev_init));
  1091. X                special_lev.nroom = nrooms;
  1092. X                special_lev.rooms = NewTab(room, nrooms);
  1093. X                for(i=0; i<nrooms; i++)
  1094. X                    special_lev.rooms[i] = tmproom[i];
  1095. X                special_lev.ncorr = ncorridor;
  1096. X                special_lev.corrs = NewTab(corridor, ncorridor);
  1097. X                for(i=0; i<ncorridor; i++)
  1098. X                    special_lev.corrs[i] = tmpcor[i];
  1099. X                if (check_subrooms())
  1100. X                    write_lev(fout, &special_lev);
  1101. X                free_rooms(special_lev.rooms,special_lev.nroom);
  1102. X                nrooms = 0;
  1103. X                ncorridor = 0;
  1104. X                (void) close(fout);
  1105. X            }
  1106. X          } break;
  1107. Xcase 9:
  1108. X# line 270 "lev_comp.y"
  1109. X{
  1110. X            if (index(yypvt[-0].map, '.'))
  1111. X                yyerror("Invalid dot ('.') in level name.");
  1112. X            if (strlen(yypvt[-0].map) > 8)
  1113. X                yyerror("Level names limited to 8 characters.");
  1114. X            yyval.map = yypvt[-0].map;
  1115. X            special_lev.nrobjects = 0;
  1116. X            special_lev.nrmonst = 0;
  1117. X          } break;
  1118. Xcase 10:
  1119. X# line 282 "lev_comp.y"
  1120. X{
  1121. X            init_lev.init_present = FALSE;
  1122. X            yyval.i = 0;
  1123. X          } break;
  1124. Xcase 11:
  1125. X# line 287 "lev_comp.y"
  1126. X{
  1127. X            init_lev.init_present = TRUE;
  1128. X            if((init_lev.fg = what_map_char(yypvt[-10].i)) == INVALID_TYPE)
  1129. X                yyerror("Invalid foreground type.");
  1130. X            if((init_lev.bg = what_map_char(yypvt[-8].i)) == INVALID_TYPE)
  1131. X                yyerror("Invalid background type.");
  1132. X            init_lev.smoothed = yypvt[-6].i;
  1133. X            init_lev.joined = yypvt[-4].i;
  1134. X            init_lev.lit = yypvt[-2].i;
  1135. X            init_lev.walled = yypvt[-0].i;
  1136. X            yyval.i = 1;
  1137. X          } break;
  1138. Xcase 14:
  1139. X# line 306 "lev_comp.y"
  1140. X{
  1141. X            yyval.i = 0;
  1142. X          } break;
  1143. Xcase 15:
  1144. X# line 310 "lev_comp.y"
  1145. X{
  1146. X            yyval.i = lev_flags;
  1147. X          } break;
  1148. Xcase 16:
  1149. X# line 316 "lev_comp.y"
  1150. X{
  1151. X            lev_flags |= yypvt[-0].i;
  1152. X          } break;
  1153. Xcase 17:
  1154. X# line 320 "lev_comp.y"
  1155. X{
  1156. X            lev_flags |= yypvt[-0].i;
  1157. X          } break;
  1158. Xcase 20:
  1159. X# line 330 "lev_comp.y"
  1160. X{
  1161. X            int i, j;
  1162. X
  1163. X            i = strlen(yypvt[-0].map) + 1;
  1164. X            j = tmpmessage[0] ? strlen(tmpmessage) : 0;
  1165. X            if(i+j > 255) {
  1166. X               yyerror("Message string too long (>256 characters)");
  1167. X            } else {
  1168. X                if(j) tmpmessage[j++] = '\n';
  1169. X                strncpy(tmpmessage+j, yypvt[-0].map, i-1);
  1170. X                tmpmessage[j+i-1] = 0;
  1171. X            }
  1172. X          } break;
  1173. Xcase 23:
  1174. X# line 350 "lev_comp.y"
  1175. X{
  1176. X            if(special_lev.nrobjects) {
  1177. X                yyerror("Object registers already initialized!");
  1178. X            } else {
  1179. X                special_lev.nrobjects = n_olist;
  1180. X                special_lev.robjects = (char *) alloc(n_olist);
  1181. X                (void) memcpy((genericptr_t)special_lev.robjects,
  1182. X                      (genericptr_t)olist, n_olist);
  1183. X            }
  1184. X          } break;
  1185. Xcase 24:
  1186. X# line 361 "lev_comp.y"
  1187. X{
  1188. X            if(special_lev.nrmonst) {
  1189. X                yyerror("Monster registers already initialized!");
  1190. X            } else {
  1191. X                special_lev.nrmonst = n_mlist;
  1192. X                special_lev.rmonst = (char *) alloc(n_mlist);
  1193. X                (void) memcpy((genericptr_t)special_lev.rmonst,
  1194. X                      (genericptr_t)mlist, n_mlist);
  1195. X              }
  1196. X          } break;
  1197. Xcase 25:
  1198. X# line 374 "lev_comp.y"
  1199. X{
  1200. X            tmproom[nrooms] = New(room);
  1201. X            (void) memset((genericptr_t) tmproom[nrooms], 0,
  1202. X                    sizeof *tmproom[nrooms]);
  1203. X            tmproom[nrooms]->name = (char *) 0;
  1204. X            tmproom[nrooms]->parent = (char *) 0;
  1205. X            tmproom[nrooms]->rtype = 0;
  1206. X            tmproom[nrooms]->rlit = 0;
  1207. X            tmproom[nrooms]->xalign = ERR;
  1208. X            tmproom[nrooms]->yalign = ERR;
  1209. X            tmproom[nrooms]->x = 0;
  1210. X            tmproom[nrooms]->y = 0;
  1211. X            tmproom[nrooms]->w = 2;
  1212. X            tmproom[nrooms]->h = 2;
  1213. X            in_room = 1;
  1214. X          } break;
  1215. Xcase 31:
  1216. X# line 402 "lev_comp.y"
  1217. X{
  1218. X            tmpcor[0] = New(corridor);
  1219. X            tmpcor[0]->src.room = -1;
  1220. X            ncorridor = 1;
  1221. X          } break;
  1222. Xcase 34:
  1223. X# line 414 "lev_comp.y"
  1224. X{
  1225. X            tmpcor[ncorridor] = New(corridor);
  1226. X            tmpcor[ncorridor]->src.room = yypvt[-2].corpos.room;
  1227. X            tmpcor[ncorridor]->src.wall = yypvt[-2].corpos.wall;
  1228. X            tmpcor[ncorridor]->src.door = yypvt[-2].corpos.door;
  1229. X            tmpcor[ncorridor]->dest.room = yypvt[-0].corpos.room;
  1230. X            tmpcor[ncorridor]->dest.wall = yypvt[-0].corpos.wall;
  1231. X            tmpcor[ncorridor]->dest.door = yypvt[-0].corpos.door;
  1232. X            ncorridor++;
  1233. X          } break;
  1234. Xcase 35:
  1235. X# line 425 "lev_comp.y"
  1236. X{
  1237. X            tmpcor[ncorridor]->src.room = yypvt[-2].corpos.room;
  1238. X            tmpcor[ncorridor]->src.wall = yypvt[-2].corpos.wall;
  1239. X            tmpcor[ncorridor]->src.door = yypvt[-2].corpos.door;
  1240. X            tmpcor[ncorridor]->dest.room = -1;
  1241. X            tmpcor[ncorridor]->dest.wall = yypvt[-0].i;
  1242. X            ncorridor++;
  1243. X          } break;
  1244. Xcase 36:
  1245. X# line 436 "lev_comp.y"
  1246. X{
  1247. X            if (yypvt[-5].i >= nrooms)
  1248. X                yyerror("Wrong room number!");
  1249. X            yyval.corpos.room = yypvt[-5].i;
  1250. X            yyval.corpos.wall = yypvt[-3].i;
  1251. X            yyval.corpos.door = yypvt[-1].i;
  1252. X          } break;
  1253. Xcase 37:
  1254. X# line 446 "lev_comp.y"
  1255. X{
  1256. X            store_room();
  1257. X          } break;
  1258. Xcase 38:
  1259. X# line 450 "lev_comp.y"
  1260. X{
  1261. X            store_room();
  1262. X          } break;
  1263. Xcase 39:
  1264. X# line 456 "lev_comp.y"
  1265. X{
  1266. X            tmproom[nrooms] = New(room);
  1267. X            (void) memset((genericptr_t) tmproom[nrooms], 0,
  1268. X                    sizeof *tmproom[nrooms]);
  1269. X            tmproom[nrooms]->parent = dup_string(yypvt[-1].map);
  1270. X            tmproom[nrooms]->name = (char *) 0;
  1271. X            tmproom[nrooms]->rtype = yypvt[-9].i;
  1272. X            tmproom[nrooms]->rlit = yypvt[-7].i;
  1273. X            tmproom[nrooms]->filled = yypvt[-0].i;
  1274. X            tmproom[nrooms]->xalign = ERR;
  1275. X            tmproom[nrooms]->yalign = ERR;
  1276. X            tmproom[nrooms]->x = current_coord.x;
  1277. X            tmproom[nrooms]->y = current_coord.y;
  1278. X            tmproom[nrooms]->w = current_size.width;
  1279. X            tmproom[nrooms]->h = current_size.height;
  1280. X            in_room = 1;
  1281. X          } break;
  1282. Xcase 40:
  1283. X# line 476 "lev_comp.y"
  1284. X{
  1285. X            tmproom[nrooms] = New(room);
  1286. X            (void) memset((genericptr_t) tmproom[nrooms], 0,
  1287. X                    sizeof *tmproom[nrooms]);
  1288. X            tmproom[nrooms]->name = (char *) 0;
  1289. X            tmproom[nrooms]->parent = (char *) 0;
  1290. X            tmproom[nrooms]->rtype = yypvt[-9].i;
  1291. X            tmproom[nrooms]->rlit = yypvt[-7].i;
  1292. X            tmproom[nrooms]->filled = yypvt[-0].i;
  1293. X            tmproom[nrooms]->xalign = current_align.x;
  1294. X            tmproom[nrooms]->yalign = current_align.y;
  1295. X            tmproom[nrooms]->x = current_coord.x;
  1296. X            tmproom[nrooms]->y = current_coord.y;
  1297. X            tmproom[nrooms]->w = current_size.width;
  1298. X            tmproom[nrooms]->h = current_size.height;
  1299. X            in_room = 1;
  1300. X          } break;
  1301. Xcase 41:
  1302. X# line 496 "lev_comp.y"
  1303. X{
  1304. X            yyval.i = 1;
  1305. X          } break;
  1306. Xcase 42:
  1307. X# line 500 "lev_comp.y"
  1308. X{
  1309. X            yyval.i = yypvt[-0].i;
  1310. X          } break;
  1311. Xcase 43:
  1312. X# line 506 "lev_comp.y"
  1313. X{
  1314. X            if ( yypvt[-3].i < 1 || yypvt[-3].i > 5 ||
  1315. X                yypvt[-1].i < 1 || yypvt[-1].i > 5 ) {
  1316. X                yyerror("Room position should be between 1 & 5!");
  1317. X            } else {
  1318. X                current_coord.x = yypvt[-3].i;
  1319. X                current_coord.y = yypvt[-1].i;
  1320. X            }
  1321. X          } break;
  1322. Xcase 44:
  1323. X# line 516 "lev_comp.y"
  1324. X{
  1325. X            current_coord.x = current_coord.y = ERR;
  1326. X          } break;
  1327. Xcase 45:
  1328. X# line 522 "lev_comp.y"
  1329. X{
  1330. X            if ( yypvt[-3].i < 0 || yypvt[-1].i < 0) {
  1331. X                yyerror("Invalid subroom position !");
  1332. X            } else {
  1333. X                current_coord.x = yypvt[-3].i;
  1334. X                current_coord.y = yypvt[-1].i;
  1335. X            }
  1336. X          } break;
  1337. Xcase 46:
  1338. X# line 531 "lev_comp.y"
  1339. X{
  1340. X            current_coord.x = current_coord.y = ERR;
  1341. X          } break;
  1342. Xcase 47:
  1343. X# line 537 "lev_comp.y"
  1344. X{
  1345. X            current_align.x = yypvt[-3].i;
  1346. X            current_align.y = yypvt[-1].i;
  1347. X          } break;
  1348. Xcase 48:
  1349. X# line 542 "lev_comp.y"
  1350. X{
  1351. X            current_align.x = current_align.y = ERR;
  1352. X          } break;
  1353. Xcase 49:
  1354. X# line 548 "lev_comp.y"
  1355. X{
  1356. X            current_size.width = yypvt[-3].i;
  1357. X            current_size.height = yypvt[-1].i;
  1358. X          } break;
  1359. Xcase 50:
  1360. X# line 553 "lev_comp.y"
  1361. X{
  1362. X            current_size.height = current_size.width = ERR;
  1363. X          } break;
  1364. Xcase 66:
  1365. X# line 578 "lev_comp.y"
  1366. X{
  1367. X            if (tmproom[nrooms]->name)
  1368. X                yyerror("This room already has a name!");
  1369. X            else
  1370. X                tmproom[nrooms]->name = dup_string(yypvt[-0].map);
  1371. X          } break;
  1372. Xcase 67:
  1373. X# line 587 "lev_comp.y"
  1374. X{
  1375. X            if (tmproom[nrooms]->chance)
  1376. X                yyerror("This room already assigned a chance!");
  1377. X            else if (tmproom[nrooms]->rtype == OROOM)
  1378. X                yyerror("Only typed rooms can have a chance!");
  1379. X            else if (yypvt[-0].i < 1 || yypvt[-0].i > 99)
  1380. X                yyerror("The chance is supposed to be precentile.");
  1381. X            else
  1382. X                tmproom[nrooms]->chance = yypvt[-0].i;
  1383. X           } break;
  1384. Xcase 68:
  1385. X# line 600 "lev_comp.y"
  1386. X{
  1387. X            /* ERR means random here */
  1388. X            if (yypvt[-2].i == ERR && yypvt[-0].i != ERR) {
  1389. X             yyerror("If the door wall is random, so must be its pos!");
  1390. X            } else {
  1391. X                tmprdoor[ndoor] = New(room_door);
  1392. X                tmprdoor[ndoor]->secret = yypvt[-6].i;
  1393. X                tmprdoor[ndoor]->mask = yypvt[-4].i;
  1394. X                tmprdoor[ndoor]->wall = yypvt[-2].i;
  1395. X                tmprdoor[ndoor]->pos = yypvt[-0].i;
  1396. X                ndoor++;
  1397. X            }
  1398. X          } break;
  1399. Xcase 75:
  1400. X# line 628 "lev_comp.y"
  1401. X{
  1402. X            maze.filling = yypvt[-0].i;
  1403. X            if (index(yypvt[-2].map, '.'))
  1404. X                yyerror("Invalid dot ('.') in level name.");
  1405. X            if (strlen(yypvt[-2].map) > 8)
  1406. X                yyerror("Level names limited to 8 characters.");
  1407. X            yyval.map = yypvt[-2].map;
  1408. X            in_room = 0;
  1409. X          } break;
  1410. Xcase 76:
  1411. X# line 640 "lev_comp.y"
  1412. X{
  1413. X            yyval.i = get_floor_type((char)yypvt[-0].i);
  1414. X          } break;
  1415. Xcase 77:
  1416. X# line 644 "lev_comp.y"
  1417. X{
  1418. X            yyval.i = -1;
  1419. X          } break;
  1420. Xcase 80:
  1421. X# line 654 "lev_comp.y"
  1422. X{
  1423. X            store_part();
  1424. X          } break;
  1425. Xcase 81:
  1426. X# line 660 "lev_comp.y"
  1427. X{
  1428. X            tmppart[npart] = New(mazepart);
  1429. X            tmppart[npart]->halign = 1;
  1430. X            tmppart[npart]->valign = 1;
  1431. X            tmppart[npart]->nrobjects = 0;
  1432. X            tmppart[npart]->nloc = 0;
  1433. X            tmppart[npart]->nrmonst = 0;
  1434. X            tmppart[npart]->xsize = 1;
  1435. X            tmppart[npart]->ysize = 1;
  1436. X            tmppart[npart]->map = (char **) alloc(sizeof(char *));
  1437. X            tmppart[npart]->map[0] = (char *) alloc(1);
  1438. X            tmppart[npart]->map[0][0] = STONE;
  1439. X            max_x_map = COLNO-1;
  1440. X            max_y_map = ROWNO;
  1441. X          } break;
  1442. Xcase 82:
  1443. X# line 676 "lev_comp.y"
  1444. X{
  1445. X            tmppart[npart] = New(mazepart);
  1446. X            tmppart[npart]->halign = yypvt[-1].i % 10;
  1447. X            tmppart[npart]->valign = yypvt[-1].i / 10;
  1448. X            tmppart[npart]->nrobjects = 0;
  1449. X            tmppart[npart]->nloc = 0;
  1450. X            tmppart[npart]->nrmonst = 0;
  1451. X            scan_map(yypvt[-0].map);
  1452. X          } break;
  1453. Xcase 83:
  1454. X# line 688 "lev_comp.y"
  1455. X{
  1456. X            yyval.i = yypvt[-2].i + (yypvt[-0].i * 10);
  1457. X          } break;
  1458. Xcase 90:
  1459. X# line 706 "lev_comp.y"
  1460. X{
  1461. X            if (tmppart[npart]->nrobjects) {
  1462. X                yyerror("Object registers already initialized!");
  1463. X            } else {
  1464. X                tmppart[npart]->robjects = (char *)alloc(n_olist);
  1465. X                (void) memcpy((genericptr_t)tmppart[npart]->robjects,
  1466. X                      (genericptr_t)olist, n_olist);
  1467. X                tmppart[npart]->nrobjects = n_olist;
  1468. X            }
  1469. X          } break;
  1470. Xcase 91:
  1471. X# line 717 "lev_comp.y"
  1472. X{
  1473. X            if (tmppart[npart]->nloc) {
  1474. X                yyerror("Location registers already initialized!");
  1475. X            } else {
  1476. X                register int i;
  1477. X                tmppart[npart]->rloc_x = (char *) alloc(n_plist);
  1478. X                tmppart[npart]->rloc_y = (char *) alloc(n_plist);
  1479. X                for(i=0;i<n_plist;i++) {
  1480. X                tmppart[npart]->rloc_x[i] = plist[i].x;
  1481. X                tmppart[npart]->rloc_y[i] = plist[i].y;
  1482. X                }
  1483. X                tmppart[npart]->nloc = n_plist;
  1484. X            }
  1485. X          } break;
  1486. Xcase 92:
  1487. X# line 732 "lev_comp.y"
  1488. X{
  1489. X            if (tmppart[npart]->nrmonst) {
  1490. X                yyerror("Monster registers already initialized!");
  1491. X            } else {
  1492. X                tmppart[npart]->rmonst = (char *) alloc(n_mlist);
  1493. X                (void) memcpy((genericptr_t)tmppart[npart]->rmonst,
  1494. X                      (genericptr_t)mlist, n_mlist);
  1495. X                tmppart[npart]->nrmonst = n_mlist;
  1496. X            }
  1497. X          } break;
  1498. Xcase 93:
  1499. X# line 745 "lev_comp.y"
  1500. X{
  1501. X            if (n_olist < MAX_REGISTERS)
  1502. X                olist[n_olist++] = yypvt[-0].i;
  1503. X            else
  1504. X                yyerror("Object list too long!");
  1505. X          } break;
  1506. Xcase 94:
  1507. X# line 752 "lev_comp.y"
  1508. X{
  1509. X            if (n_olist < MAX_REGISTERS)
  1510. X                olist[n_olist++] = yypvt[-2].i;
  1511. X            else
  1512. X                yyerror("Object list too long!");
  1513. X          } break;
  1514. Xcase 95:
  1515. X# line 761 "lev_comp.y"
  1516. X{
  1517. X            if (n_mlist < MAX_REGISTERS)
  1518. X                mlist[n_mlist++] = yypvt[-0].i;
  1519. X            else
  1520. X                yyerror("Monster list too long!");
  1521. X          } break;
  1522. Xcase 96:
  1523. X# line 768 "lev_comp.y"
  1524. X{
  1525. X            if (n_mlist < MAX_REGISTERS)
  1526. X                mlist[n_mlist++] = yypvt[-2].i;
  1527. X            else
  1528. X                yyerror("Monster list too long!");
  1529. X          } break;
  1530. Xcase 97:
  1531. X# line 777 "lev_comp.y"
  1532. X{
  1533. X            if (n_plist < MAX_REGISTERS)
  1534. X                plist[n_plist++] = current_coord;
  1535. X            else
  1536. X                yyerror("Location list too long!");
  1537. X          } break;
  1538. Xcase 98:
  1539. X# line 784 "lev_comp.y"
  1540. X{
  1541. X            if (n_plist < MAX_REGISTERS)
  1542. X                plist[n_plist++] = current_coord;
  1543. X            else
  1544. X                yyerror("Location list too long!");
  1545. X          } break;
  1546. Xcase 121:
  1547. X# line 819 "lev_comp.y"
  1548. X{
  1549. X            tmpmonst[nmons] = New(monster);
  1550. X            tmpmonst[nmons]->x = current_coord.x;
  1551. X            tmpmonst[nmons]->y = current_coord.y;
  1552. X            tmpmonst[nmons]->class = yypvt[-4].i;
  1553. X            tmpmonst[nmons]->peaceful = -1; /* no override */
  1554. X            tmpmonst[nmons]->asleep = -1;
  1555. X            tmpmonst[nmons]->align = - MAX_REGISTERS - 2;
  1556. X            tmpmonst[nmons]->name = (char *) 0;
  1557. X            tmpmonst[nmons]->appear = 0;
  1558. X            tmpmonst[nmons]->appear_as = (char *) 0;
  1559. X            if (!in_room)
  1560. X                check_coord(current_coord.x, current_coord.y,
  1561. X                    "Monster");
  1562. X            if (!yypvt[-2].map)
  1563. X                tmpmonst[nmons]->id = -1;
  1564. X            else {
  1565. X                int token = get_monster_id(yypvt[-2].map, (char) yypvt[-4].i);
  1566. X                if (token == ERR) {
  1567. X                    yywarning("Illegal monster name!  Making random monster.");
  1568. X                    tmpmonst[nmons]->id = -1;
  1569. X                } else
  1570. X                    tmpmonst[nmons]->id = token;
  1571. X            }
  1572. X          } break;
  1573. Xcase 122:
  1574. X# line 845 "lev_comp.y"
  1575. X{
  1576. X            nmons++;
  1577. X          } break;
  1578. Xcase 125:
  1579. X# line 855 "lev_comp.y"
  1580. X{
  1581. X            tmpmonst[nmons]->name = dup_string(yypvt[-0].map);
  1582. X          } break;
  1583. Xcase 126:
  1584. X# line 859 "lev_comp.y"
  1585. X{
  1586. X            tmpmonst[nmons]->peaceful = yypvt[-0].i;
  1587. X          } break;
  1588. Xcase 127:
  1589. X# line 863 "lev_comp.y"
  1590. X{
  1591. X            tmpmonst[nmons]->asleep = yypvt[-0].i;
  1592. X          } break;
  1593. Xcase 128:
  1594. X# line 867 "lev_comp.y"
  1595. X{
  1596. X            tmpmonst[nmons]->align = yypvt[-0].i;
  1597. X          } break;
  1598. Xcase 129:
  1599. X# line 871 "lev_comp.y"
  1600. X{
  1601. X            tmpmonst[nmons]->appear = yypvt[-1].i;
  1602. X            tmpmonst[nmons]->appear_as = dup_string(yypvt[-0].map);
  1603. X          } break;
  1604. Xcase 130:
  1605. X# line 878 "lev_comp.y"
  1606. X{
  1607. X            tmpobj[nobj] = New(object);
  1608. X            tmpobj[nobj]->x = current_coord.x;
  1609. X            tmpobj[nobj]->y = current_coord.y;
  1610. X            tmpobj[nobj]->class = yypvt[-4].i;
  1611. X            tmpobj[nobj]->corpsenm = -1;    /* init as none */
  1612. X            tmpobj[nobj]->curse_state = -1;
  1613. X            tmpobj[nobj]->name = (char *) 0;
  1614. X            if (!in_room)
  1615. X                check_coord(current_coord.x, current_coord.y,
  1616. X                    "Object");
  1617. X            if (!yypvt[-2].map)
  1618. X                tmpobj[nobj]->id = -1;
  1619. X            else {
  1620. X                int token = get_object_id(yypvt[-2].map);
  1621. X                if (token == ERR) {
  1622. X                    yywarning("Illegal object name!  Making random object.");
  1623. X                    tmpobj[nobj]->id = -1;
  1624. X                } else
  1625. X                    tmpobj[nobj]->id = token;
  1626. X            }
  1627. X          } break;
  1628. Xcase 131:
  1629. X# line 901 "lev_comp.y"
  1630. X{
  1631. X            nobj++;
  1632. X          } break;
  1633. Xcase 132:
  1634. X# line 907 "lev_comp.y"
  1635. X{
  1636. X            tmpobj[nobj]->spe = -127;
  1637. X          } break;
  1638. Xcase 133:
  1639. X# line 911 "lev_comp.y"
  1640. X{
  1641. X            int token = get_monster_id(yypvt[-2].map, (char)0);
  1642. X            if (token == ERR)    /* "random" */
  1643. X                tmpobj[nobj]->corpsenm = -2;
  1644. X            else
  1645. X                tmpobj[nobj]->corpsenm = token;
  1646. X            tmpobj[nobj]->spe = yypvt[-0].i;
  1647. X          } break;
  1648. Xcase 134:
  1649. X# line 920 "lev_comp.y"
  1650. X{
  1651. X            tmpobj[nobj]->curse_state = yypvt[-4].i;
  1652. X            tmpobj[nobj]->spe = yypvt[-2].i;
  1653. X            if (yypvt[-0].map)
  1654. X                tmpobj[nobj]->name = dup_string(yypvt[-0].map);
  1655. X            else
  1656. X                tmpobj[nobj]->name = (char *) 0;
  1657. X          } break;
  1658. Xcase 138:
  1659. X# line 936 "lev_comp.y"
  1660. X{
  1661. X            yyval.i = -127;
  1662. X          } break;
  1663. Xcase 139:
  1664. X# line 942 "lev_comp.y"
  1665. X{
  1666. X            tmpdoor[ndoor] = New(door);
  1667. X            tmpdoor[ndoor]->x = current_coord.x;
  1668. X            tmpdoor[ndoor]->y = current_coord.y;
  1669. X            tmpdoor[ndoor]->mask = yypvt[-2].i;
  1670. X            if(current_coord.x >= 0 && current_coord.y >= 0 &&
  1671. X               tmpmap[current_coord.y][current_coord.x] != DOOR &&
  1672. X               tmpmap[current_coord.y][current_coord.x] != SDOOR)
  1673. X                yyerror("Door decl doesn't match the map");
  1674. X            ndoor++;
  1675. X          } break;
  1676. Xcase 140:
  1677. X# line 956 "lev_comp.y"
  1678. X{
  1679. X            tmptrap[ntrap] = New(trap);
  1680. X            tmptrap[ntrap]->x = current_coord.x;
  1681. X            tmptrap[ntrap]->y = current_coord.y;
  1682. X            tmptrap[ntrap]->type = yypvt[-2].i;
  1683. X            if (!in_room)
  1684. X                check_coord(current_coord.x, current_coord.y,
  1685. X                    "Trap");
  1686. X            ntrap++;
  1687. X          } break;
  1688. Xcase 141:
  1689. X# line 969 "lev_comp.y"
  1690. X{
  1691. X                int x, y, dir;
  1692. X
  1693. X            tmpdb[ndb] = New(drawbridge);
  1694. X            x = tmpdb[ndb]->x = current_coord.x;
  1695. X            y = tmpdb[ndb]->y = current_coord.y;
  1696. X            /* convert dir from a DIRECTION to a DB_DIR */
  1697. X            dir = yypvt[-2].i;
  1698. X            switch(dir) {
  1699. X            case W_NORTH: dir = DB_NORTH; y--; break;
  1700. X            case W_SOUTH: dir = DB_SOUTH; y++; break;
  1701. X            case W_EAST:  dir = DB_EAST;  x++; break;
  1702. X            case W_WEST:  dir = DB_WEST;  x--; break;
  1703. X            default:
  1704. X                yyerror("Invalid drawbridge direction");
  1705. X                break;
  1706. X            }
  1707. X            tmpdb[ndb]->dir = dir;
  1708. X            if (current_coord.x >= 0 && current_coord.y >= 0 &&
  1709. X                !IS_WALL(tmpmap[y][x])) {
  1710. X                char ebuf[60];
  1711. X                Sprintf(ebuf,
  1712. X                    "Wall needed for drawbridge (%02d, %02d)",
  1713. X                    current_coord.x, current_coord.y);
  1714. X                yyerror(ebuf);
  1715. X            }
  1716. X
  1717. X            if ( yypvt[-0].i == D_ISOPEN )
  1718. X                tmpdb[ndb]->db_open = 1;
  1719. X            else if ( yypvt[-0].i == D_CLOSED )
  1720. X                tmpdb[ndb]->db_open = 0;
  1721. X            else
  1722. X                yyerror("A drawbridge can only be open or closed!");
  1723. X            ndb++;
  1724. X           } break;
  1725. Xcase 142:
  1726. X# line 1007 "lev_comp.y"
  1727. X{
  1728. X            tmpwalk[nwalk] = New(walk);
  1729. X            tmpwalk[nwalk]->x = current_coord.x;
  1730. X            tmpwalk[nwalk]->y = current_coord.y;
  1731. X            tmpwalk[nwalk]->dir = yypvt[-0].i;
  1732. X            nwalk++;
  1733. X          } break;
  1734. Xcase 143:
  1735. X# line 1017 "lev_comp.y"
  1736. X{
  1737. X            wallify_map();
  1738. X          } break;
  1739. Xcase 144:
  1740. X# line 1023 "lev_comp.y"
  1741. X{
  1742. X            tmplad[nlad] = New(lad);
  1743. X            tmplad[nlad]->x = current_coord.x;
  1744. X            tmplad[nlad]->y = current_coord.y;
  1745. X            tmplad[nlad]->up = yypvt[-0].i;
  1746. X            if (!in_room)
  1747. X                check_coord(current_coord.x, current_coord.y,
  1748. X                    "Ladder");
  1749. X            nlad++;
  1750. X          } break;
  1751. Xcase 145:
  1752. X# line 1036 "lev_comp.y"
  1753. X{
  1754. X            tmpstair[nstair] = New(stair);
  1755. X            tmpstair[nstair]->x = current_coord.x;
  1756. X            tmpstair[nstair]->y = current_coord.y;
  1757. X            tmpstair[nstair]->up = yypvt[-0].i;
  1758. X            if (!in_room)
  1759. X                check_coord(current_coord.x, current_coord.y,
  1760. X                    "Stairway");
  1761. X            nstair++;
  1762. X          } break;
  1763. Xcase 146:
  1764. X# line 1049 "lev_comp.y"
  1765. X{
  1766. X            tmplreg[nlreg] = New(lev_region);
  1767. X            tmplreg[nlreg]->in_islev = yypvt[-0].i;
  1768. X            tmplreg[nlreg]->inarea.x1 = current_region.x1;
  1769. X            tmplreg[nlreg]->inarea.y1 = current_region.y1;
  1770. X            tmplreg[nlreg]->inarea.x2 = current_region.x2;
  1771. X            tmplreg[nlreg]->inarea.y2 = current_region.y2;
  1772. X          } break;
  1773. Xcase 147:
  1774. X# line 1058 "lev_comp.y"
  1775. X{
  1776. X            tmplreg[nlreg]->del_islev = yypvt[-2].i;
  1777. X            tmplreg[nlreg]->delarea.x1 = current_region.x1;
  1778. X            tmplreg[nlreg]->delarea.y1 = current_region.y1;
  1779. X            tmplreg[nlreg]->delarea.x2 = current_region.x2;
  1780. X            tmplreg[nlreg]->delarea.y2 = current_region.y2;
  1781. X            if(yypvt[-0].i)
  1782. X                tmplreg[nlreg]->rtype = LR_UPSTAIR;
  1783. X            else
  1784. X                tmplreg[nlreg]->rtype = LR_DOWNSTAIR;
  1785. X            tmplreg[nlreg]->rname = 0;
  1786. X            nlreg++;
  1787. X          } break;
  1788. Xcase 148:
  1789. X# line 1074 "lev_comp.y"
  1790. X{
  1791. X            tmplreg[nlreg] = New(lev_region);
  1792. X            tmplreg[nlreg]->in_islev = yypvt[-0].i;
  1793. X            tmplreg[nlreg]->inarea.x1 = current_region.x1;
  1794. X            tmplreg[nlreg]->inarea.y1 = current_region.y1;
  1795. X            tmplreg[nlreg]->inarea.x2 = current_region.x2;
  1796. X            tmplreg[nlreg]->inarea.y2 = current_region.y2;
  1797. X          } break;
  1798. Xcase 149:
  1799. X# line 1083 "lev_comp.y"
  1800. X{
  1801. X            tmplreg[nlreg]->del_islev = yypvt[-2].i;
  1802. X            tmplreg[nlreg]->delarea.x1 = current_region.x1;
  1803. X            tmplreg[nlreg]->delarea.y1 = current_region.y1;
  1804. X            tmplreg[nlreg]->delarea.x2 = current_region.x2;
  1805. X            tmplreg[nlreg]->delarea.y2 = current_region.y2;
  1806. X            tmplreg[nlreg]->rtype = LR_PORTAL;
  1807. X            tmplreg[nlreg]->rname = yypvt[-0].map;
  1808. X            nlreg++;
  1809. X          } break;
  1810. Xcase 150:
  1811. X# line 1096 "lev_comp.y"
  1812. X{
  1813. X            tmplreg[nlreg] = New(lev_region);
  1814. X            tmplreg[nlreg]->in_islev = yypvt[-0].i;
  1815. X            tmplreg[nlreg]->inarea.x1 = current_region.x1;
  1816. X            tmplreg[nlreg]->inarea.y1 = current_region.y1;
  1817. X            tmplreg[nlreg]->inarea.x2 = current_region.x2;
  1818. X            tmplreg[nlreg]->inarea.y2 = current_region.y2;
  1819. X          } break;
  1820. Xcase 151:
  1821. X# line 1105 "lev_comp.y"
  1822. X{
  1823. X            tmplreg[nlreg]->del_islev = yypvt[-0].i;
  1824. X            tmplreg[nlreg]->delarea.x1 = current_region.x1;
  1825. X            tmplreg[nlreg]->delarea.y1 = current_region.y1;
  1826. X            tmplreg[nlreg]->delarea.x2 = current_region.x2;
  1827. X            tmplreg[nlreg]->delarea.y2 = current_region.y2;
  1828. X          } break;
  1829. Xcase 152:
  1830. X# line 1113 "lev_comp.y"
  1831. X{
  1832. X            switch(yypvt[-0].i) {
  1833. X            case -1: tmplreg[nlreg]->rtype = LR_TELE; break;
  1834. X            case 0: tmplreg[nlreg]->rtype = LR_DOWNTELE; break;
  1835. X            case 1: tmplreg[nlreg]->rtype = LR_UPTELE; break;
  1836. X            }
  1837. X            tmplreg[nlreg]->rname = 0;
  1838. X            nlreg++;
  1839. X          } break;
  1840. Xcase 153:
  1841. X# line 1125 "lev_comp.y"
  1842. X{
  1843. X            tmplreg[nlreg] = New(lev_region);
  1844. X            tmplreg[nlreg]->in_islev = yypvt[-0].i;
  1845. X            tmplreg[nlreg]->inarea.x1 = current_region.x1;
  1846. X            tmplreg[nlreg]->inarea.y1 = current_region.y1;
  1847. X            tmplreg[nlreg]->inarea.x2 = current_region.x2;
  1848. X            tmplreg[nlreg]->inarea.y2 = current_region.y2;
  1849. X          } break;
  1850. Xcase 154:
  1851. X# line 1134 "lev_comp.y"
  1852. X{
  1853. X            tmplreg[nlreg]->del_islev = yypvt[-0].i;
  1854. X            tmplreg[nlreg]->delarea.x1 = current_region.x1;
  1855. X            tmplreg[nlreg]->delarea.y1 = current_region.y1;
  1856. X            tmplreg[nlreg]->delarea.x2 = current_region.x2;
  1857. X            tmplreg[nlreg]->delarea.y2 = current_region.y2;
  1858. X            tmplreg[nlreg]->rtype = LR_BRANCH;
  1859. X            tmplreg[nlreg]->rname = 0;
  1860. X            nlreg++;
  1861. X          } break;
  1862. Xcase 155:
  1863. X# line 1147 "lev_comp.y"
  1864. X{
  1865. X            yyval.i = -1;
  1866. X          } break;
  1867. Xcase 156:
  1868. X# line 1151 "lev_comp.y"
  1869. X{
  1870. X            yyval.i = yypvt[-0].i;
  1871. X          } break;
  1872. Xcase 157:
  1873. X# line 1157 "lev_comp.y"
  1874. X{
  1875. X            yyval.i = 0;
  1876. X          } break;
  1877. Xcase 158:
  1878. X# line 1161 "lev_comp.y"
  1879. X{
  1880. X/* This series of if statements is a hack for MSC 5.1.  It seems that its
  1881. X   tiny little brain cannot compile if these are all one big if statement. */
  1882. X            if (yypvt[-7].i <= 0 || yypvt[-7].i >= COLNO)
  1883. X                yyerror("Region out of level range!");
  1884. X            else if (yypvt[-5].i < 0 || yypvt[-5].i >= ROWNO)
  1885. X                yyerror("Region out of level range!");
  1886. X            else if (yypvt[-3].i <= 0 || yypvt[-3].i >= COLNO)
  1887. X                yyerror("Region out of level range!");
  1888. X            else if (yypvt[-1].i < 0 || yypvt[-1].i >= ROWNO)
  1889. X                yyerror("Region out of level range!");
  1890. X            current_region.x1 = yypvt[-7].i;
  1891. X            current_region.y1 = yypvt[-5].i;
  1892. X            current_region.x2 = yypvt[-3].i;
  1893. X            current_region.y2 = yypvt[-1].i;
  1894. X            yyval.i = 1;
  1895. X          } break;
  1896. Xcase 159:
  1897. X# line 1181 "lev_comp.y"
  1898. X{
  1899. X            tmpfountain[nfountain] = New(fountain);
  1900. X            tmpfountain[nfountain]->x = current_coord.x;
  1901. X            tmpfountain[nfountain]->y = current_coord.y;
  1902. X            if (!in_room)
  1903. X                check_coord(current_coord.x, current_coord.y,
  1904. X                    "Fountain");
  1905. X            nfountain++;
  1906. X          } break;
  1907. Xcase 160:
  1908. X# line 1193 "lev_comp.y"
  1909. X{
  1910. X            tmpsink[nsink] = New(sink);
  1911. X            tmpsink[nsink]->x = current_coord.x;
  1912. X            tmpsink[nsink]->y = current_coord.y;
  1913. X            nsink++;
  1914. X          } break;
  1915. Xcase 161:
  1916. X# line 1202 "lev_comp.y"
  1917. X{
  1918. X            tmppool[npool] = New(pool);
  1919. X            tmppool[npool]->x = current_coord.x;
  1920. X            tmppool[npool]->y = current_coord.y;
  1921. X            npool++;
  1922. X          } break;
  1923. Xcase 162:
  1924. X# line 1211 "lev_comp.y"
  1925. X{
  1926. X            tmpdig[ndig] = New(digpos);
  1927. X            tmpdig[ndig]->x1 = current_region.x1;
  1928. X            tmpdig[ndig]->y1 = current_region.y1;
  1929. X            tmpdig[ndig]->x2 = current_region.x2;
  1930. X            tmpdig[ndig]->y2 = current_region.y2;
  1931. X            ndig++;
  1932. X          } break;
  1933. Xcase 163:
  1934. X# line 1222 "lev_comp.y"
  1935. X{
  1936. X            tmpreg[nreg] = New(region);
  1937. X            tmpreg[nreg]->x1 = current_region.x1;
  1938. X            tmpreg[nreg]->y1 = current_region.y1;
  1939. X            tmpreg[nreg]->x2 = current_region.x2;
  1940. X            tmpreg[nreg]->y2 = current_region.y2;
  1941. X            tmpreg[nreg]->rlit = yypvt[-3].i;
  1942. X            tmpreg[nreg]->rtype = yypvt[-1].i;
  1943. X            if(yypvt[-0].i & 1) tmpreg[nreg]->rtype += MAXRTYPE+1;
  1944. X            tmpreg[nreg]->rirreg = ((yypvt[-0].i & 2) != 0);
  1945. X            if(current_region.x1 > current_region.x2 ||
  1946. X               current_region.y1 > current_region.y2)
  1947. X               yyerror("Region start > end!");
  1948. X            if(tmpreg[nreg]->rtype == VAULT &&
  1949. X               (tmpreg[nreg]->rirreg ||
  1950. X                (tmpreg[nreg]->x2 - tmpreg[nreg]->x1 != 1) ||
  1951. X                (tmpreg[nreg]->y2 - tmpreg[nreg]->y1 != 1)))
  1952. X                yyerror("Vaults must be exactly 2x2!");
  1953. X            if(want_warnings && !tmpreg[nreg]->rirreg &&
  1954. X               current_region.x1 > 0 && current_region.y1 > 0 &&
  1955. X               current_region.x2 < max_x_map &&
  1956. X               current_region.y2 < max_y_map) {
  1957. X                /* check for walls in the room */
  1958. X                char ebuf[60];
  1959. X                register int x, y, nrock = 0;
  1960. X
  1961. X                for(y=current_region.y1; y<=current_region.y2; y++)
  1962. X                for(x=current_region.x1;
  1963. X                    x<=current_region.x2; x++)
  1964. X                    if(IS_ROCK(tmpmap[y][x]) ||
  1965. X                       IS_DOOR(tmpmap[y][x])) nrock++;
  1966. X                if(nrock) {
  1967. X                Sprintf(ebuf,
  1968. X                    "Rock in room (%02d,%02d,%02d,%02d)?!",
  1969. X                    current_region.x1, current_region.y1,
  1970. X                    current_region.x2, current_region.y2);
  1971. X                yywarning(ebuf);
  1972. X                }
  1973. X                if (
  1974. X        !IS_ROCK(tmpmap[current_region.y1-1][current_region.x1-1]) ||
  1975. X        !IS_ROCK(tmpmap[current_region.y2+1][current_region.x1-1]) ||
  1976. X        !IS_ROCK(tmpmap[current_region.y1-1][current_region.x2+1]) ||
  1977. X        !IS_ROCK(tmpmap[current_region.y2+1][current_region.x2+1])) {
  1978. X                Sprintf(ebuf,
  1979. X                "NonRock edge in room (%02d,%02d,%02d,%02d)?!",
  1980. X                    current_region.x1, current_region.y1,
  1981. X                    current_region.x2, current_region.y2);
  1982. X                yywarning(ebuf);
  1983. X                }
  1984. X            } else if(tmpreg[nreg]->rirreg &&
  1985. X        !IS_ROOM(tmpmap[current_region.y1][current_region.x1])) {
  1986. X                char ebuf[60];
  1987. X                Sprintf(ebuf,
  1988. X                    "Rock in irregular room (%02d,%02d)?!",
  1989. X                    current_region.x1, current_region.y1);
  1990. X                yyerror(ebuf);
  1991. X            }
  1992. X            nreg++;
  1993. X          } break;
  1994. Xcase 164:
  1995. X# line 1284 "lev_comp.y"
  1996. X{
  1997. X            tmpaltar[naltar] = New(altar);
  1998. X            tmpaltar[naltar]->x = current_coord.x;
  1999. X            tmpaltar[naltar]->y = current_coord.y;
  2000. X            tmpaltar[naltar]->align = yypvt[-2].i;
  2001. X            tmpaltar[naltar]->shrine = yypvt[-0].i;
  2002. X            if (!in_room)
  2003. X                check_coord(current_coord.x, current_coord.y,
  2004. X                    "Altar");
  2005. X            naltar++;
  2006. X          } break;
  2007. Xcase 165:
  2008. X# line 1298 "lev_comp.y"
  2009. X{
  2010. X            tmpgold[ngold] = New(gold);
  2011. X            tmpgold[ngold]->x = current_coord.x;
  2012. X            tmpgold[ngold]->y = current_coord.y;
  2013. X            tmpgold[ngold]->amount = yypvt[-2].i;
  2014. X            if (!in_room)
  2015. X                check_coord(current_coord.x, current_coord.y,
  2016. X                    "Gold");
  2017. X            ngold++;
  2018. X          } break;
  2019. Xcase 166:
  2020. X# line 1311 "lev_comp.y"
  2021. X{
  2022. X            tmpengraving[nengraving] = New(engraving);
  2023. X            tmpengraving[nengraving]->x = current_coord.x;
  2024. X            tmpengraving[nengraving]->y = current_coord.y;
  2025. X            tmpengraving[nengraving]->e.text = yypvt[-0].map;
  2026. X            tmpengraving[nengraving]->etype = yypvt[-2].i;
  2027. X            if (!in_room)
  2028. X                check_coord(current_coord.x, current_coord.y,
  2029. X                    "Engraving");
  2030. X            nengraving++;
  2031. X          } break;
  2032. Xcase 168:
  2033. X# line 1326 "lev_comp.y"
  2034. X{
  2035. X            yyval.i = - MAX_REGISTERS - 1;
  2036. X          } break;
  2037. Xcase 171:
  2038. X# line 1334 "lev_comp.y"
  2039. X{
  2040. X            yyval.i = - MAX_REGISTERS - 1;
  2041. X          } break;
  2042. Xcase 174:
  2043. X# line 1342 "lev_comp.y"
  2044. X{
  2045. X            yyval.map = (char *) 0;
  2046. X          } break;
  2047. Xcase 176:
  2048. X# line 1349 "lev_comp.y"
  2049. X{
  2050. X            yyval.map = (char *) 0;
  2051. X          } break;
  2052. Xcase 177:
  2053. X# line 1355 "lev_comp.y"
  2054. X{
  2055. X            int token = get_trap_type(yypvt[-0].map);
  2056. X            if (token == ERR)
  2057. X                yyerror("Unknown trap type!");
  2058. X            yyval.i = token;
  2059. X          } break;
  2060. Xcase 179:
  2061. X# line 1365 "lev_comp.y"
  2062. X{
  2063. X            int token = get_room_type(yypvt[-0].map);
  2064. X            if (token == ERR) {
  2065. X                yywarning("Unknown room type!  Making ordinary room...");
  2066. X                yyval.i = OROOM;
  2067. X            } else
  2068. X                yyval.i = token;
  2069. X          } break;
  2070. Xcase 181:
  2071. X# line 1377 "lev_comp.y"
  2072. X{
  2073. X            yyval.i = 0;
  2074. X          } break;
  2075. Xcase 182:
  2076. X# line 1381 "lev_comp.y"
  2077. X{
  2078. X            yyval.i = yypvt[-0].i;
  2079. X          } break;
  2080. Xcase 183:
  2081. X# line 1385 "lev_comp.y"
  2082. X{
  2083. X            yyval.i = yypvt[-2].i + (yypvt[-0].i << 1);
  2084. X          } break;
  2085. Xcase 186:
  2086. X# line 1393 "lev_comp.y"
  2087. X{
  2088. X            current_coord.x = current_coord.y = -MAX_REGISTERS-1;
  2089. X          } break;
  2090. Xcase 193:
  2091. X# line 1409 "lev_comp.y"
  2092. X{
  2093. X            yyval.i = - MAX_REGISTERS - 1;
  2094. X          } break;
  2095. Xcase 196:
  2096. X# line 1419 "lev_comp.y"
  2097. X{
  2098. X            if ( yypvt[-1].i >= MAX_REGISTERS )
  2099. X                yyerror("Register Index overflow!");
  2100. X            else
  2101. X                current_coord.x = current_coord.y = - yypvt[-1].i - 1;
  2102. X          } break;
  2103. Xcase 197:
  2104. X# line 1428 "lev_comp.y"
  2105. X{
  2106. X            if ( yypvt[-1].i >= MAX_REGISTERS )
  2107. X                yyerror("Register Index overflow!");
  2108. X            else
  2109. X                yyval.i = - yypvt[-1].i - 1;
  2110. X          } break;
  2111. Xcase 198:
  2112. X# line 1437 "lev_comp.y"
  2113. X{
  2114. X            if ( yypvt[-1].i >= MAX_REGISTERS )
  2115. X                yyerror("Register Index overflow!");
  2116. X            else
  2117. X                yyval.i = - yypvt[-1].i - 1;
  2118. X          } break;
  2119. Xcase 199:
  2120. X# line 1446 "lev_comp.y"
  2121. X{
  2122. X            if ( yypvt[-1].i >= 3 )
  2123. X                yyerror("Register Index overflow!");
  2124. X            else
  2125. X                yyval.i = - yypvt[-1].i - 1;
  2126. X          } break;
  2127. Xcase 201:
  2128. X# line 1458 "lev_comp.y"
  2129. X{
  2130. X            if (check_monster_char((char) yypvt[-0].i))
  2131. X                yyval.i = yypvt[-0].i ;
  2132. X            else {
  2133. X                yyerror("Unknown monster class!");
  2134. X                yyval.i = ERR;
  2135. X            }
  2136. X          } break;
  2137. Xcase 202:
  2138. X# line 1469 "lev_comp.y"
  2139. X{
  2140. X            char c = yypvt[-0].i;
  2141. X            if (check_object_char(c))
  2142. X                yyval.i = c;
  2143. X            else {
  2144. X                yyerror("Unknown char class!");
  2145. X                yyval.i = ERR;
  2146. X            }
  2147. X          } break;
  2148. Xcase 205:
  2149. X# line 1485 "lev_comp.y"
  2150. X{
  2151. X            yyval.map = (char *) 0;
  2152. X          } break;
  2153. Xcase 210:
  2154. X# line 1499 "lev_comp.y"
  2155. X{
  2156. X            if (!in_room && !init_lev.init_present &&
  2157. X                (yypvt[-3].i < 0 || yypvt[-3].i > max_x_map ||
  2158. X                 yypvt[-1].i < 0 || yypvt[-1].i > max_y_map))
  2159. X                yyerror("Coordinates out of map range!");
  2160. X            current_coord.x = yypvt[-3].i;
  2161. X            current_coord.y = yypvt[-1].i;
  2162. X          } break;
  2163. Xcase 211:
  2164. X# line 1510 "lev_comp.y"
  2165. X{
  2166. X/* This series of if statements is a hack for MSC 5.1.  It seems that its
  2167. X   tiny little brain cannot compile if these are all one big if statement. */
  2168. X            if (yypvt[-7].i < 0 || yypvt[-7].i > max_x_map)
  2169. X                yyerror("Region out of map range!");
  2170. X            else if (yypvt[-5].i < 0 || yypvt[-5].i > max_y_map)
  2171. X                yyerror("Region out of map range!");
  2172. X            else if (yypvt[-3].i < 0 || yypvt[-3].i > max_x_map)
  2173. X                yyerror("Region out of map range!");
  2174. X            else if (yypvt[-1].i < 0 || yypvt[-1].i > max_y_map)
  2175. X                yyerror("Region out of map range!");
  2176. X            current_region.x1 = yypvt[-7].i;
  2177. X            current_region.y1 = yypvt[-5].i;
  2178. X            current_region.x2 = yypvt[-3].i;
  2179. X            current_region.y2 = yypvt[-1].i;
  2180. X          } break;
  2181. X    }
  2182. X    goto yystack;        /* reset registers in driver code */
  2183. X}
  2184. END_OF_FILE
  2185. if test 30244 -ne `wc -c <'sys/share/lev_yacc.c2'`; then
  2186.     echo shar: \"'sys/share/lev_yacc.c2'\" unpacked with wrong size!
  2187. fi
  2188. # end of 'sys/share/lev_yacc.c2'
  2189. fi
  2190. echo shar: End of archive 72 \(of 108\).
  2191. cp /dev/null ark72isdone
  2192. MISSING=""
  2193. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
  2194. 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
  2195. 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
  2196. 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
  2197. 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 \
  2198. 101 102 103 104 105 106 107 108 ; do
  2199.     if test ! -f ark${I}isdone ; then
  2200.     MISSING="${MISSING} ${I}"
  2201.     fi
  2202. done
  2203. if test "${MISSING}" = "" ; then
  2204.     echo You have unpacked all 108 archives.
  2205.     echo "Now execute 'rebuild.sh'"
  2206.     rm -f ark10[0-8]isdone ark[1-9]isdone ark[1-9][0-9]isdone
  2207. else
  2208.     echo You still need to unpack the following archives:
  2209.     echo "        " ${MISSING}
  2210. fi
  2211. ##  End of shell archive.
  2212. exit 0
  2213.