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

  1. Path: uunet!news.tek.com!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v18i048:  nethack31 - display oriented dungeons & dragons (Ver. 3.1), Patch3o/18
  5. Date: 20 Jul 1993 22:33:33 GMT
  6. Organization: Tektronix, Inc, Redmond, OR, USA
  7. Lines: 2113
  8. Approved: billr@saab.CNA.TEK.COM
  9. Message-ID: <22hrrt$9q7@ying.cna.tek.com>
  10. NNTP-Posting-Host: saab.cna.tek.com
  11. Xref: uunet comp.sources.games:1848
  12.  
  13. Submitted-by: izchak@linc.cis.upenn.edu (Izchak Miller)
  14. Posting-number: Volume 18, Issue 48
  15. Archive-name: nethack31/patch3o
  16. Patch-To: nethack31: Volume 16, Issue 1-116
  17. Environment: Amiga, Atari, Mac, MS-DOS, Windows-NT, OS2, Unix, VMS, X11
  18.  
  19.  
  20.  
  21. #! /bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of archive 15 (of 18)."
  28. # Contents:  sys/mac/macmenu.c sys/share/dgn_yacc.c
  29. # Wrapped by billr@saab on Tue Jul 20 14:57:23 1993
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'sys/mac/macmenu.c' -a "${1}" != "-c" ; then 
  32.   echo shar: Renaming existing file \"'sys/mac/macmenu.c'\" to \"'sys/mac/macmenu.c.orig'\"
  33.   mv -f 'sys/mac/macmenu.c' 'sys/mac/macmenu.c.orig'
  34. fi
  35. echo shar: Extracting \"'sys/mac/macmenu.c'\" \(23678 characters\)
  36. sed "s/^X//" >'sys/mac/macmenu.c' <<'END_OF_FILE'
  37. X/*    SCCS Id: @(#)macmenu.c    3.1               93/04/29       */
  38. X/*      Copyright (c) Macintosh NetHack Port Team, 1993.          */
  39. X/* NetHack may be freely redistributed.  See license for details. */
  40. X
  41. X/****************************************\
  42. X * Extended Macintosh menu support
  43. X *
  44. X * provides access to all keyboard commands from cmd.c
  45. X * provides control key functionality for classic keyboards
  46. X * provides key equivalent references and logical menu groups
  47. X * supports various menu highlighting modes
  48. X * does not (yet) provide balloon help support (maybe never will!)
  49. X\****************************************/
  50. X
  51. X/****************************************\
  52. X * Edit History:
  53. X *
  54. X * 930512    - More bug fixes and getting tty to work again, Jon W{tte
  55. X * 930508    - Bug fixes in-flight, Jon W{tte
  56. X * 04/29/93 - 1st Release Draft, David Hairston
  57. X * 04/11/93 - 1st Draft, David Hairston
  58. X\****************************************/
  59. X
  60. X/******** Application Defines ********/
  61. X#include "hack.h"
  62. X#include "patchlevel.h"
  63. X
  64. X/******** Toolbox Defines ********/
  65. X/* #include <Controls.h> */
  66. X#include <Desk.h>
  67. X/* #include <Dialogs.h> */
  68. X/* #include <Memory.h> */
  69. X#include <Menus.h>
  70. X/* #include <Quickdraw.h> */
  71. X#include <Resources.h>
  72. X/* #include <SegLoad.h> */
  73. X#include <TextEdit.h>
  74. X#include <ToolUtils.h>
  75. X#include <Packages.h>
  76. X/* #include <Windows.h> */
  77. X
  78. X/* Think/MPW incompatibility from Think.h/Script.h */
  79. X#if !defined(__THINK__) && !defined(__SCRIPT__)
  80. X#define GetMBarHeight()        (* (short *) 0x0BAA)
  81. X#endif
  82. X
  83. X/* Think/MPW incompatibility from LoMem.h/SysEqu.h */
  84. X#if !defined(__LOMEM__) && !defined(__SYSEQU__)
  85. Xenum { WindowList = 0x9D6 };
  86. X#endif
  87. X
  88. X/* Think has separated out c2pstr and other pascal odditites */
  89. X#if defined(THINK_C)
  90. X#include <pascal.h>
  91. X#endif
  92. X
  93. X/******** Local Defines ********/
  94. X
  95. X/* 'MNU#' (menu list record) */
  96. Xtypedef union menuRefUnn
  97. X{
  98. X    short        mresID;        /* MENU resource ID (before GetMenu) */
  99. X    MenuHandle    mhnd;        /* MENU handle (after GetMenu) */
  100. X} menuRefUnn;
  101. X
  102. Xtypedef struct menuListRec
  103. X{
  104. X    short        firstMenuID;
  105. X    short        numMenus;
  106. X    menuRefUnn    mref[];
  107. X} menuListRec, *menuListPtr, **menuListHandle;
  108. X
  109. X/* indices and resource IDs of the menu list data */
  110. Xenum
  111. X{
  112. X    listMenubar,
  113. X    listSubmenu,
  114. X
  115. X    menuBarListID = 128,
  116. X    subMenuListID
  117. X};
  118. X
  119. X/* the following mref[] indices are reserved */
  120. Xenum
  121. X{
  122. X    /* menu bar */
  123. X    menuApple,
  124. X    menuFile,
  125. X    menuEdit,
  126. X
  127. X    /* submenu */
  128. X    menuWizard = 0
  129. X};
  130. X
  131. X/* the following menu items are reserved */
  132. Xenum
  133. X{
  134. X    /* apple */
  135. X    menuAppleAboutBox = 1,
  136. X    ____Apple__1,
  137. X
  138. X    /* File */
  139. X    menuFileOpenMap = 1,
  140. X    menuFileRedraw,
  141. X    menuFilePrevMsg,
  142. X    menuFileCleanup,
  143. X    menuFileClose,
  144. X    ____File___1,
  145. X    menuFilePlayMode,
  146. X    menuFileEnterExplore,
  147. X    ____File___2,
  148. X    menuFileOptionEdit,
  149. X    ____File___3,
  150. X    menuFileSave,
  151. X    ____File___4,
  152. X    menuFileQuit,
  153. X
  154. X    /* standard minimum Edit menu items */
  155. X
  156. X    /* Wizard */
  157. X    menuWizardAttributes = 1
  158. X};
  159. X
  160. X/* symbols here correspond to arrays in DialogAskName */
  161. X/* eventually this data will become a 'STR#' resource */
  162. Xstatic unsigned char    uitmChar[3][16] = {{"ABCEHKPRSTVW"}, {"MF"}, {" XD"}};
  163. X
  164. X    /* arrays here correspond to symbols in drawANUserItem */
  165. X    /* eventually this data will be moved to 'STR#' resources */
  166. Xstatic unsigned char * nhRole [ askn_role_end ] = {
  167. X    {"\pArcheologist"}, {"\pBarbarian"},
  168. X    {"\pCaveman"}, {"\pElf"}, {"\pHealer"}, {"\pKnight"},
  169. X    {"\pPriest"}, {"\pRogue"}, {"\pSamurai"}, {"\pTourist"},
  170. X    {"\pValkyrie"}, {"\pWizard"}
  171. X};
  172. Xstatic unsigned char * nhSex [ 2 ] = {
  173. X    {"\pMale"}, {"\pFemale"}
  174. X};
  175. Xstatic unsigned char * nhMode [ 3 ] = {
  176. X    {"\pRegular"}, {"\pExplore"}, {"\pDebug"}
  177. X};
  178. X
  179. X
  180. X/*
  181. X * menuListRec data (preloaded and locked) specifies the number of menus in
  182. X * the menu bar, the number of hierarchal or submenus and the menu IDs of
  183. X * all of those menus.  menus that go into in the menu bar are specified by
  184. X * 'MNU#' 128 and submenus are specified by 'MNU#' 129.  the fields of the
  185. X * menuListRec are:
  186. X * firstMenuID - the menu ID (not resource ID) of the 1st menu.  subsequent
  187. X *     menus in the list are _forced_ to have consecutively incremented IDs.
  188. X * numMenus - the total count of menus in a given list (and the extent of
  189. X *     valid menu IDs).
  190. X * mref[] - initially the MENU resource ID is stored in the placeholder for
  191. X *     the resource handle.  after loading (GetResource), the menu handle
  192. X *     is stored and the menu ID, in memory, is set as noted above.
  193. X *
  194. X * NOTE: a ResEdit template editor is supplied to edit the 'MNU#' resources.
  195. X *
  196. X * NOTE: the resource IDs do not need to match the menu IDs in a menu list
  197. X * record although they have been originally set that way.
  198. X *
  199. X * NOTE: the menu ID's of menus in the submenu list record may be reset, as
  200. X * noted above.  it is the programmers responsibility to make sure that
  201. X * submenu references/IDs are valid.
  202. X *
  203. X * WARNING: the existence of the submenu list record is assumed even if the
  204. X * number of submenus is zero.  also, no error checking is done on the
  205. X * extents of the menu IDs.  this must be correctly setup by the programmer.
  206. X */
  207. X
  208. X#define ID1_MBAR    pMenuList[listMenubar]->firstMenuID
  209. X#define ID1_SUBM    pMenuList[listSubmenu]->firstMenuID
  210. X
  211. X#define NUM_MBAR    pMenuList[listMenubar]->numMenus
  212. X#define NUM_SUBM    pMenuList[listSubmenu]->numMenus
  213. X
  214. X#define MHND_APPLE    pMenuList[listMenubar]->mref[menuApple].mhnd
  215. X#define MHND_FILE    pMenuList[listMenubar]->mref[menuFile].mhnd
  216. X#define MHND_EDIT    pMenuList[listMenubar]->mref[menuEdit].mhnd
  217. X
  218. X#define MBARHND(x)    pMenuList[listMenubar]->mref[(x)].mhnd
  219. X
  220. X#define MHND_WIZ    pMenuList[listSubmenu]->mref[menuWizard].mhnd
  221. X
  222. X
  223. X/* mutually exclusive (and prioritized) menu bar states */
  224. Xenum
  225. X{
  226. X    mbarDim,
  227. X    mbarNoWindows,
  228. X    mbarDA,
  229. X    mbarNoMap,
  230. X    mbarRegular,
  231. X    mbarSpecial                    /* explore or debug mode */
  232. X};
  233. X
  234. X#define WKND_MAP        (WIN_BASE_KIND + NHW_MAP)
  235. X
  236. X
  237. X/* menu routine error numbers */
  238. Xenum
  239. X{
  240. X    errGetMenuList,
  241. X    errGetMenu,
  242. X    errGetANDlogTemplate,
  243. X    errGetANDlogItems,
  244. X    errGetANDialog,
  245. X    errANNewMenu,
  246. X    err_Menu_total
  247. X};
  248. X
  249. X
  250. X/* menu 'STR#' comment char */
  251. X#define mstrEndChar        0xA5        /* '\245' or option-* or "bullet" */
  252. X
  253. X/* max key queue (from macwin.c) */
  254. X#define QUEUE_LEN        keyQueueLen
  255. Xextern const int keyQueueLen ;
  256. X
  257. X/* 'ALRT' */
  258. Xenum
  259. X{
  260. X    alrt_Menu_start = 5000,
  261. X    alrtMenuNote = alrt_Menu_start,
  262. X    alrtMenu_NY,
  263. X    alrt_Menu_limit
  264. X};
  265. X
  266. X#define beepMenuAlertErr    1        /* # of SysBeep()'s before exitting */
  267. Xenum
  268. X{
  269. X    bttnMenuAlertNo = 1,
  270. X    bttnMenuAlertYes
  271. X};
  272. X
  273. X/* askname menus */
  274. Xenum
  275. X{
  276. X    menuANRole,
  277. X    menuANSex,
  278. X    menuANMode,
  279. X    menuAN_total
  280. X};
  281. X
  282. X
  283. X/******** Globals ********/
  284. Xstatic    unsigned char *menuErrStr[err_Menu_total] = 
  285. X    {
  286. X        "\pAbort: Bad \'MNU#\' resource!",        /* errGetMenuList */
  287. X        "\pAbort: Bad \'MENU\' resource!",        /* errGetMenu */
  288. X        "\pAbort: Bad \'DLOG\' resource!",        /* errGetANDlogTemplate */
  289. X        "\pAbort: Bad \'DITL\' resource!",        /* errGetANDlogItems */
  290. X        "\pAbort: Bad Dialog Allocation!",        /* errGetANDialog */
  291. X        "\pAbort: Bad Menu Allocation!",        /* errANNewMenu */
  292. X    };
  293. Xstatic    menuListPtr    pMenuList[2];
  294. Xstatic    short        theMenubar = mbarDA;    /* force initial update */
  295. Xstatic    short        kAdjustWizardMenu = 1;
  296. X
  297. X
  298. X/******** Prototypes ********/
  299. Xstatic    void alignAD(Rect *, short);
  300. Xstatic    void mustGetMenuAlerts(void);
  301. Xstatic    void menuError(short);
  302. X
  303. Xextern    void AddToKeyQueue ( int ch , Boolean force ) ;
  304. Xpascal    void drawANUserItem(WindowPtr, short);
  305. X        void DialogAskName(asknameRec *);
  306. X        void InitMenuRes(void);
  307. X        void AdjustMenus(short);
  308. X        void DoMenuEvt(long);
  309. Xextern    void WindowGoAway(EventRecord *, WindowPtr);
  310. X
  311. Xstatic    void aboutNetHack(void);
  312. Xstatic    void openMap(void);
  313. Xstatic    void closeFrontWindow(void);
  314. Xstatic    void optionEditor(void);
  315. Xstatic    void askSave(void);
  316. Xstatic    void askQuit(void);
  317. X
  318. X
  319. X/******** Routines ********/
  320. Xstatic void
  321. XalignAD(Rect *pRct, short vExempt)
  322. X{
  323. X    (*pRct).right -= (*pRct).left;        /* width */
  324. X    (*pRct).bottom -= (*pRct).top;        /* height */
  325. X    (*pRct).left = (qd.screenBits.bounds.right - (*pRct).right) / 2;
  326. X    (*pRct).top = (qd.screenBits.bounds.bottom - (*pRct).bottom - vExempt) / 2;
  327. X    (*pRct).top += vExempt;
  328. X    (*pRct).right += (*pRct).left;
  329. X    (*pRct).bottom += (*pRct).top;
  330. X}
  331. X
  332. Xstatic void
  333. XmustGetMenuAlerts()
  334. X{
  335. X    short        i, mbarHgt = GetMBarHeight();
  336. X    Rect        **hRct;
  337. X
  338. X    for (i = alrt_Menu_start; i < alrt_Menu_limit; i++)
  339. X    {
  340. X        if (! (hRct = (Rect **) GetResource('ALRT', i)))    /* AlertTHndl */
  341. X        {
  342. X            for (i = 0; i < beepMenuAlertErr; i++)
  343. X                SysBeep(3);
  344. X            ExitToShell();
  345. X        }
  346. X
  347. X        alignAD(*hRct, mbarHgt);
  348. X    }
  349. X}
  350. X
  351. Xstatic void
  352. XmenuError(short menuErr)
  353. X{
  354. X    short    i;
  355. X
  356. X    for (i = 0; i < beepMenuAlertErr; i++)
  357. X        SysBeep(3);
  358. X
  359. X    ParamText(menuErrStr[menuErr], "\p", "\p", "\p");
  360. X    (void) Alert(alrtMenuNote, (ModalFilterProcPtr) 0L);
  361. X
  362. X    ExitToShell();
  363. X}
  364. X
  365. Xpascal void
  366. XdrawANUserItem(WindowPtr wPtr, short uItm)
  367. X{
  368. X    asknameRec    *pANR;
  369. X    short        iTyp;
  370. X    Handle        iHnd;
  371. X    Rect        iRct;
  372. X    short        whichUserItem;
  373. X
  374. X    pANR = (asknameRec *) GetWRefCon(wPtr);
  375. X    GetDItem((DialogPtr) wPtr, uItm, &iTyp, &iHnd, &iRct);
  376. X
  377. X    switch (uItm)
  378. X    {
  379. X    case uitmANOutlineDefault:
  380. X        PenSize(3, 3);
  381. X        FrameRoundRect(&iRct, 16, 16);
  382. X        break;
  383. X
  384. X    case uitmANRole:
  385. X    case uitmANSex:
  386. X    case uitmANMode:
  387. X        whichUserItem = uItm - uitmANRole;
  388. X
  389. X        PenNormal();
  390. X        EraseRect(&iRct);
  391. X
  392. X        /* drop shadow */
  393. X        iRct.right--;
  394. X        iRct.bottom--;
  395. X        MoveTo(iRct.right, (iRct.top + 1));
  396. X        LineTo(iRct.right, iRct.bottom);
  397. X        LineTo((iRct.left + 1), iRct.bottom);
  398. X
  399. X        /* frame */
  400. X        FrameRect(&iRct);
  401. X
  402. X        /* menu character */
  403. X        MoveTo((iRct.left + 2), (iRct.top + 12));
  404. X        DrawChar(uitmChar[whichUserItem][(*pANR).anMenu[whichUserItem]]);
  405. X
  406. X        /* popup symbol */
  407. X        MoveTo((iRct.left + 18), (iRct.top + 6));
  408. X        LineTo((iRct.left + 28), (iRct.top + 6));
  409. X        LineTo((iRct.left + 23), (iRct.top + 11));
  410. X        LineTo((iRct.left + 19), (iRct.top + 7));
  411. X        LineTo((iRct.left + 26), (iRct.top + 7));
  412. X        LineTo((iRct.left + 23), (iRct.top + 10));
  413. X        LineTo((iRct.left + 21), (iRct.top + 8));
  414. X        LineTo((iRct.left + 24), (iRct.top + 8));
  415. X        LineTo((iRct.left + 23), (iRct.top + 9));
  416. X        break;
  417. X    }
  418. X}
  419. X
  420. X/* this routine manages the extended askname dialog */
  421. Xvoid
  422. XDialogAskName(asknameRec *pANR)
  423. X{
  424. X    GrafPtr            pOldPort;
  425. X    DialogTHndl        dTHnd;
  426. X    Handle            dIHnd;
  427. X    DialogRecord    dRec;
  428. X    short            i, iHit, iTyp;
  429. X    Handle            iHnd;
  430. X    Rect            iRct, iRct2;
  431. X    MenuHandle        mhndAskName[menuAN_total];
  432. X    short            mbarHgt = GetMBarHeight();
  433. X    short            ndxItem, menuEntry;
  434. X    Point            pt;
  435. X
  436. X    if (! (dTHnd = (DialogTHndl) GetResource('DLOG', dlogAskName)))
  437. X        menuError(errGetANDlogTemplate);
  438. X    alignAD((Rect *) *dTHnd, mbarHgt);
  439. X
  440. X    if (! (dIHnd = GetResource('DITL', dlogAskName)))
  441. X        menuError(errGetANDlogItems);
  442. X
  443. X    GetPort(&pOldPort);
  444. X    /* to do: check if theWorld.hasColorQD ... */
  445. X    (void) GetNewDialog(dlogAskName, (Ptr) &dRec, (WindowPtr) 0L);
  446. X    if (ResError() || MemError())
  447. X        menuError(errGetANDialog);
  448. X
  449. X    SetWRefCon((WindowPtr) &dRec, (long) pANR);
  450. X    for (i = 0; i < menuAN_total; i++) {
  451. X        if (! (mhndAskName[i] = NewMenu((dlogAskName + i), "\pPopup")))
  452. X            menuError(errANNewMenu);
  453. X    }
  454. X
  455. X    /* role menu */
  456. X    for (i = 0; i < askn_role_end; i++)
  457. X        AppendMenu(mhndAskName[menuANRole], * (Str255 *) nhRole[i]);
  458. X
  459. X    /* sex menu */
  460. X    for (i = 0; i < 2; i++)
  461. X        AppendMenu(mhndAskName[menuANSex], * (Str255 *) nhSex[i]);
  462. X
  463. X    /* mode menu */
  464. X    for (i = 0; i < 3; i++)
  465. X        AppendMenu(mhndAskName[menuANMode], * (Str255 *) nhMode[i]);
  466. X
  467. X    /* insert the popup menus */
  468. X    for (i = 0; i < menuAN_total; i++)
  469. X        InsertMenu(mhndAskName[i], hierMenu);
  470. X
  471. X    for (i = uitmANOutlineDefault; i <= uitmANMode; i++)
  472. X    {
  473. X        GetDItem((DialogPtr)&dRec, i, &iTyp, &iHnd, &iRct);
  474. X        SetDItem((DialogPtr)&dRec, i, iTyp, (Handle) drawANUserItem, &iRct);
  475. X    }
  476. X    {
  477. X    short kind ; Handle item ; Rect area ;
  478. X    Str32 pName ;
  479. X        pName [ 0 ] = 0 ;
  480. X        if ( plname && plname [ 0 ] ) {
  481. X            strcpy ( ( char * ) pName , plname ) ;
  482. X            c2pstr ( ( char * ) pName ) ;
  483. X        } else {
  484. X            Handle h ;
  485. X            h = GetResource ( 'STR ' , -16096 ) ;
  486. X            if ( ( (Handle) NULL != h ) && ( GetHandleSize ( h ) > 0 ) ) {
  487. X                DetachResource ( h ) ;
  488. X                HLock ( h ) ;
  489. X                if ( * * h > 31 ) {
  490. X                    * * h = 31 ;
  491. X                }
  492. X                BlockMove ( * h , pName , * * h + 1 )  ;
  493. X                DisposeHandle ( h ) ;
  494. X            }
  495. X        }
  496. X        if ( pName [ 0 ] ) {
  497. X            GetDItem ( ( WindowPtr ) & dRec , etxtANWho , & kind , & item , & area ) ;
  498. X            SetIText ( item , pName ) ;
  499. X            if ( pName [ 0 ] > 2 && pName [ pName [ 0 ] - 1 ] == '-' ) {
  500. X                (*pANR).anMenu[anRole] = ( strchr ( (char *) uitmChar [ 0 ] , pName [ pName [ 0 ] ] ) -
  501. X                    (char *) uitmChar [ 0 ] ) ;
  502. X            }
  503. X        }
  504. X    }
  505. X    SelIText ( ( WindowPtr ) & dRec , etxtANWho , 0 , 32767 ) ;
  506. X
  507. X    SetPort((GrafPtr) &dRec);
  508. X    ShowWindow((WindowPtr) &dRec);
  509. X    SelectWindow((WindowPtr) &dRec);
  510. X
  511. X    iHit = bttnANQuit + 1;
  512. X    while (iHit > bttnANQuit)
  513. X    {
  514. X        /* adjust the askname menus */
  515. X        {
  516. X            static short    checkFeatures = 1;
  517. X            static short    currRole = -1, currSex = -1;
  518. X            unsigned char    anCavePerson[2][16] = {{"\pCaveman"}, {"\pCavewoman"}};
  519. X            unsigned char    anCleric[2][16] = {{"\pPriest"}, {"\pPriestess"}};
  520. X
  521. X            if (checkFeatures)
  522. X            {
  523. X                checkFeatures = 0;
  524. X
  525. X#ifndef TOURIST
  526. X                DisableItem(mhndAskName[menuANRole], (asknTourist + 1));
  527. X#endif
  528. X#ifndef WIZARD
  529. X                DisableItem(mhndAskName[menuANMode], (asknDebug + 1));
  530. X#endif
  531. X#ifndef EXPLORE_MODE
  532. X                DisableItem(mhndAskName[menuANMode], (asknExplore + 1));
  533. X#endif
  534. X            }
  535. X
  536. X            /* check role 1st, valkyrie forces female */
  537. X            if (currRole != (*pANR).anMenu[anRole])
  538. X            {
  539. X                currRole = (*pANR).anMenu[anRole];
  540. X
  541. X                if ((*pANR).anMenu[anRole] == asknValkyrie)
  542. X                {
  543. X                    (*pANR).anMenu[anSex] = asknFemale;
  544. X
  545. X                    GetDItem((DialogPtr) &dRec, uitmANSex, &iTyp, &iHnd, &iRct);
  546. X                    InvalRect(&iRct);
  547. X
  548. X                    /* disable male sex option */
  549. X                    DisableItem(mhndAskName[menuANSex], (asknMale + 1));
  550. X                }
  551. X                else
  552. X                    /* enable male sex option */
  553. X                    EnableItem(mhndAskName[menuANSex], (asknMale + 1));
  554. X            }
  555. X
  556. X            if (currSex != (*pANR).anMenu[anSex])
  557. X            {
  558. X                currSex = (*pANR).anMenu[anSex];
  559. X
  560. X                SetItem(mhndAskName[menuANRole], (asknCaveman + 1),
  561. X                        * (Str255 *) anCavePerson[currSex]);
  562. X                SetItem(mhndAskName[menuANRole], (asknPriest + 1),
  563. X                        * (Str255 *) anCleric[currSex]);
  564. X            }
  565. X        }
  566. X
  567. X        ModalDialog((ModalFilterProcPtr) 0L, &iHit);
  568. X
  569. X        switch (iHit)
  570. X        {
  571. X        case bttnANPlay:        /* done!  let's play */
  572. X            break;
  573. X
  574. X        case bttnANQuit:
  575. X            (*pANR).anMenu[anMode] = asknQuit;
  576. X            break;
  577. X
  578. X        case uitmANRole:
  579. X        case uitmANSex:
  580. X        case uitmANMode:
  581. X            ndxItem = iHit - uitmANRole;
  582. X
  583. X            /* invert the popup title */
  584. X            GetDItem((DialogPtr) &dRec, (iHit + 3), &iTyp, &iHnd, &iRct2);
  585. X            InvertRect(&iRct2);
  586. X
  587. X            /* get the menu item */
  588. X            GetDItem((DialogPtr) &dRec, iHit, &iTyp, &iHnd, &iRct);
  589. X            pt = * (Point *) &iRct;
  590. X            LocalToGlobal(&pt);
  591. X            if (menuEntry = PopUpMenuSelect(mhndAskName[ndxItem],
  592. X                            pt.v, pt.h, ((*pANR).anMenu[ndxItem] + 1)))
  593. X                /* set last item selected */
  594. X                (*pANR).anMenu[ndxItem] = LoWord(menuEntry) - 1;
  595. X
  596. X            InvertRect(&iRct2);
  597. X            InvalRect(&iRct);
  598. X            break;
  599. X
  600. X        case etxtANWho:
  601. X            /* limit the data here to 25 chars */
  602. X            {
  603. X                short beepTEDelete = 1;
  604. X
  605. X                while ((**dRec.textH).teLength > 25)
  606. X                {
  607. X                    if (beepTEDelete++ <= 3)
  608. X                        SysBeep(3);
  609. X                    TEKey('\b', dRec.textH);
  610. X                }
  611. X            }
  612. X
  613. X            /* special case filter (that doesn't plug all the holes!) */
  614. X            if (((**dRec.textH).teLength == 1) && (**((**dRec.textH).hText) < 32))
  615. X                TEKey('\b', dRec.textH);
  616. X
  617. X            /* if no name then disable the play button */
  618. X            GetDItem((DialogPtr) &dRec, bttnANPlay, &iTyp, &iHnd, &iRct);
  619. X            if ((**dRec.textH).teLength > 0)
  620. X                iTyp &= ~itemDisable;
  621. X            else
  622. X                iTyp |= itemDisable;
  623. X            HiliteControl((ControlHandle) iHnd, ((iTyp & itemDisable) ? 255 : 0));
  624. X            SetDItem((DialogPtr) &dRec, bttnANPlay, iTyp, iHnd, &iRct);
  625. X            break;
  626. X        }
  627. X    }
  628. X
  629. X    if ((*pANR).anMenu[anMode] != asknQuit) {
  630. X/*
  631. X * This is a good example of how NOT to get text from a dialog
  632. X *
  633. X *        HLock((Handle) (**dRec.textH).hText);
  634. X *        BlockMove(*((**dRec.textH).hText), &((*pANR).anWho[1]), (**dRec.textH).teLength);
  635. X *        (*pANR).anWho[0] = (**dRec.textH).teLength;
  636. X *        HUnlock((Handle) (**dRec.textH).hText);
  637. X */
  638. X        short kind ; Rect outline ; Handle item ;
  639. X        Str32 pName ;
  640. X
  641. X        GetDItem ( ( WindowPtr ) & dRec , etxtANWho , & kind , & item , & outline ) ;
  642. X         GetIText ( item , ( * pANR ) . anWho ) ;
  643. X        BlockMove ( pANR -> anWho , pName , pANR -> anWho [ 0 ] + 1 ) ;
  644. X        if ( pName [ 0 ] > 2 && pName [ pName [ 0 ] - 1 ] == '-' ) {
  645. X            (*pANR).anMenu[anRole] = ( strchr ( (char *) uitmChar [ 0 ] , pName [ pName [ 0 ] ] ) -
  646. X                (char *) uitmChar [ 0 ] ) ;
  647. X        }
  648. X    }
  649. X
  650. X    /* cleanup (in reverse order) and leave */
  651. X    for (i = 0; i < menuAN_total; i++)
  652. X    {
  653. X        DeleteMenu(dlogAskName + i);
  654. X        DisposeMenu(mhndAskName[i]);
  655. X    }
  656. X    CloseDialog((DialogPtr)&dRec);
  657. X    DisposHandle(dRec.items);
  658. X    ReleaseResource(dIHnd);
  659. X    ReleaseResource((Handle) dTHnd);
  660. X    SetPort(pOldPort);
  661. X}
  662. X
  663. Xvoid
  664. XInitMenuRes()
  665. X{
  666. Xstatic Boolean was_inited = 0 ;
  667. Xshort            i, j;
  668. XmenuListHandle    mlHnd;
  669. XMenuHandle        mHnd;
  670. X
  671. X    if ( was_inited ) {
  672. X        return ;
  673. X    }
  674. X    was_inited = 1 ;
  675. X
  676. X    mustGetMenuAlerts();
  677. X
  678. X    for (i = listMenubar; i <= listSubmenu; i++)
  679. X    {
  680. X        if (! (mlHnd = (menuListHandle) GetResource('MNU#', (menuBarListID + i))))
  681. X            menuError(errGetMenuList);
  682. X
  683. X        pMenuList[i] = *mlHnd;
  684. X
  685. X        for (j = 0; j < (**mlHnd).numMenus; j++)
  686. X        {
  687. X            if (! (mHnd = (MenuHandle) GetMenu((**mlHnd).mref[j].mresID))) {
  688. X            Str31 d ;
  689. X                NumToString ( (**mlHnd).mref[j].mresID , d ) ;
  690. X//                DebugStr ( d ) ;
  691. X                menuError(errGetMenu);
  692. X            }
  693. X
  694. X            (**mlHnd).mref[j].mhnd = mHnd;
  695. X            * ((short *) *mHnd) = j + (**mlHnd).firstMenuID;    /* consecutive IDs */
  696. X
  697. X            /* expand apple menu */
  698. X            if ((i == listMenubar) && (j == menuApple)) {
  699. X                AddResMenu(mHnd, 'DRVR');
  700. X            }
  701. X
  702. X            InsertMenu(mHnd, ((i == listSubmenu) ? hierMenu : 0));
  703. X        }
  704. X    }
  705. X
  706. X    DrawMenuBar();
  707. X}
  708. X
  709. Xvoid
  710. XAdjustMenus(short dimMenubar)
  711. X{
  712. Xshort        newMenubar = mbarRegular;
  713. XWindowPeek    peekWindow = (WindowPeek) FrontWindow();
  714. Xshort        i;
  715. X
  716. X/*
  717. X *    if ( windowprocs != mac_procs ) {
  718. X *        return ;
  719. X *    }
  720. X */
  721. X    /* determine the new menubar state */
  722. X    if (dimMenubar) {
  723. X        newMenubar = mbarDim;
  724. X    } else if (! peekWindow) {
  725. X        newMenubar = mbarNoWindows;
  726. X    } else if (peekWindow->windowKind < 0) {
  727. X        newMenubar = mbarDA;
  728. X    } else {
  729. X        while (peekWindow && (peekWindow->windowKind != WKND_MAP)) {
  730. X            peekWindow = peekWindow->nextWindow;
  731. X        }
  732. X        if ((! peekWindow) || (! peekWindow->visible)) {
  733. X            newMenubar = mbarNoMap;
  734. X        }
  735. X    }
  736. X
  737. X    if (newMenubar != mbarRegular)
  738. X        ;                            /* we've already found its state */
  739. X#ifdef WIZARD
  740. X    else if (wizard)
  741. X    {
  742. X        newMenubar = mbarSpecial;
  743. X
  744. X        if (kAdjustWizardMenu)
  745. X        {
  746. X            kAdjustWizardMenu = 0;
  747. X
  748. X            SetItem(MHND_FILE, menuFilePlayMode, "\pDebug");
  749. X        }
  750. X    }
  751. X#endif
  752. X
  753. X#ifdef EXPLORE_MODE
  754. X    else if (discover)
  755. X    {
  756. X        newMenubar = mbarSpecial;
  757. X
  758. X        if (kAdjustWizardMenu)
  759. X        {
  760. X            kAdjustWizardMenu = 0;
  761. X
  762. X            SetItem(MHND_FILE, menuFilePlayMode, "\pExplore");
  763. X
  764. X            for (i = CountMItems(MHND_WIZ); i > menuWizardAttributes; i--)
  765. X                DelMenuItem(MHND_WIZ, i);
  766. X        }
  767. X    }
  768. X#endif
  769. X
  770. X    /* adjust the menubar, if there's a state change */
  771. X    if (theMenubar != newMenubar)
  772. X    {
  773. X        switch(theMenubar = newMenubar)
  774. X        {
  775. X        case mbarDim:
  776. X            /* disable all menus (except the apple menu) */
  777. X            for (i = menuFile; i < NUM_MBAR; i++)
  778. X                DisableItem(MBARHND(i), 0);
  779. X            break;
  780. X
  781. X        case mbarNoWindows:
  782. X        case mbarDA:
  783. X        case mbarNoMap:
  784. X            /* enable the file menu, but ... */
  785. X            EnableItem(MHND_FILE, 0);
  786. X
  787. X            if (theMenubar == mbarDA)
  788. X                DisableItem(MHND_FILE, menuFileOpenMap);
  789. X            else
  790. X                EnableItem(MHND_FILE, menuFileOpenMap);
  791. X
  792. X            /* ... disable the window commands! */
  793. X            for (i = menuFileRedraw; i <= menuFileEnterExplore; i++)
  794. X                DisableItem(MHND_FILE, i);
  795. X
  796. X            if (theMenubar != mbarNoWindows)
  797. X                EnableItem(MHND_FILE, menuFileClose);
  798. X
  799. X            /* ... and disable the rest of the menus */
  800. X            for (i = menuEdit; i < NUM_MBAR; i++)
  801. X                DisableItem(MBARHND(i), 0);
  802. X
  803. X            if (theMenubar == mbarDA)
  804. X                EnableItem(MHND_EDIT, 0);
  805. X
  806. X            break;
  807. X
  808. X        case mbarRegular:
  809. X        case mbarSpecial:
  810. X            /* enable all menus ... */
  811. X            for (i = menuFile; i < NUM_MBAR; i++)
  812. X                EnableItem(MBARHND(i), 0);
  813. X
  814. X            /* ... except the unused Edit menu */
  815. X            DisableItem(MHND_EDIT, 0);
  816. X
  817. X            /* ... the map is already open! */
  818. X            DisableItem(MHND_FILE, menuFileOpenMap);
  819. X
  820. X            /* ... enable the window commands */
  821. X            for (i = menuFileRedraw; i <= menuFileEnterExplore; i++)
  822. X                EnableItem(MHND_FILE, i);
  823. X
  824. X            if (theMenubar == mbarRegular)
  825. X                DisableItem(MHND_FILE, menuFilePlayMode);
  826. X            else
  827. X                DisableItem(MHND_FILE, menuFileEnterExplore);
  828. X
  829. X            break;
  830. X        }
  831. X
  832. X        DrawMenuBar();
  833. X    }
  834. X}
  835. X
  836. Xvoid
  837. XDoMenuEvt(long menuEntry)
  838. X{
  839. X    short menuID = HiWord(menuEntry);
  840. X    short menuItem = LoWord(menuEntry);
  841. X
  842. X    switch(menuID - ID1_MBAR)    /* all submenus are default case */
  843. X    {
  844. X    case menuApple:
  845. X        if (menuItem == menuAppleAboutBox)
  846. X            aboutNetHack();
  847. X        else
  848. X        {
  849. X            unsigned char daName[32];
  850. X
  851. X            GetItem(MHND_APPLE, menuItem, * (Str255 *) daName);
  852. X            (void) OpenDeskAcc(daName);
  853. X        }
  854. X        break;
  855. X
  856. X    /*
  857. X     * Those direct calls are ugly: they should be installed into cmd.c .
  858. X     * Those AddToKeyQueue() calls are also ugly: they should be put into
  859. X     * the 'STR#' resource.
  860. X     */
  861. X    case menuFile:
  862. X        switch(menuItem)
  863. X        {
  864. X        case menuFileOpenMap:
  865. X            openMap();
  866. X            break;
  867. X
  868. X        case menuFileRedraw:
  869. X            AddToKeyQueue ( 'R' & 0x1f , 1 ) ;
  870. X            break;
  871. X
  872. X        case menuFilePrevMsg:
  873. X            AddToKeyQueue ( 'P' & 0x1f , 1 ) ;
  874. X            break;
  875. X
  876. X        case menuFileCleanup:
  877. X            (void) SanePositions();
  878. X            break;
  879. X
  880. X        case menuFileClose:
  881. X            closeFrontWindow();
  882. X            break;
  883. X
  884. X        case menuFileEnterExplore:
  885. X            AddToKeyQueue ( 'X' , 1 ) ;
  886. X            break;
  887. X
  888. X        case menuFileOptionEdit:
  889. X            optionEditor();
  890. X            break;
  891. X
  892. X        case menuFileSave:
  893. X            askSave();
  894. X            break;
  895. X
  896. X        case menuFileQuit:
  897. X            askQuit();
  898. X            break;
  899. X        }
  900. X        break;
  901. X
  902. X    case menuEdit:
  903. X        (void) SystemEdit(menuItem - 1);
  904. X        break;
  905. X
  906. X    default:    /* get associated string and add to key queue */
  907. X        {
  908. X            Str255    mstr;
  909. X            short    i;
  910. X
  911. X            GetIndString(mstr, menuID, menuItem);
  912. X            if (mstr[0] > QUEUE_LEN)
  913. X                mstr[0] = QUEUE_LEN;
  914. X
  915. X            for (i = 1; ((i <= mstr[0]) && (mstr[i] != mstrEndChar)); i++)
  916. X                AddToKeyQueue(mstr[i], false);
  917. X        }
  918. X        break;
  919. X    }
  920. X
  921. X    HiliteMenu(0);
  922. X}
  923. X
  924. X
  925. Xstatic void
  926. XaboutNetHack() {
  927. X    if (theMenubar >= mbarRegular) {
  928. X        (void) doversion();                /* is this necessary? */
  929. X    } else {
  930. X    unsigned char aboutStr[32] = "\pNetHack 3.1.";
  931. X
  932. X        if (PATCHLEVEL > 10) {
  933. X            aboutStr[++aboutStr[0]] = '0'+PATCHLEVEL/10;
  934. X        }
  935. X
  936. X        aboutStr[++aboutStr[0]] = '0' + (PATCHLEVEL % 10);
  937. X
  938. X        ParamText(aboutStr, "\p\rnethack-bugs@linc.cis.upenn.edu", "\p", "\p");
  939. X        (void) Alert(alrtMenuNote, (ModalFilterProcPtr) 0L);
  940. X        ResetAlrtStage();
  941. X    }
  942. X}
  943. X
  944. Xstatic void
  945. XopenMap()
  946. X{
  947. X    WindowPeek    peekWindow = *(WindowPeek*) WindowList;
  948. X
  949. X    while (peekWindow && (peekWindow->windowKind != WKND_MAP))
  950. X        peekWindow = peekWindow->nextWindow;
  951. X
  952. X    if (! peekWindow)
  953. X        return;                /* impossible? */
  954. X
  955. X    ShowWindow((WindowPtr) peekWindow);
  956. X    SelectWindow((WindowPtr) peekWindow);
  957. X}
  958. X
  959. Xstatic void
  960. XcloseFrontWindow()
  961. X{
  962. X    WindowPeek    peekWindow = (WindowPeek) FrontWindow();
  963. X
  964. X    if (! peekWindow)
  965. X        return;                /* impossible? */
  966. X    else if (peekWindow->windowKind < 0)
  967. X        CloseDeskAcc(peekWindow->windowKind);
  968. X    else if (peekWindow->windowKind == WKND_MAP)
  969. X        HideWindow((WindowPtr) peekWindow);
  970. X    else
  971. X        WindowGoAway((EventRecord *) 0L, (WindowPtr) peekWindow);
  972. X}
  973. X
  974. Xstatic void
  975. XoptionEditor()
  976. X{
  977. X    ParamText("\pSorry, not yet implemented!  Use Options on the Help menu.", "\p", "\p", "\p");
  978. X    (void) Alert(alrtMenuNote, (ModalFilterProcPtr) 0L);
  979. X    ResetAlrtStage();
  980. X}
  981. X
  982. Xstatic void
  983. XaskSave() {
  984. XBoolean doSave = 1 ;
  985. XBoolean doYes = 0 ;
  986. X
  987. X    if (theMenubar < mbarRegular) {
  988. X    short    itemHit;
  989. X
  990. X        ParamText("\pReally Save?", "\p", "\p", "\p");
  991. X        itemHit = Alert(alrtMenu_NY, (ModalFilterProcPtr) 0L);
  992. X        ResetAlrtStage();
  993. X
  994. X        if (itemHit != bttnMenuAlertYes) {
  995. X            doSave = 0 ;
  996. X        } else {
  997. X            doYes = 1 ;
  998. X        }
  999. X    }
  1000. X    if ( doSave ) {
  1001. X        AddToKeyQueue ( 'S' , 1 ) ;
  1002. X        if ( doYes ) {
  1003. X            AddToKeyQueue ( 'y' , 1 ) ;
  1004. X        }
  1005. X    }
  1006. X}
  1007. X
  1008. Xstatic void
  1009. XaskQuit() {
  1010. XBoolean doQuit = 1 ;
  1011. XBoolean doYes = 0 ;
  1012. X
  1013. X    if (theMenubar < mbarRegular) {
  1014. X    short    itemHit;
  1015. X
  1016. X        ParamText("\pReally Quit?", "\p", "\p", "\p");
  1017. X        itemHit = Alert(alrtMenu_NY, (ModalFilterProcPtr) 0L);
  1018. X        ResetAlrtStage();
  1019. X
  1020. X        if (itemHit != bttnMenuAlertYes) {
  1021. X            doQuit = 0 ;
  1022. X        } else {
  1023. X            doYes = 1 ;
  1024. X        }
  1025. X    }
  1026. X    if ( doQuit ) {
  1027. X        AddToKeyQueue ( 'Q' , 1 ) ;
  1028. X        if ( doYes ) {
  1029. X            AddToKeyQueue ( 'y' , 1 ) ;
  1030. X        }
  1031. X    }
  1032. X}
  1033. END_OF_FILE
  1034. if test 23678 -ne `wc -c <'sys/mac/macmenu.c'`; then
  1035.     echo shar: \"'sys/mac/macmenu.c'\" unpacked with wrong size!
  1036. fi
  1037. # end of 'sys/mac/macmenu.c'
  1038. if test -f 'sys/share/dgn_yacc.c' -a "${1}" != "-c" ; then 
  1039.   echo shar: Renaming existing file \"'sys/share/dgn_yacc.c'\" to \"'sys/share/dgn_yacc.c.orig'\"
  1040.   mv -f 'sys/share/dgn_yacc.c' 'sys/share/dgn_yacc.c.orig'
  1041. fi
  1042. echo shar: Extracting \"'sys/share/dgn_yacc.c'\" \(30875 characters\)
  1043. sed "s/^X//" >'sys/share/dgn_yacc.c' <<'END_OF_FILE'
  1044. X#ifndef lint
  1045. Xstatic char yysccsid[] = "@(#)yaccpar    1.9 (Berkeley) 02/21/93";
  1046. X#endif
  1047. X#define YYBYACC 1
  1048. X#define YYMAJOR 1
  1049. X#define YYMINOR 9
  1050. X#define yyclearin (yychar=(-1))
  1051. X#define yyerrok (yyerrflag=0)
  1052. X#define YYRECOVERING (yyerrflag!=0)
  1053. X#define YYPREFIX "yy"
  1054. X/*    SCCS Id: @(#)dgn_comp.c    3.1    93/05/15    */
  1055. X/*    Copyright (c) 1989 by Jean-Christophe Collet */
  1056. X/*    Copyright (c) 1990 by M. Stephenson                  */
  1057. X/* NetHack may be freely redistributed.  See license for details. */
  1058. X
  1059. X/*
  1060. X * This file contains the Dungeon Compiler code
  1061. X */
  1062. X
  1063. X/* In case we're using bison in AIX.  This definition must be
  1064. X * placed before any other C-language construct in the file
  1065. X * excluding comments and preprocessor directives (thanks IBM
  1066. X * for this wonderful feature...).
  1067. X *
  1068. X * Note: some cpps barf on this 'undefined control' (#pragma).
  1069. X * Addition of the leading space seems to prevent barfage for now,
  1070. X * and AIX will still see the directive in its non-standard locale.
  1071. X */
  1072. X
  1073. X#ifdef _AIX
  1074. X #pragma alloca        /* keep leading space! */
  1075. X#endif
  1076. X
  1077. X#include "config.h"
  1078. X#include "dgn_file.h"
  1079. X
  1080. Xvoid FDECL(yyerror, (const char *));
  1081. Xvoid FDECL(yywarning, (const char *));
  1082. Xint NDECL(yylex);
  1083. Xint NDECL(yyparse);
  1084. Xint FDECL(getchain, (char *));
  1085. Xint NDECL(check_dungeon);
  1086. Xint NDECL(check_branch);
  1087. Xint NDECL(check_level);
  1088. Xvoid NDECL(init_dungeon);
  1089. Xvoid NDECL(init_branch);
  1090. Xvoid NDECL(init_level);
  1091. Xvoid NDECL(output_dgn);
  1092. X
  1093. X#ifdef AMIGA
  1094. X# undef    printf
  1095. X#ifndef    LATTICE
  1096. X# define    memset(addr,val,len)    setmem(addr,len,val)
  1097. X#endif
  1098. X#endif
  1099. X
  1100. X#ifdef MICRO
  1101. X# undef exit
  1102. Xextern void FDECL(exit, (int));
  1103. X#endif
  1104. X
  1105. X#undef NULL
  1106. X
  1107. X#define ERR        (-1)
  1108. X
  1109. Xstatic struct couple couple;
  1110. Xstatic struct tmpdungeon tmpdungeon[MAXDUNGEON];
  1111. Xstatic struct tmplevel tmplevel[LEV_LIMIT];
  1112. Xstatic struct tmpbranch tmpbranch[BRANCH_LIMIT];
  1113. X
  1114. Xstatic int in_dungeon = 0, n_dgns = -1, n_levs = -1, n_brs = -1;
  1115. X
  1116. Xextern int fatal_error;
  1117. Xextern const char *fname;
  1118. X
  1119. Xtypedef union
  1120. X{
  1121. X    int    i;
  1122. X    char*    str;
  1123. X} YYSTYPE;
  1124. X#define INTEGER 257
  1125. X#define A_DUNGEON 258
  1126. X#define BRANCH 259
  1127. X#define CHBRANCH 260
  1128. X#define LEVEL 261
  1129. X#define RNDLEVEL 262
  1130. X#define CHLEVEL 263
  1131. X#define RNDCHLEVEL 264
  1132. X#define UP_OR_DOWN 265
  1133. X#define PROTOFILE 266
  1134. X#define DESCRIPTION 267
  1135. X#define DESCRIPTOR 268
  1136. X#define LEVELDESC 269
  1137. X#define ALIGNMENT 270
  1138. X#define LEVALIGN 271
  1139. X#define ENTRY 272
  1140. X#define STAIR 273
  1141. X#define NO_UP 274
  1142. X#define NO_DOWN 275
  1143. X#define PORTAL 276
  1144. X#define STRING 277
  1145. X#define YYERRCODE 256
  1146. Xshort yylhs[] = {                                        -1,
  1147. X    0,    0,    4,    4,    5,    5,    5,    5,    6,    1,
  1148. X    1,    7,    7,    7,   11,   12,   14,   14,   13,    9,
  1149. X    9,    9,    9,    9,   15,   15,   16,   16,   17,   17,
  1150. X   18,   18,   19,   19,    8,    8,   21,   22,    3,    3,
  1151. X    3,    3,    3,    2,    2,   20,   10,
  1152. X};
  1153. Xshort yylen[] = {                                         2,
  1154. X    0,    1,    1,    2,    1,    1,    1,    1,    6,    0,
  1155. X    1,    1,    1,    1,    3,    1,    3,    3,    3,    1,
  1156. X    1,    1,    1,    1,    6,    7,    7,    8,    3,    3,
  1157. X    7,    8,    8,    9,    1,    1,    7,    8,    0,    1,
  1158. X    1,    1,    1,    0,    1,    5,    5,
  1159. X};
  1160. Xshort yydefred[] = {                                      0,
  1161. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1162. X    0,    0,    0,    0,    0,    3,    5,    6,    7,    8,
  1163. X   12,   13,   14,   16,   20,   21,   22,   23,   24,   35,
  1164. X   36,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1165. X    0,    0,    0,    0,    4,    0,    0,    0,    0,    0,
  1166. X    0,    0,   19,   17,   29,   18,   30,   15,    0,    0,
  1167. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1168. X    0,    0,    0,    0,    0,   11,    9,    0,   40,   41,
  1169. X   42,   43,    0,    0,    0,    0,    0,    0,    0,    0,
  1170. X   45,   37,    0,   27,    0,    0,    0,    0,    0,   38,
  1171. X   28,   33,    0,   47,   46,   34,
  1172. X};
  1173. Xshort yydgoto[] = {                                      14,
  1174. X   77,   92,   83,   15,   16,   17,   18,   19,   20,   67,
  1175. X   21,   22,   23,   24,   25,   26,   27,   28,   29,   69,
  1176. X   30,   31,
  1177. X};
  1178. Xshort yysindex[] = {                                   -237,
  1179. X  -50,  -49,  -48,  -47,  -46,  -45,  -44,  -43,  -39,  -38,
  1180. X  -30,  -22,  -21,    0, -237,    0,    0,    0,    0,    0,
  1181. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1182. X    0, -239, -238, -236, -235, -234, -233, -232, -230, -228,
  1183. X -220, -219, -218, -206,    0, -225,  -11, -223, -222, -221,
  1184. X -217, -215,    0,    0,    0,    0,    0,    0,   17,   18,
  1185. X   20,   -5,    2, -213, -212, -190, -189, -188, -271,   17,
  1186. X   18,   18,   27,   28,   29,    0,    0,   30,    0,    0,
  1187. X    0,    0, -193, -271, -182, -180,   17,   17, -179, -178,
  1188. X    0,    0, -193,    0, -177, -176, -175,   42,   43,    0,
  1189. X    0,    0, -172,    0,    0,    0,
  1190. X};
  1191. Xshort yyrindex[] = {                                     86,
  1192. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1193. X    0,    0,    0,    0,   87,    0,    0,    0,    0,    0,
  1194. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1195. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1196. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1197. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1198. X    0,    0,    0,    0,    0,    0,   16,    0,    1,    0,
  1199. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1200. X    0,    0,   31,    1,   46,    0,    0,    0,    0,    0,
  1201. X    0,    0,   31,    0,   61,   76,    0,    0,    0,    0,
  1202. X    0,    0,   91,    0,    0,    0,
  1203. X};
  1204. Xshort yygindex[] = {                                      0,
  1205. X    0,   -4,    4,    0,   75,    0,    0,    0,    0,  -70,
  1206. X    0,    0,    0,    0,    0,    0,    0,    0,    0,  -65,
  1207. X    0,    0,
  1208. X};
  1209. X#define YYTABLESIZE 363
  1210. Xshort yytable[] = {                                      84,
  1211. X   39,   79,   80,   81,   82,   85,   86,   32,   33,   34,
  1212. X   35,   36,   37,   38,   39,   10,   96,   97,   40,   41,
  1213. X    1,    2,    3,    4,    5,    6,    7,   42,    8,    9,
  1214. X   44,   10,   11,   12,   13,   43,   44,   46,   47,   54,
  1215. X   48,   49,   50,   51,   52,   25,   53,   55,   56,   57,
  1216. X   58,   59,   60,   61,   62,   63,   66,   68,   71,   64,
  1217. X   26,   65,   70,   73,   74,   72,   75,   76,   78,   87,
  1218. X   88,   91,   89,   90,   94,   31,   95,   98,   99,  101,
  1219. X  102,  103,  104,  105,  106,    1,    2,   93,  100,   45,
  1220. X   32,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1221. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1222. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1223. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1224. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1225. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1226. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1227. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1228. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1229. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1230. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1231. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1232. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1233. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1234. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1235. X    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  1236. X    0,    0,    0,    0,    0,    0,    0,    0,   39,   39,
  1237. X   39,   39,   39,   39,   39,   39,   39,   39,    0,   39,
  1238. X   39,   39,   39,   10,   10,   10,   10,   10,   10,   10,
  1239. X    0,   10,   10,    0,   10,   10,   10,   10,   44,   44,
  1240. X   44,   44,   44,   44,   44,    0,   44,   44,    0,   44,
  1241. X   44,   44,   44,   25,   25,   25,   25,   25,   25,   25,
  1242. X    0,   25,   25,    0,   25,   25,   25,   25,   26,   26,
  1243. X   26,   26,   26,   26,   26,    0,   26,   26,    0,   26,
  1244. X   26,   26,   26,   31,   31,   31,   31,   31,   31,   31,
  1245. X    0,   31,   31,    0,   31,   31,   31,   31,   32,   32,
  1246. X   32,   32,   32,   32,   32,    0,   32,   32,    0,   32,
  1247. X   32,   32,   32,
  1248. X};
  1249. Xshort yycheck[] = {                                      70,
  1250. X    0,  273,  274,  275,  276,   71,   72,   58,   58,   58,
  1251. X   58,   58,   58,   58,   58,    0,   87,   88,   58,   58,
  1252. X  258,  259,  260,  261,  262,  263,  264,   58,  266,  267,
  1253. X    0,  269,  270,  271,  272,   58,   58,  277,  277,  268,
  1254. X  277,  277,  277,  277,  277,    0,  277,  268,  268,  268,
  1255. X  257,  277,   64,  277,  277,  277,   40,   40,   64,  277,
  1256. X    0,  277,   43,  277,  277,   64,  257,  257,  257,   43,
  1257. X   43,  265,   44,   44,  257,    0,  257,  257,  257,  257,
  1258. X  257,  257,   41,   41,  257,    0,    0,   84,   93,   15,
  1259. X    0,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1260. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1261. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1262. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1263. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1264. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1265. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1266. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1267. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1268. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1269. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1270. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1271. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1272. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1273. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1274. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  1275. X   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,
  1276. X  260,  261,  262,  263,  264,  265,  266,  267,   -1,  269,
  1277. X  270,  271,  272,  258,  259,  260,  261,  262,  263,  264,
  1278. X   -1,  266,  267,   -1,  269,  270,  271,  272,  258,  259,
  1279. X  260,  261,  262,  263,  264,   -1,  266,  267,   -1,  269,
  1280. X  270,  271,  272,  258,  259,  260,  261,  262,  263,  264,
  1281. X   -1,  266,  267,   -1,  269,  270,  271,  272,  258,  259,
  1282. X  260,  261,  262,  263,  264,   -1,  266,  267,   -1,  269,
  1283. X  270,  271,  272,  258,  259,  260,  261,  262,  263,  264,
  1284. X   -1,  266,  267,   -1,  269,  270,  271,  272,  258,  259,
  1285. X  260,  261,  262,  263,  264,   -1,  266,  267,   -1,  269,
  1286. X  270,  271,  272,
  1287. X};
  1288. X#define YYFINAL 14
  1289. X#ifndef YYDEBUG
  1290. X#define YYDEBUG 0
  1291. X#endif
  1292. X#define YYMAXTOKEN 277
  1293. X#if YYDEBUG
  1294. Xchar *yyname[] = {
  1295. X"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1296. X0,0,0,0,0,0,"'('","')'",0,"'+'","','",0,0,0,0,0,0,0,0,0,0,0,0,0,"':'",0,0,0,0,0,
  1297. X"'@'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1298. X0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1299. X0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1300. X0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1301. X0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"INTEGER",
  1302. X"A_DUNGEON","BRANCH","CHBRANCH","LEVEL","RNDLEVEL","CHLEVEL","RNDCHLEVEL",
  1303. X"UP_OR_DOWN","PROTOFILE","DESCRIPTION","DESCRIPTOR","LEVELDESC","ALIGNMENT",
  1304. X"LEVALIGN","ENTRY","STAIR","NO_UP","NO_DOWN","PORTAL","STRING",
  1305. X};
  1306. Xchar *yyrule[] = {
  1307. X"$accept : file",
  1308. X"file :",
  1309. X"file : dungeons",
  1310. X"dungeons : dungeon",
  1311. X"dungeons : dungeons dungeon",
  1312. X"dungeon : dungeonline",
  1313. X"dungeon : dungeondesc",
  1314. X"dungeon : branches",
  1315. X"dungeon : levels",
  1316. X"dungeonline : A_DUNGEON ':' STRING STRING rcouple optional_int",
  1317. X"optional_int :",
  1318. X"optional_int : INTEGER",
  1319. X"dungeondesc : entry",
  1320. X"dungeondesc : descriptions",
  1321. X"dungeondesc : prototype",
  1322. X"entry : ENTRY ':' INTEGER",
  1323. X"descriptions : desc",
  1324. X"desc : DESCRIPTION ':' DESCRIPTOR",
  1325. X"desc : ALIGNMENT ':' DESCRIPTOR",
  1326. X"prototype : PROTOFILE ':' STRING",
  1327. X"levels : level1",
  1328. X"levels : level2",
  1329. X"levels : levdesc",
  1330. X"levels : chlevel1",
  1331. X"levels : chlevel2",
  1332. X"level1 : LEVEL ':' STRING STRING '@' acouple",
  1333. X"level1 : RNDLEVEL ':' STRING STRING '@' acouple INTEGER",
  1334. X"level2 : LEVEL ':' STRING STRING '@' acouple INTEGER",
  1335. X"level2 : RNDLEVEL ':' STRING STRING '@' acouple INTEGER INTEGER",
  1336. X"levdesc : LEVELDESC ':' DESCRIPTOR",
  1337. X"levdesc : LEVALIGN ':' DESCRIPTOR",
  1338. X"chlevel1 : CHLEVEL ':' STRING STRING STRING '+' rcouple",
  1339. X"chlevel1 : RNDCHLEVEL ':' STRING STRING STRING '+' rcouple INTEGER",
  1340. X"chlevel2 : CHLEVEL ':' STRING STRING STRING '+' rcouple INTEGER",
  1341. X"chlevel2 : RNDCHLEVEL ':' STRING STRING STRING '+' rcouple INTEGER INTEGER",
  1342. X"branches : branch",
  1343. X"branches : chbranch",
  1344. X"branch : BRANCH ':' STRING '@' acouple branch_type direction",
  1345. X"chbranch : CHBRANCH ':' STRING STRING '+' rcouple branch_type direction",
  1346. X"branch_type :",
  1347. X"branch_type : STAIR",
  1348. X"branch_type : NO_UP",
  1349. X"branch_type : NO_DOWN",
  1350. X"branch_type : PORTAL",
  1351. X"direction :",
  1352. X"direction : UP_OR_DOWN",
  1353. X"acouple : '(' INTEGER ',' INTEGER ')'",
  1354. X"rcouple : '(' INTEGER ',' INTEGER ')'",
  1355. X};
  1356. X#endif
  1357. X#ifdef YYSTACKSIZE
  1358. X#undef YYMAXDEPTH
  1359. X#define YYMAXDEPTH YYSTACKSIZE
  1360. X#else
  1361. X#ifdef YYMAXDEPTH
  1362. X#define YYSTACKSIZE YYMAXDEPTH
  1363. X#else
  1364. X#define YYSTACKSIZE 500
  1365. X#define YYMAXDEPTH 500
  1366. X#endif
  1367. X#endif
  1368. Xint yydebug;
  1369. Xint yynerrs;
  1370. Xint yyerrflag;
  1371. Xint yychar;
  1372. Xshort *yyssp;
  1373. XYYSTYPE *yyvsp;
  1374. XYYSTYPE yyval;
  1375. XYYSTYPE yylval;
  1376. Xshort yyss[YYSTACKSIZE];
  1377. XYYSTYPE yyvs[YYSTACKSIZE];
  1378. X#define yystacksize YYSTACKSIZE
  1379. X
  1380. Xvoid
  1381. Xinit_dungeon()
  1382. X{
  1383. X    if(++n_dgns > MAXDUNGEON) {
  1384. X        fprintf(stderr, "FATAL - Too many dungeons (limit: %d).\n",
  1385. X            MAXDUNGEON);
  1386. X        fprintf(stderr, "To increase the limit edit MAXDUNGEON in global.h\n");
  1387. X        exit(1);
  1388. X    }
  1389. X
  1390. X    in_dungeon = 1;
  1391. X    tmpdungeon[n_dgns].lev.base = 0;
  1392. X    tmpdungeon[n_dgns].lev.rand = 0;
  1393. X    tmpdungeon[n_dgns].chance = 100;
  1394. X    strcpy(tmpdungeon[n_dgns].name, "");
  1395. X    strcpy(tmpdungeon[n_dgns].protoname, "");
  1396. X    tmpdungeon[n_dgns].flags = 0;
  1397. X    tmpdungeon[n_dgns].levels = 0;
  1398. X    tmpdungeon[n_dgns].branches = 0;
  1399. X    tmpdungeon[n_dgns].entry_lev = 0;
  1400. X}
  1401. X
  1402. Xvoid
  1403. Xinit_level()
  1404. X{
  1405. X    if(++n_levs > LEV_LIMIT) {
  1406. X
  1407. X        yyerror("FATAL - Too many special levels defined.");
  1408. X        exit(1);
  1409. X    }
  1410. X    tmplevel[n_levs].lev.base = 0;
  1411. X    tmplevel[n_levs].lev.rand = 0;
  1412. X    tmplevel[n_levs].chance = 100;
  1413. X    tmplevel[n_levs].rndlevs = 0;
  1414. X    tmplevel[n_levs].flags = 0;
  1415. X    strcpy(tmplevel[n_levs].name, "");
  1416. X    tmplevel[n_levs].chain = -1;
  1417. X}
  1418. X
  1419. Xvoid
  1420. Xinit_branch()
  1421. X{
  1422. X    if(++n_brs > BRANCH_LIMIT) {
  1423. X
  1424. X        yyerror("FATAL - Too many special levels defined.");
  1425. X        exit(1);
  1426. X    }
  1427. X    tmpbranch[n_brs].lev.base = 0;
  1428. X    tmpbranch[n_brs].lev.rand = 0;
  1429. X    strcpy(tmpbranch[n_brs].name, "");
  1430. X    tmpbranch[n_brs].chain = -1;
  1431. X}
  1432. X
  1433. Xint
  1434. Xgetchain(s)
  1435. X    char    *s;
  1436. X{
  1437. X    int i;
  1438. X
  1439. X    if(strlen(s)) {
  1440. X
  1441. X        for(i = n_levs - tmpdungeon[n_dgns].levels + 1; i <= n_levs; i++)
  1442. X        if(!strcmp(tmplevel[i].name, s)) return i;
  1443. X
  1444. X        yyerror("Can't locate the specified chain level.");
  1445. X        return(-2);
  1446. X    }
  1447. X    return(-1);
  1448. X}
  1449. X
  1450. X/*
  1451. X *    Consistancy checking routines:
  1452. X *
  1453. X *    - A dungeon must have a unique name.
  1454. X *    - A dungeon must have a originating "branch" command
  1455. X *      (except, of course, for the first dungeon).
  1456. X *    - A dungeon must have a proper depth (at least (1, 0)).
  1457. X */
  1458. X
  1459. Xint
  1460. Xcheck_dungeon()
  1461. X{
  1462. X    int i;
  1463. X
  1464. X    for(i = 0; i < n_dgns; i++)
  1465. X        if(!strcmp(tmpdungeon[i].name, tmpdungeon[n_dgns].name)) {
  1466. X        yyerror("Duplicate dungeon name.");
  1467. X        return(0);
  1468. X        }
  1469. X
  1470. X    if(n_dgns)
  1471. X      for(i = 0; i < n_brs - tmpdungeon[n_dgns].branches; i++) {
  1472. X        if(!strcmp(tmpbranch[i].name, tmpdungeon[n_dgns].name)) break;
  1473. X
  1474. X        if(i >= n_brs - tmpdungeon[n_dgns].branches) {
  1475. X        yyerror("Dungeon cannot be reached.");
  1476. X        return(0);
  1477. X        }
  1478. X      }
  1479. X
  1480. X    if(tmpdungeon[n_dgns].lev.base <= 0 ||
  1481. X       tmpdungeon[n_dgns].lev.rand < 0) {
  1482. X        yyerror("Invalid dungeon depth specified.");
  1483. X        return(0);
  1484. X    }
  1485. X    return(1);    /* OK */
  1486. X}
  1487. X
  1488. X/*
  1489. X *    - A level must have a unique level name.
  1490. X *    - If chained, the level used as reference for the chain
  1491. X *      must be in this dungeon, must be previously defined, and
  1492. X *      the level chained from must be "non-probabalistic" (ie.
  1493. X *      have a 100% chance of existing).
  1494. X */
  1495. X
  1496. Xint
  1497. Xcheck_level()
  1498. X{
  1499. X    int i;
  1500. X
  1501. X    if(!in_dungeon) {
  1502. X        yyerror("Level defined outside of dungeon.");
  1503. X        return(0);
  1504. X    }
  1505. X
  1506. X    for(i = 0; i < n_levs; i++)
  1507. X        if(!strcmp(tmplevel[i].name, tmplevel[n_levs].name)) {
  1508. X        yyerror("Duplicate level name.");
  1509. X        return(0);
  1510. X        }
  1511. X
  1512. X    if(tmplevel[i].chain == -2) {
  1513. X        yyerror("Invaild level chain reference.");
  1514. X        return(0);
  1515. X    } else if(tmplevel[i].chain != -1) {    /* there is a chain */
  1516. X        if(tmplevel[tmpbranch[i].chain].chance != 100) {
  1517. X        yyerror("Level cannot chain from a probabalistic level.");
  1518. X        return(0);
  1519. X        } else if(tmplevel[i].chain == n_levs) {
  1520. X        yyerror("A level cannot chain to itself!");
  1521. X        return(0);
  1522. X        }
  1523. X    }
  1524. X    return(1);    /* OK */
  1525. X}
  1526. X
  1527. X/*
  1528. X *    - A branch may not branch backwards - to avoid branch loops.
  1529. X *    - A branch name must be unique.
  1530. X *      (ie. You can only have one entry point to each dungeon).
  1531. X *    - If chained, the level used as reference for the chain
  1532. X *      must be in this dungeon, must be previously defined, and
  1533. X *      the level chained from must be "non-probabalistic" (ie.
  1534. X *      have a 100% chance of existing).
  1535. X */
  1536. X
  1537. Xint
  1538. Xcheck_branch()
  1539. X{
  1540. X    int i;
  1541. X
  1542. X    if(!in_dungeon) {
  1543. X        yyerror("Branch defined outside of dungeon.");
  1544. X        return(0);
  1545. X    }
  1546. X
  1547. X    for(i = 0; i < n_dgns; i++)
  1548. X        if(!strcmp(tmpdungeon[i].name, tmpbranch[n_brs].name)) {
  1549. X
  1550. X        yyerror("Reverse branching not allowed.");
  1551. X        return(0);
  1552. X        }
  1553. X
  1554. X    if(tmpbranch[i].chain == -2) {
  1555. X
  1556. X        yyerror("Invaild branch chain reference.");
  1557. X        return(0);
  1558. X    } else if(tmpbranch[i].chain != -1) {    /* it is chained */
  1559. X
  1560. X        if(tmplevel[tmpbranch[i].chain].chance != 100) {
  1561. X        yyerror("Branch cannot chain from a probabalistic level.");
  1562. X        return(0);
  1563. X        }
  1564. X    }
  1565. X    return(1);    /* OK */
  1566. X}
  1567. X
  1568. X/*
  1569. X *    Output the dungon definition into a file.
  1570. X *
  1571. X *    The file will have the following format:
  1572. X *
  1573. X *    [ number of dungeons ]
  1574. X *    [ first dungeon struct ]
  1575. X *    [ levels for the first dungeon ]
  1576. X *      ...
  1577. X *    [ branches for the first dungeon ]
  1578. X *      ...
  1579. X *    [ second dungeon struct ]
  1580. X *      ...
  1581. X */
  1582. X
  1583. Xvoid
  1584. Xoutput_dgn()
  1585. X{
  1586. X    int    nd, cl = 0, nl = 0,
  1587. X            cb = 0, nb = 0;
  1588. X
  1589. X    if(++n_dgns <= 0) {
  1590. X
  1591. X        yyerror("FATAL - no dungeons were defined.");
  1592. X        exit(1);
  1593. X    }
  1594. X
  1595. X    fwrite((char *)(&n_dgns), sizeof(int), 1, stdout);
  1596. X    for(nd = 0; nd < n_dgns; nd++) {
  1597. X
  1598. X        fwrite((char *)&tmpdungeon[nd], sizeof(struct tmpdungeon), 1,
  1599. X                                stdout);
  1600. X
  1601. X        nl += tmpdungeon[nd].levels;
  1602. X        for(; cl < nl; cl++)
  1603. X        fwrite((char *)&tmplevel[cl], sizeof(struct tmplevel), 1,
  1604. X                                stdout);
  1605. X
  1606. X        nb += tmpdungeon[nd].branches;
  1607. X        for(; cb < nb; cb++)
  1608. X        fwrite((char *)&tmpbranch[cb], sizeof(struct tmpbranch), 1,
  1609. X                                stdout);
  1610. X    }
  1611. X}
  1612. X#define YYABORT goto yyabort
  1613. X#define YYREJECT goto yyabort
  1614. X#define YYACCEPT goto yyaccept
  1615. X#define YYERROR goto yyerrlab
  1616. Xint
  1617. Xyyparse()
  1618. X{
  1619. X    register int yym, yyn, yystate;
  1620. X#if YYDEBUG
  1621. X    register char *yys;
  1622. X    extern char *getenv();
  1623. X
  1624. X    if ((yys = getenv("YYDEBUG")) != 0)
  1625. X    {
  1626. X        yyn = *yys;
  1627. X        if (yyn >= '0' && yyn <= '9')
  1628. X            yydebug = yyn - '0';
  1629. X    }
  1630. X#endif
  1631. X
  1632. X    yynerrs = 0;
  1633. X    yyerrflag = 0;
  1634. X    yychar = (-1);
  1635. X
  1636. X    yyssp = yyss;
  1637. X    yyvsp = yyvs;
  1638. X    *yyssp = yystate = 0;
  1639. X
  1640. Xyyloop:
  1641. X    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
  1642. X    if (yychar < 0)
  1643. X    {
  1644. X        if ((yychar = yylex()) < 0) yychar = 0;
  1645. X#if YYDEBUG
  1646. X        if (yydebug)
  1647. X        {
  1648. X            yys = 0;
  1649. X            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  1650. X            if (!yys) yys = "illegal-symbol";
  1651. X            printf("%sdebug: state %d, reading %d (%s)\n",
  1652. X                    YYPREFIX, yystate, yychar, yys);
  1653. X        }
  1654. X#endif
  1655. X    }
  1656. X    if ((yyn = yysindex[yystate]) != 0 && (yyn += yychar) >= 0 &&
  1657. X            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  1658. X    {
  1659. X#if YYDEBUG
  1660. X        if (yydebug)
  1661. X            printf("%sdebug: state %d, shifting to state %d\n",
  1662. X                    YYPREFIX, yystate, yytable[yyn]);
  1663. X#endif
  1664. X        if (yyssp >= yyss + yystacksize - 1)
  1665. X        {
  1666. X            goto yyoverflow;
  1667. X        }
  1668. X        *++yyssp = yystate = yytable[yyn];
  1669. X        *++yyvsp = yylval;
  1670. X        yychar = (-1);
  1671. X        if (yyerrflag > 0)  --yyerrflag;
  1672. X        goto yyloop;
  1673. X    }
  1674. X    if ((yyn = yyrindex[yystate]) != 0 && (yyn += yychar) >= 0 &&
  1675. X            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  1676. X    {
  1677. X        yyn = yytable[yyn];
  1678. X        goto yyreduce;
  1679. X    }
  1680. X    if (yyerrflag) goto yyinrecovery;
  1681. X#ifdef lint
  1682. X    goto yynewerror;
  1683. X#endif
  1684. Xyynewerror:
  1685. X    yyerror("syntax error");
  1686. X#ifdef lint
  1687. X    goto yyerrlab;
  1688. X#endif
  1689. Xyyerrlab:
  1690. X    ++yynerrs;
  1691. Xyyinrecovery:
  1692. X    if (yyerrflag < 3)
  1693. X    {
  1694. X        yyerrflag = 3;
  1695. X        for (;;)
  1696. X        {
  1697. X            if ((yyn = yysindex[*yyssp]) != 0 && (yyn += YYERRCODE) >= 0 &&
  1698. X                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
  1699. X            {
  1700. X#if YYDEBUG
  1701. X                if (yydebug)
  1702. X                    printf("%sdebug: state %d, error recovery shifting\
  1703. X to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
  1704. X#endif
  1705. X                if (yyssp >= yyss + yystacksize - 1)
  1706. X                {
  1707. X                    goto yyoverflow;
  1708. X                }
  1709. X                *++yyssp = yystate = yytable[yyn];
  1710. X                *++yyvsp = yylval;
  1711. X                goto yyloop;
  1712. X            }
  1713. X            else
  1714. X            {
  1715. X#if YYDEBUG
  1716. X                if (yydebug)
  1717. X                    printf("%sdebug: error recovery discarding state %d\n",
  1718. X                            YYPREFIX, *yyssp);
  1719. X#endif
  1720. X                if (yyssp <= yyss) goto yyabort;
  1721. X                --yyssp;
  1722. X                --yyvsp;
  1723. X            }
  1724. X        }
  1725. X    }
  1726. X    else
  1727. X    {
  1728. X        if (yychar == 0) goto yyabort;
  1729. X#if YYDEBUG
  1730. X        if (yydebug)
  1731. X        {
  1732. X            yys = 0;
  1733. X            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  1734. X            if (!yys) yys = "illegal-symbol";
  1735. X            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
  1736. X                    YYPREFIX, yystate, yychar, yys);
  1737. X        }
  1738. X#endif
  1739. X        yychar = (-1);
  1740. X        goto yyloop;
  1741. X    }
  1742. Xyyreduce:
  1743. X#if YYDEBUG
  1744. X    if (yydebug)
  1745. X        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
  1746. X                YYPREFIX, yystate, yyn, yyrule[yyn]);
  1747. X#endif
  1748. X    yym = yylen[yyn];
  1749. X    yyval = yyvsp[1-yym];
  1750. X    switch (yyn)
  1751. X    {
  1752. Xcase 2:
  1753. X{
  1754. X            output_dgn();
  1755. X          }
  1756. Xbreak;
  1757. Xcase 9:
  1758. X{
  1759. X            init_dungeon();
  1760. X            strcpy(tmpdungeon[n_dgns].name, yyvsp[-3].str);
  1761. X            if (!strcmp(yyvsp[-2].str, "none"))
  1762. X                tmpdungeon[n_levs].boneschar = '\0';
  1763. X            else if (yyvsp[-2].str[1])
  1764. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1765. X            else
  1766. X                tmpdungeon[n_dgns].boneschar = yyvsp[-2].str[0];
  1767. X            tmpdungeon[n_dgns].lev.base = couple.base;
  1768. X            tmpdungeon[n_dgns].lev.rand = couple.rand;
  1769. X            tmpdungeon[n_dgns].chance = yyvsp[0].i;
  1770. X          }
  1771. Xbreak;
  1772. Xcase 10:
  1773. X{
  1774. X            yyval.i = 0;
  1775. X          }
  1776. Xbreak;
  1777. Xcase 11:
  1778. X{
  1779. X            yyval.i = yyvsp[0].i;
  1780. X          }
  1781. Xbreak;
  1782. Xcase 15:
  1783. X{
  1784. X            tmpdungeon[n_dgns].entry_lev = yyvsp[0].i;
  1785. X          }
  1786. Xbreak;
  1787. Xcase 17:
  1788. X{
  1789. X            if(yyvsp[0].i <= TOWN || yyvsp[0].i >= D_ALIGN_CHAOTIC)
  1790. X                yyerror("Illegal description - ignoring!");
  1791. X            else
  1792. X                tmpdungeon[n_dgns].flags |= yyvsp[0].i ;
  1793. X          }
  1794. Xbreak;
  1795. Xcase 18:
  1796. X{
  1797. X            if(yyvsp[0].i && yyvsp[0].i < D_ALIGN_CHAOTIC)
  1798. X                yyerror("Illegal alignment - ignoring!");
  1799. X            else
  1800. X                tmpdungeon[n_dgns].flags |= yyvsp[0].i ;
  1801. X          }
  1802. Xbreak;
  1803. Xcase 19:
  1804. X{
  1805. X            strcpy(tmpdungeon[n_dgns].protoname, yyvsp[0].str);
  1806. X          }
  1807. Xbreak;
  1808. Xcase 25:
  1809. X{
  1810. X            init_level();
  1811. X            strcpy(tmplevel[n_levs].name, yyvsp[-3].str);
  1812. X            if (!strcmp(yyvsp[-2].str, "none"))
  1813. X                tmplevel[n_levs].boneschar = '\0';
  1814. X            else if (yyvsp[-2].str[1])
  1815. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1816. X            else
  1817. X                tmplevel[n_levs].boneschar = yyvsp[-2].str[0];
  1818. X            tmplevel[n_levs].lev.base = couple.base;
  1819. X            tmplevel[n_levs].lev.rand = couple.rand;
  1820. X            tmpdungeon[n_dgns].levels++;
  1821. X          }
  1822. Xbreak;
  1823. Xcase 26:
  1824. X{
  1825. X            init_level();
  1826. X            strcpy(tmplevel[n_levs].name, yyvsp[-4].str);
  1827. X            if (!strcmp(yyvsp[-3].str, "none"))
  1828. X                tmplevel[n_levs].boneschar = '\0';
  1829. X            else if (yyvsp[-3].str[1])
  1830. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1831. X            else
  1832. X                tmplevel[n_levs].boneschar = yyvsp[-3].str[0];
  1833. X            tmplevel[n_levs].lev.base = couple.base;
  1834. X            tmplevel[n_levs].lev.rand = couple.rand;
  1835. X            tmplevel[n_levs].rndlevs = yyvsp[0].i;
  1836. X            tmpdungeon[n_dgns].levels++;
  1837. X          }
  1838. Xbreak;
  1839. Xcase 27:
  1840. X{
  1841. X            init_level();
  1842. X            strcpy(tmplevel[n_levs].name, yyvsp[-4].str);
  1843. X            if (!strcmp(yyvsp[-3].str, "none"))
  1844. X                tmplevel[n_levs].boneschar = '\0';
  1845. X            else if (yyvsp[-3].str[1])
  1846. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1847. X            else
  1848. X                tmplevel[n_levs].boneschar = yyvsp[-3].str[0];
  1849. X            tmplevel[n_levs].lev.base = couple.base;
  1850. X            tmplevel[n_levs].lev.rand = couple.rand;
  1851. X            tmplevel[n_levs].chance = yyvsp[0].i;
  1852. X            tmpdungeon[n_dgns].levels++;
  1853. X          }
  1854. Xbreak;
  1855. Xcase 28:
  1856. X{
  1857. X            init_level();
  1858. X            strcpy(tmplevel[n_levs].name, yyvsp[-5].str);
  1859. X            if (!strcmp(yyvsp[-4].str, "none"))
  1860. X                tmplevel[n_levs].boneschar = '\0';
  1861. X            else if (yyvsp[-4].str[1])
  1862. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1863. X            else
  1864. X                tmplevel[n_levs].boneschar = yyvsp[-4].str[0];
  1865. X            tmplevel[n_levs].lev.base = couple.base;
  1866. X            tmplevel[n_levs].lev.rand = couple.rand;
  1867. X            tmplevel[n_levs].chance = yyvsp[-1].i;
  1868. X            tmplevel[n_levs].rndlevs = yyvsp[0].i;
  1869. X            tmpdungeon[n_dgns].levels++;
  1870. X          }
  1871. Xbreak;
  1872. Xcase 29:
  1873. X{
  1874. X            if(yyvsp[0].i >= D_ALIGN_CHAOTIC)
  1875. X                yyerror("Illegal description - ignoring!");
  1876. X            else
  1877. X                tmplevel[n_levs].flags |= yyvsp[0].i ;
  1878. X          }
  1879. Xbreak;
  1880. Xcase 30:
  1881. X{
  1882. X            if(yyvsp[0].i && yyvsp[0].i < D_ALIGN_CHAOTIC)
  1883. X                yyerror("Illegal alignment - ignoring!");
  1884. X            else
  1885. X                tmplevel[n_levs].flags |= yyvsp[0].i ;
  1886. X          }
  1887. Xbreak;
  1888. Xcase 31:
  1889. X{
  1890. X            init_level();
  1891. X            strcpy(tmplevel[n_levs].name, yyvsp[-4].str);
  1892. X            if (!strcmp(yyvsp[-3].str, "none"))
  1893. X                tmplevel[n_levs].boneschar = '\0';
  1894. X            else if (yyvsp[-3].str[1])
  1895. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1896. X            else
  1897. X                tmplevel[n_levs].boneschar = yyvsp[-3].str[0];
  1898. X            tmplevel[n_levs].chain = getchain(yyvsp[-2].str);
  1899. X            tmplevel[n_levs].lev.base = couple.base;
  1900. X            tmplevel[n_levs].lev.rand = couple.rand;
  1901. X            if(!check_level()) n_levs--;
  1902. X            else tmpdungeon[n_dgns].levels++;
  1903. X          }
  1904. Xbreak;
  1905. Xcase 32:
  1906. X{
  1907. X            init_level();
  1908. X            strcpy(tmplevel[n_levs].name, yyvsp[-5].str);
  1909. X            if (!strcmp(yyvsp[-4].str, "none"))
  1910. X                tmplevel[n_levs].boneschar = '\0';
  1911. X            else if (yyvsp[-4].str[1])
  1912. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1913. X            else
  1914. X                tmplevel[n_levs].boneschar = yyvsp[-4].str[0];
  1915. X            tmplevel[n_levs].chain = getchain(yyvsp[-3].str);
  1916. X            tmplevel[n_levs].lev.base = couple.base;
  1917. X            tmplevel[n_levs].lev.rand = couple.rand;
  1918. X            tmplevel[n_levs].rndlevs = yyvsp[0].i;
  1919. X            if(!check_level()) n_levs--;
  1920. X            else tmpdungeon[n_dgns].levels++;
  1921. X          }
  1922. Xbreak;
  1923. Xcase 33:
  1924. X{
  1925. X            init_level();
  1926. X            strcpy(tmplevel[n_levs].name, yyvsp[-5].str);
  1927. X            if (!strcmp(yyvsp[-4].str, "none"))
  1928. X                tmplevel[n_levs].boneschar = '\0';
  1929. X            else if (yyvsp[-4].str[1])
  1930. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1931. X            else
  1932. X                tmplevel[n_levs].boneschar = yyvsp[-4].str[0];
  1933. X            tmplevel[n_levs].chain = getchain(yyvsp[-3].str);
  1934. X            tmplevel[n_levs].lev.base = couple.base;
  1935. X            tmplevel[n_levs].lev.rand = couple.rand;
  1936. X            tmplevel[n_levs].chance = yyvsp[0].i;
  1937. X            if(!check_level()) n_levs--;
  1938. X            else tmpdungeon[n_dgns].levels++;
  1939. X          }
  1940. Xbreak;
  1941. Xcase 34:
  1942. X{
  1943. X            init_level();
  1944. X            strcpy(tmplevel[n_levs].name, yyvsp[-6].str);
  1945. X            if (!strcmp(yyvsp[-5].str, "none"))
  1946. X                tmplevel[n_levs].boneschar = '\0';
  1947. X            else if (yyvsp[-5].str[1])
  1948. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1949. X            else
  1950. X                tmplevel[n_levs].boneschar = yyvsp[-5].str[0];
  1951. X            tmplevel[n_levs].chain = getchain(yyvsp[-4].str);
  1952. X            tmplevel[n_levs].lev.base = couple.base;
  1953. X            tmplevel[n_levs].lev.rand = couple.rand;
  1954. X            tmplevel[n_levs].chance = yyvsp[-1].i;
  1955. X            tmplevel[n_levs].rndlevs = yyvsp[0].i;
  1956. X            if(!check_level()) n_levs--;
  1957. X            else tmpdungeon[n_dgns].levels++;
  1958. X          }
  1959. Xbreak;
  1960. Xcase 37:
  1961. X{
  1962. X            init_branch();
  1963. X            strcpy(tmpbranch[n_brs].name, yyvsp[-4].str);
  1964. X            tmpbranch[n_brs].lev.base = couple.base;
  1965. X            tmpbranch[n_brs].lev.rand = couple.rand;
  1966. X            tmpbranch[n_brs].type = yyvsp[-1].i;
  1967. X            tmpbranch[n_brs].up = yyvsp[0].i;
  1968. X            if(!check_branch()) n_brs--;
  1969. X            else tmpdungeon[n_dgns].branches++;
  1970. X          }
  1971. Xbreak;
  1972. Xcase 38:
  1973. X{
  1974. X            init_branch();
  1975. X            strcpy(tmpbranch[n_brs].name, yyvsp[-5].str);
  1976. X            tmpbranch[n_brs].chain = getchain(yyvsp[-4].str);
  1977. X            tmpbranch[n_brs].lev.base = couple.base;
  1978. X            tmpbranch[n_brs].lev.rand = couple.rand;
  1979. X            tmpbranch[n_brs].type = yyvsp[-1].i;
  1980. X            tmpbranch[n_brs].up = yyvsp[0].i;
  1981. X            if(!check_branch()) n_brs--;
  1982. X            else tmpdungeon[n_dgns].branches++;
  1983. X          }
  1984. Xbreak;
  1985. Xcase 39:
  1986. X{
  1987. X            yyval.i = TBR_STAIR;    /* two way stair */
  1988. X          }
  1989. Xbreak;
  1990. Xcase 40:
  1991. X{
  1992. X            yyval.i = TBR_STAIR;    /* two way stair */
  1993. X          }
  1994. Xbreak;
  1995. Xcase 41:
  1996. X{
  1997. X            yyval.i = TBR_NO_UP;    /* no up staircase */
  1998. X          }
  1999. Xbreak;
  2000. Xcase 42:
  2001. X{
  2002. X            yyval.i = TBR_NO_DOWN;    /* no down staircase */
  2003. X          }
  2004. Xbreak;
  2005. Xcase 43:
  2006. X{
  2007. X            yyval.i = TBR_PORTAL;    /* portal connection */
  2008. X          }
  2009. Xbreak;
  2010. Xcase 44:
  2011. X{
  2012. X            yyval.i = 0;    /* defaults to down */
  2013. X          }
  2014. Xbreak;
  2015. Xcase 45:
  2016. X{
  2017. X            yyval.i = yyvsp[0].i;
  2018. X          }
  2019. Xbreak;
  2020. Xcase 46:
  2021. X{
  2022. X            if (yyvsp[-3].i < -MAXLEVEL || yyvsp[-3].i > MAXLEVEL) {
  2023. X                yyerror("Abs base out of dlevel range - zeroing!");
  2024. X                couple.base = couple.rand = 0;
  2025. X            } else if (yyvsp[-1].i < -1 ||
  2026. X                ((yyvsp[-3].i < 0) ? (MAXLEVEL + yyvsp[-3].i + yyvsp[-1].i + 1) > MAXLEVEL :
  2027. X                    (yyvsp[-3].i + yyvsp[-1].i) > MAXLEVEL)) {
  2028. X                yyerror("Abs range out of dlevel range - zeroing!");
  2029. X                couple.base = couple.rand = 0;
  2030. X            } else {
  2031. X                couple.base = yyvsp[-3].i;
  2032. X                couple.rand = yyvsp[-1].i;
  2033. X            }
  2034. X          }
  2035. Xbreak;
  2036. Xcase 47:
  2037. X{
  2038. X            if (yyvsp[-3].i < -MAXLEVEL || yyvsp[-3].i > MAXLEVEL) {
  2039. X                yyerror("Rel base out of dlevel range - zeroing!");
  2040. X                couple.base = couple.rand = 0;
  2041. X            } else {
  2042. X                couple.base = yyvsp[-3].i;
  2043. X                couple.rand = yyvsp[-1].i;
  2044. X            }
  2045. X          }
  2046. Xbreak;
  2047. X    }
  2048. X    yyssp -= yym;
  2049. X    yystate = *yyssp;
  2050. X    yyvsp -= yym;
  2051. X    yym = yylhs[yyn];
  2052. X    if (yystate == 0 && yym == 0)
  2053. X    {
  2054. X#if YYDEBUG
  2055. X        if (yydebug)
  2056. X            printf("%sdebug: after reduction, shifting from state 0 to\
  2057. X state %d\n", YYPREFIX, YYFINAL);
  2058. X#endif
  2059. X        yystate = YYFINAL;
  2060. X        *++yyssp = YYFINAL;
  2061. X        *++yyvsp = yyval;
  2062. X        if (yychar < 0)
  2063. X        {
  2064. X            if ((yychar = yylex()) < 0) yychar = 0;
  2065. X#if YYDEBUG
  2066. X            if (yydebug)
  2067. X            {
  2068. X                yys = 0;
  2069. X                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  2070. X                if (!yys) yys = "illegal-symbol";
  2071. X                printf("%sdebug: state %d, reading %d (%s)\n",
  2072. X                        YYPREFIX, YYFINAL, yychar, yys);
  2073. X            }
  2074. X#endif
  2075. X        }
  2076. X        if (yychar == 0) goto yyaccept;
  2077. X        goto yyloop;
  2078. X    }
  2079. X    if ((yyn = yygindex[yym]) != 0 && (yyn += yystate) >= 0 &&
  2080. X            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
  2081. X        yystate = yytable[yyn];
  2082. X    else
  2083. X        yystate = yydgoto[yym];
  2084. X#if YYDEBUG
  2085. X    if (yydebug)
  2086. X        printf("%sdebug: after reduction, shifting from state %d \
  2087. Xto state %d\n", YYPREFIX, *yyssp, yystate);
  2088. X#endif
  2089. X    if (yyssp >= yyss + yystacksize - 1)
  2090. X    {
  2091. X        goto yyoverflow;
  2092. X    }
  2093. X    *++yyssp = yystate;
  2094. X    *++yyvsp = yyval;
  2095. X    goto yyloop;
  2096. Xyyoverflow:
  2097. X    yyerror("yacc stack overflow");
  2098. Xyyabort:
  2099. X    return (1);
  2100. Xyyaccept:
  2101. X    return (0);
  2102. X}
  2103. END_OF_FILE
  2104. if test 30875 -ne `wc -c <'sys/share/dgn_yacc.c'`; then
  2105.     echo shar: \"'sys/share/dgn_yacc.c'\" unpacked with wrong size!
  2106. fi
  2107. # end of 'sys/share/dgn_yacc.c'
  2108. echo shar: End of archive 15 \(of 18\).
  2109. cp /dev/null ark15isdone
  2110. MISSING=""
  2111. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; do
  2112.     if test ! -f ark${I}isdone ; then
  2113.     MISSING="${MISSING} ${I}"
  2114.     fi
  2115. done
  2116. if test "${MISSING}" = "" ; then
  2117.     echo You have unpacked all 18 archives.
  2118.     echo "Now execute ./patchit3.sh"
  2119.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2120. else
  2121.     echo You still need to unpack the following archives:
  2122.     echo "        " ${MISSING}
  2123. fi
  2124. ##  End of shell archive.
  2125. exit 0
  2126.