home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume14 / umoria4 / part30 < prev    next >
Text File  |  1992-08-31  |  58KB  |  2,241 lines

  1. Path: uunet!zephyr.ens.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v14i062:  umoria4 - single player dungeon simulation (ver. 5.5), Part30/39
  5. Message-ID: <3426@master.CNA.TEK.COM>
  6. Date: 22 Aug 92 22:14:17 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 2230
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: grabiner@math.harvard.edu (David Grabiner)
  12. Posting-number: Volume 14, Issue 62
  13. Archive-name: umoria4/Part30
  14. Supersedes: umoria3: Volume 9, Issue 55-97; Volume 10, Issue 15-17
  15. Environment: Curses, Unix, Mac, MS-DOS, Atari-ST, Amiga, VMS
  16.  
  17.  
  18.  
  19. #! /bin/sh
  20. # This is a shell archive.  Remove anything before this line, then unpack
  21. # it by saving it into a file and typing "sh file".  To overwrite existing
  22. # files, type "sh file -c".  You can also feed this as standard input via
  23. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  24. # will see the following message at the end:
  25. #        "End of archive 30 (of 39)."
  26. # Contents:  mac/dumpres/TestDR.c mac/macio.c source/create.c
  27. #   source/main.c source/types.h
  28. # Wrapped by billr@saab on Thu Aug 20 09:11:34 1992
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. if test -f 'mac/dumpres/TestDR.c' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'mac/dumpres/TestDR.c'\"
  32. else
  33. echo shar: Extracting \"'mac/dumpres/TestDR.c'\" \(1358 characters\)
  34. sed "s/^X//" >'mac/dumpres/TestDR.c' <<'END_OF_FILE'
  35. X/* mac/dumpres/TestDR.c: test driver for resource dumping code
  36. X
  37. X   Copyright (c) 1989-1991 Curtis McCauley, James E. Wilson
  38. X
  39. X   This software may be copied and distributed for educational, research, and
  40. X   not for profit purposes provided that this copyright and statement are
  41. X   included in all such copies. */
  42. X
  43. X#include <StdIO.h>
  44. X
  45. X#ifndef THINK_C
  46. X#include <Resources.h>
  47. X#endif
  48. X
  49. X#include "DumpRes.h"
  50. X
  51. Xtypedef struct {
  52. X    char *name;
  53. X    int x, y, z;
  54. X} Test;
  55. X
  56. XTest table[5] = {
  57. X    { "Huron", 1, 2, 3 },
  58. X    { "Ontario", 4, 5, 6 },
  59. X    { "Michigan", 7, 8, 9 },
  60. X    { "Erie", 10, 11, 12 },
  61. X    { "Superior", 13, 14, 15 }
  62. X};
  63. X
  64. XTest *data;
  65. X
  66. Xvoid MyStrProc(ptr, proc)
  67. Xchar *ptr;
  68. Xvoid (*proc)(char **);
  69. X
  70. X{
  71. X    (*proc)(&((Test *) ptr)->name);
  72. X    return;
  73. X}
  74. X
  75. Xmain()
  76. X
  77. X{
  78. X    short resFile;
  79. X    long i, rc;
  80. X
  81. X    DumpRes(
  82. X        "DumpResTest.rsrc",
  83. X        'TEST', 256, "Test Data", 0,
  84. X        (char *) table, 5, sizeof(Test),
  85. X        MyStrProc
  86. X    );
  87. X
  88. X    resFile = OpenResFile("\pDumpResTest.rsrc");
  89. X
  90. X    if (resFile != -1) {
  91. X
  92. X        data = NULL;
  93. X
  94. X        rc = LoadRes(
  95. X            (char **) &data),
  96. X            'TEST', 256,
  97. X            5, sizeof(Test),
  98. X            MyStrProc
  99. X        );
  100. X
  101. X        if (rc)
  102. X            for (i = 0; i < 5; i++)
  103. X                fprintf(stderr, "%s : %d %d %d\n",
  104. X                    data[i].name, data[i].x, data[i].y,
  105. X                    data[i].z);
  106. X
  107. X        else
  108. X            fprintf(stderr, "LoadRes failed.\n");
  109. X
  110. X        CloseResFile(resFile);
  111. X
  112. X    }
  113. X
  114. X    else
  115. X        fprintf(stderr, "Unable to open file for LoadRes testing.\n");
  116. X
  117. X    return(0);
  118. X}
  119. END_OF_FILE
  120. if test 1358 -ne `wc -c <'mac/dumpres/TestDR.c'`; then
  121.     echo shar: \"'mac/dumpres/TestDR.c'\" unpacked with wrong size!
  122. fi
  123. # end of 'mac/dumpres/TestDR.c'
  124. fi
  125. if test -f 'mac/macio.c' -a "${1}" != "-c" ; then 
  126.   echo shar: Will not clobber existing file \"'mac/macio.c'\"
  127. else
  128. echo shar: Extracting \"'mac/macio.c'\" \(12528 characters\)
  129. sed "s/^X//" >'mac/macio.c' <<'END_OF_FILE'
  130. X/* mac/macio.c: terminal I/O code for the macintosh
  131. X
  132. X   Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  133. X
  134. X   This software may be copied and distributed for educational, research, and
  135. X   not for profit purposes provided that this copyright and statement are
  136. X   included in all such copies. */
  137. X
  138. X#ifdef THINK_C
  139. X#include "ScrnMgr.h"
  140. X#else
  141. X#include <scrnmgr.h>
  142. X#endif
  143. X
  144. X#include <ctype.h>
  145. X#include <string.h>
  146. X
  147. X#include "config.h"
  148. X#include "constant.h"
  149. X#include "types.h"
  150. X#include "externs.h"
  151. X
  152. X
  153. Xvoid exit();
  154. Xunsigned sleep();
  155. X
  156. X/* Attributes of normal and hilighted characters */
  157. X#define ATTR_NORMAL    attrNormal
  158. X#define ATTR_HILITED    attrReversed
  159. X
  160. X/* initializes curses routines */
  161. Xvoid init_curses()
  162. X{
  163. X  /* Primary initialization is done in mac.c since game is restartable */
  164. X  /* Only need to clear the screen here */
  165. X  Rect scrn;
  166. X
  167. X  scrn.left = scrn.top = 0;
  168. X  scrn.right = SCRN_COLS;
  169. X  scrn.bottom = SCRN_ROWS;
  170. X  EraseScreen(&scrn);
  171. X  UpdateScreen();
  172. X}
  173. X
  174. X/* Set up the terminal into a suitable state for moria.     -CJS- */
  175. Xvoid moriaterm()
  176. X/* Nothing to do on Mac */
  177. X{
  178. X}
  179. X
  180. X/* Dump IO to buffer                    -RAK-    */
  181. Xvoid put_buffer(out_str, row, col)
  182. Xchar *out_str;
  183. Xint row, col;
  184. X{
  185. X  /* The screen manager handles writes past the edge ok */
  186. X  DSetScreenCursor(col, row);
  187. X  DWriteScreenStringAttr(out_str, ATTR_NORMAL);
  188. X}
  189. X
  190. X/* Dump the IO buffer to terminal            -RAK-    */
  191. Xvoid put_qio()
  192. X{
  193. X  screen_change = TRUE;       /* Let inven_command know something has changed. */
  194. X  UpdateScreen();
  195. X}
  196. X
  197. X/* Put the terminal in the original mode.               -CJS- */
  198. Xvoid restore_term()
  199. X/* Nothing to do on Mac */
  200. X{
  201. X}
  202. X
  203. Xvoid shell_out()
  204. X{
  205. X  alert_error("This command is not implemented on the Macintosh.");
  206. X}
  207. X
  208. X/* Returns a single character input from the terminal.    This silently -CJS-
  209. X   consumes ^R to redraw the screen and reset the terminal, so that this
  210. X   operation can always be performed at any input prompt.  inkey() never
  211. X   returns ^R.    */
  212. Xchar inkey()
  213. X/* The Mac does not need ^R, so it just consumes it */
  214. X/* This routine does nothing special with direction keys */
  215. X/* Just returns their keypad ascii value (e.g. '0'-'9') */
  216. X/* Compare with inkeydir() below */
  217. X{
  218. X  char ch;
  219. X  int dir;
  220. X  int shift_flag, ctrl_flag;
  221. X
  222. X  put_qio();
  223. X  command_count = 0;
  224. X
  225. X  do {
  226. X    macgetkey(&ch, FALSE);
  227. X  } while (ch == CTRL('R'));
  228. X
  229. X  dir = extractdir(ch, &shift_flag, &ctrl_flag);
  230. X  if (dir != -1)
  231. X    ch = '0' + dir;
  232. X
  233. X  return(ch);
  234. X}
  235. X
  236. Xchar inkeydir()
  237. X/* The Mac does not need ^R, so it just consumes it */
  238. X/* This routine translates the direction keys in rogue-like mode */
  239. X{
  240. X  char ch;
  241. X  int dir;
  242. X  int shift_flag, ctrl_flag;
  243. X  static char tab[9] = {
  244. X    'b',        'j',        'n',
  245. X    'h',        '.',        'l',
  246. X    'y',        'k',        'u'
  247. X  };
  248. X  static char shifttab[9] = {
  249. X    'B',        'J',        'N',
  250. X    'H',        '.',        'L',
  251. X    'Y',        'K',        'U'
  252. X  };
  253. X  static char ctrltab[9] = {
  254. X    CTRL('B'),    CTRL('J'),    CTRL('N'),
  255. X    CTRL('H'),    '.',        CTRL('L'),
  256. X    CTRL('Y'),    CTRL('K'),    CTRL('U')
  257. X  };
  258. X
  259. X  put_qio();
  260. X  command_count = 0;
  261. X
  262. X  do {
  263. X    macgetkey(&ch, FALSE);
  264. X  } while (ch == CTRL('R'));
  265. X
  266. X  dir = extractdir(ch, &shift_flag, &ctrl_flag);
  267. X
  268. X  if (dir != -1) {
  269. X    if (!rogue_like_commands) {
  270. X      ch = '0' + dir;
  271. X    }
  272. X    else {
  273. X      if (ctrl_flag)
  274. X    ch = ctrltab[dir - 1];
  275. X      else if (shift_flag)
  276. X    ch = shifttab[dir - 1];
  277. X      else
  278. X    ch = tab[dir - 1];
  279. X    }
  280. X  }
  281. X
  282. X  return(ch);
  283. X}
  284. X
  285. X/* Flush the buffer                    -RAK-    */
  286. Xvoid flush()
  287. X{
  288. X/* Removed put_qio() call.  Reduces flashing.  Doesn't seem to hurt. */
  289. X  FlushScreenKeys();
  290. X}
  291. X
  292. X/* Clears given line of text                -RAK-    */
  293. Xvoid erase_line(row, col)
  294. Xint row;
  295. Xint col;
  296. X{
  297. X  Rect line;
  298. X
  299. X  if (row == MSG_LINE && msg_flag)
  300. X    msg_print(NULL);
  301. X
  302. X  line.left = col;
  303. X  line.top = row;
  304. X  line.right = SCRN_COLS;
  305. X  line.bottom = row + 1;
  306. X  DEraseScreen(&line);
  307. X}
  308. X
  309. X/* Clears screen */
  310. Xvoid clear_screen()
  311. X{
  312. X  Rect area;
  313. X
  314. X  if (msg_flag)
  315. X    msg_print(NULL);
  316. X
  317. X  area.left = area.top = 0;
  318. X  area.right = SCRN_COLS;
  319. X  area.bottom = SCRN_ROWS;
  320. X  DEraseScreen(&area);
  321. X}
  322. X
  323. Xvoid clear_from (row)
  324. Xint row;
  325. X{
  326. X  Rect area;
  327. X
  328. X  area.left = 0;
  329. X  area.top = row;
  330. X  area.right = SCRN_COLS;
  331. X  area.bottom = SCRN_ROWS;
  332. X  DEraseScreen(&area);
  333. X}
  334. X
  335. X/* Outputs a char to a given interpolated y, x position    -RAK-    */
  336. X/* sign bit of a character used to indicate standout mode. -CJS */
  337. Xvoid print(ch, row, col)
  338. Xchar ch;
  339. Xint row;
  340. Xint col;
  341. X{
  342. X  char cnow, anow, cnew, anew;
  343. X
  344. X  row -= panel_row_prt;/* Real co-ords convert to screen positions */
  345. X  col -= panel_col_prt;
  346. X
  347. X  if (ch & 0x80) {
  348. X    cnew = ch & ~0x80;
  349. X    anew = ATTR_HILITED;
  350. X  }
  351. X  else {
  352. X    cnew = ch;
  353. X    anew = ATTR_NORMAL;
  354. X  }
  355. X
  356. X  GetScreenCharAttr(&cnow, &anow, col, row);    /* Check current */
  357. X
  358. X  if ((cnow != ch) || (anow != anew))    /* If char is already set, ignore op */
  359. X    DSetScreenCharAttr(cnew, anew, col, row);
  360. X}
  361. X
  362. X/* Moves the cursor to a given interpolated y, x position    -RAK-    */
  363. Xvoid move_cursor_relative(row, col)
  364. Xint row;
  365. Xint col;
  366. X{
  367. X  row -= panel_row_prt;/* Real co-ords convert to screen positions */
  368. X  col -= panel_col_prt;
  369. X
  370. X  DSetScreenCursor(col, row);
  371. X}
  372. X
  373. X/* Print a message so as not to interrupt a counted command. -CJS- */
  374. Xvoid count_msg_print(p)
  375. Xchar *p;
  376. X{
  377. X  int i;
  378. X
  379. X  i = command_count;
  380. X  msg_print(p);
  381. X  command_count = i;
  382. X}
  383. X
  384. X/* Outputs a line to a given y, x position        -RAK-    */
  385. Xvoid prt(str_buff, row, col)
  386. Xchar *str_buff;
  387. Xint row;
  388. Xint col;
  389. X{
  390. X  Rect line;
  391. X
  392. X  if (row == MSG_LINE && msg_flag)
  393. X    msg_print(NULL);
  394. X
  395. X  line.left = col;
  396. X  line.top = row;
  397. X  line.right = SCRN_COLS;
  398. X  line.bottom = row + 1;
  399. X  DEraseScreen(&line);
  400. X
  401. X  put_buffer(str_buff, row, col);
  402. X}
  403. X
  404. X/* move cursor to a given y, x position */
  405. Xvoid move_cursor(row, col)
  406. Xint row, col;
  407. X{
  408. X  DSetScreenCursor(col, row);
  409. X}
  410. X
  411. X/* Outputs message to top line of screen                */
  412. X/* These messages are kept for later reference.     */
  413. Xvoid msg_print(str_buff)
  414. Xchar *str_buff;
  415. X{
  416. X  register int old_len;
  417. X  char in_char;
  418. X  Rect line;
  419. X
  420. X  if (msg_flag)
  421. X    {
  422. X      old_len = strlen(old_msg[last_msg]) + 1;
  423. X      /* ensure that the complete -more- message is visible. */
  424. X      if (old_len > 73)
  425. X    old_len = 73;
  426. X      put_buffer(" -more-", MSG_LINE, old_len);
  427. X      /* let sigint handler know that we are waiting for a space */
  428. X      wait_for_more = 1;
  429. X      do
  430. X    {
  431. X      in_char = inkey();
  432. X    }
  433. X      while ((in_char != ' ') && (in_char != ESCAPE) && (in_char != '\n') &&
  434. X         (in_char != '\r'));
  435. X      wait_for_more = 0;
  436. X    }
  437. X  line.left = 0;
  438. X  line.top = MSG_LINE;
  439. X  line.right = SCRN_COLS;
  440. X  line.bottom = MSG_LINE+1;
  441. X  DEraseScreen(&line);
  442. X
  443. X  /* Make the null string a special case.  -CJS- */
  444. X  if (str_buff)
  445. X    {
  446. X      put_buffer(str_buff, MSG_LINE, 0);
  447. X      command_count = 0;
  448. X      last_msg++;
  449. X      if (last_msg >= MAX_SAVE_MSG)
  450. X    last_msg = 0;
  451. X      (void) strncpy(old_msg[last_msg], str_buff, VTYPESIZ);
  452. X      old_msg[last_msg][VTYPESIZ - 1] = '\0';
  453. X      msg_flag = TRUE;
  454. X    }
  455. X  else
  456. X    msg_flag = FALSE;
  457. X}
  458. X
  459. X/* Used to verify a choice - user gets the chance to abort choice.  -CJS- */
  460. Xint get_check(prompt)
  461. Xchar *prompt;
  462. X{
  463. X  int res;
  464. X  long x, y;
  465. X
  466. X  prt(prompt, 0, 0);
  467. X  GetScreenCursor(&x, &y);
  468. X  if (x > 73)
  469. X    DSetScreenCursor(73, y);
  470. X  DWriteScreenStringAttr(" [y/n]", ATTR_NORMAL);
  471. X  do
  472. X    {
  473. X      res = inkey();
  474. X    }
  475. X  while(res == ' ');
  476. X  erase_line(0, 0);
  477. X  if (res == 'Y' || res == 'y')
  478. X    return TRUE;
  479. X  else
  480. X    return FALSE;
  481. X}
  482. X
  483. X/* Prompts (optional) and returns ord value of input char    */
  484. X/* Function returns false if <ESCAPE> is input    */
  485. Xint get_com(prompt, command)
  486. Xchar *prompt;
  487. Xchar *command;
  488. X{
  489. X  int res;
  490. X
  491. X  if (prompt)
  492. X    prt(prompt, 0, 0);
  493. X  *command = inkey();
  494. X  if (*command == 0 || *command == ESCAPE)
  495. X    res = FALSE;
  496. X  else
  497. X    res = TRUE;
  498. X  erase_line(MSG_LINE, 0);
  499. X  return(res);
  500. X}
  501. X
  502. X/* Same as get_com(), but translates direction keys from keypad */
  503. Xint get_comdir(prompt, command)
  504. Xchar *prompt;
  505. Xchar *command;
  506. X{
  507. X  int res;
  508. X
  509. X  if (prompt)
  510. X    prt(prompt, 0, 0);
  511. X  *command = inkeydir();
  512. X  if (*command == 0 || *command == ESCAPE)
  513. X    res = FALSE;
  514. X  else
  515. X    res = TRUE;
  516. X  erase_line(MSG_LINE, 0);
  517. X  return(res);
  518. X}
  519. X
  520. X/* Gets a string terminated by <RETURN>        */
  521. X/* Function returns false if <ESCAPE> is input    */
  522. Xint get_string(in_str, row, column, slen)
  523. Xchar *in_str;
  524. Xint row, column, slen;
  525. X{
  526. X  register int start_col, end_col, i;
  527. X  char *p;
  528. X  int flag, abort;
  529. X  Rect area;
  530. X
  531. X  abort = FALSE;
  532. X  flag    = FALSE;
  533. X  area.left = column;
  534. X  area.top = row;
  535. X  area.right = column + slen;
  536. X  area.bottom = row + 1;
  537. X  DEraseScreen(&area);
  538. X  DSetScreenCursor(column, row);
  539. X  start_col = column;
  540. X  end_col = column + slen - 1;
  541. X  if (end_col > 79)
  542. X    {
  543. X      slen = 80 - column;
  544. X      end_col = 79;
  545. X    }
  546. X  p = in_str;
  547. X  do
  548. X    {
  549. X      i = inkey();
  550. X      switch(i)
  551. X    {
  552. X    case ESCAPE:
  553. X      abort = TRUE;
  554. X      break;
  555. X    case CTRL('J'): case CTRL('M'):
  556. X      flag    = TRUE;
  557. X      break;
  558. X    case DELETE: case CTRL('H'):
  559. X      if (column > start_col)
  560. X        {
  561. X          column--;
  562. X          put_buffer(" ", row, column);
  563. X          move_cursor(row, column);
  564. X          *--p = '\0';
  565. X        }
  566. X      break;
  567. X    default:
  568. X      if (!isprint(i) || column > end_col)
  569. X        bell();
  570. X      else
  571. X        {
  572. X          DSetScreenCursor(column, row);
  573. X          DWriteScreenCharAttr((char) i, ATTR_NORMAL);
  574. X          *p++ = i;
  575. X          column++;
  576. X        }
  577. X      break;
  578. X    }
  579. X    }
  580. X  while ((!flag) && (!abort));
  581. X  if (abort)
  582. X    return(FALSE);
  583. X  /* Remove trailing blanks    */
  584. X  while (p > in_str && p[-1] == ' ')
  585. X    p--;
  586. X  *p = '\0';
  587. X  return(TRUE);
  588. X}
  589. X
  590. X/* Pauses for user response before returning        -RAK-    */
  591. Xvoid pause_line(prt_line)
  592. Xint prt_line;
  593. X{
  594. X  prt("[Press any key to continue.]", prt_line, 23);
  595. X  (void) inkey();
  596. X  erase_line(prt_line, 0);
  597. X}
  598. X
  599. X/* Pauses for user response before returning        -RAK-    */
  600. X/* NOTE: Delay is for players trying to roll up "perfect"    */
  601. X/*    characters.  Make them wait a bit.            */
  602. Xvoid pause_exit(prt_line, delay)
  603. Xint prt_line;
  604. Xint delay;
  605. X{
  606. X  char dummy;
  607. X
  608. X  prt("[Press any key to continue, or Q to exit.]", prt_line, 10);
  609. X  dummy = inkey();
  610. X  if (dummy == 'Q')
  611. X    {
  612. X      erase_line(prt_line, 0);
  613. X      if (delay > 0)  (void) sleep((unsigned)delay);
  614. X      exit_game();
  615. X    }
  616. X  erase_line(prt_line, 0);
  617. X}
  618. X
  619. Xvoid save_screen()
  620. X{
  621. X  mac_save_screen();
  622. X}
  623. X
  624. Xvoid restore_screen()
  625. X{
  626. X  mac_restore_screen();
  627. X}
  628. X
  629. Xvoid bell()
  630. X{
  631. X  put_qio();
  632. X  if (! sound_beep_flag)
  633. X    return;
  634. X  mac_beep();
  635. X}
  636. X
  637. X/* definitions used by screen_map() */
  638. X/* index into border character array */
  639. X#define TL 0    /* top left */
  640. X#define TR 1
  641. X#define BL 2
  642. X#define BR 3
  643. X#define HE 4    /* horizontal edge */
  644. X#define VE 5
  645. X
  646. X/* Display highest priority object in the RATIO by RATIO area */
  647. X#define    RATIO 3
  648. X
  649. Xvoid screen_map()
  650. X{
  651. X  register int    i, j;
  652. X  static int8u border[6] = {
  653. X    '+', '+', '+', '+', '-', '|'    /* normal chars */
  654. X  };
  655. X  int8u map[MAX_WIDTH / RATIO + 1];
  656. X  int8u tmp;
  657. X  int priority[256];
  658. X  int row, orow, col, myrow, mycol = 0;
  659. X
  660. X  for (i = 0; i < 256; i++)
  661. X    priority[i] = 0;
  662. X  priority['<'] = 5;
  663. X  priority['>'] = 5;
  664. X  priority['@'] = 10;
  665. X  priority['#'] = -5;
  666. X  priority['.'] = -10;
  667. X  priority['\''] = -3;
  668. X  priority[' '] = -15;
  669. X
  670. X  save_screen();
  671. X  clear_screen();
  672. X  DSetScreenCursor(0, 0);
  673. X  DWriteScreenCharAttr(border[TL], ATTR_NORMAL);
  674. X  for (i = 0; i < MAX_WIDTH / RATIO; i++)
  675. X    DWriteScreenCharAttr(border[HE], ATTR_NORMAL);
  676. X  DWriteScreenCharAttr(border[TR], ATTR_NORMAL);
  677. X  orow = -1;
  678. X  map[MAX_WIDTH / RATIO] = '\0';
  679. X  for (i = 0; i < MAX_HEIGHT; i++)
  680. X    {
  681. X      row = i / RATIO;
  682. X      if (row != orow)
  683. X    {
  684. X      if (orow >= 0)
  685. X        {
  686. X          DSetScreenCursor(0, orow+1);
  687. X          DWriteScreenCharAttr(border[VE], ATTR_NORMAL);
  688. X          DWriteScreenString((char *)map);
  689. X          DWriteScreenCharAttr(border[VE], ATTR_NORMAL);
  690. X        }
  691. X      for (j = 0; j < MAX_WIDTH / RATIO; j++)
  692. X        map[j] = ' ';
  693. X      orow = row;
  694. X    }
  695. X      for (j = 0; j < MAX_WIDTH; j++)
  696. X    {
  697. X      col = j / RATIO;
  698. X      tmp = loc_symbol(i, j);
  699. X      /* Attributes are not handled correctly by DWriteScreenString */
  700. X      /* Also, no special priority for the vein character */
  701. X      if (tmp & 0x80)
  702. X        tmp &= ~0x80;
  703. X      if (priority[map[col]] < priority[tmp])
  704. X        map[col] = tmp;
  705. X      if (map[col] == '@')
  706. X        {
  707. X          mycol = col + 1; /* account for border */
  708. X          myrow = row + 1;
  709. X        }
  710. X    }
  711. X    }
  712. X  if (orow >= 0)
  713. X    {
  714. X      DSetScreenCursor(0, orow+1);
  715. X      DWriteScreenCharAttr(border[VE], ATTR_NORMAL);
  716. X      DWriteScreenString((char *)map);
  717. X      DWriteScreenCharAttr(border[VE], ATTR_NORMAL);
  718. X    }
  719. X  DSetScreenCursor(0, orow + 2);
  720. X  DWriteScreenCharAttr(border[BL], ATTR_NORMAL);
  721. X  for (i = 0; i < MAX_WIDTH / RATIO; i++)
  722. X    DWriteScreenCharAttr(border[HE], ATTR_NORMAL);
  723. X  DWriteScreenCharAttr(border[BR], ATTR_NORMAL);
  724. X  DSetScreenCursor(23, 23);
  725. X  DWriteScreenStringAttr("Hit any key to continue", ATTR_NORMAL);
  726. X  if (mycol > 0)
  727. X    DSetScreenCursor(mycol, myrow);
  728. X  (void) inkey();
  729. X  restore_screen();
  730. X}
  731. END_OF_FILE
  732. if test 12528 -ne `wc -c <'mac/macio.c'`; then
  733.     echo shar: \"'mac/macio.c'\" unpacked with wrong size!
  734. fi
  735. # end of 'mac/macio.c'
  736. fi
  737. if test -f 'source/create.c' -a "${1}" != "-c" ; then 
  738.   echo shar: Will not clobber existing file \"'source/create.c'\"
  739. else
  740. echo shar: Extracting \"'source/create.c'\" \(12803 characters\)
  741. sed "s/^X//" >'source/create.c' <<'END_OF_FILE'
  742. X/* source/create.c: create a player character
  743. X
  744. X   Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  745. X
  746. X   This software may be copied and distributed for educational, research, and
  747. X   not for profit purposes provided that this copyright and statement are
  748. X   included in all such copies. */
  749. X
  750. X#ifdef __TURBOC__
  751. X#include    <stdio.h>
  752. X#endif /* __TURBOC__ */
  753. X#include "config.h"
  754. X#include "constant.h"
  755. X#include "types.h"
  756. X#include "externs.h"
  757. X
  758. X#ifdef USG
  759. X#ifndef ATARIST_MWC
  760. X#include <string.h>
  761. X#endif
  762. X#else
  763. X#include <strings.h>
  764. X#endif
  765. X
  766. X#if defined(LINT_ARGS)
  767. Xstatic void get_stats(void);
  768. Xstatic void change_stat(int, int16);
  769. Xstatic void get_all_stats(void);
  770. Xstatic void choose_race(void);
  771. Xstatic void print_history(void);
  772. Xstatic void get_history(void);
  773. Xstatic void get_sex(void);
  774. Xstatic void get_ahw(void);
  775. Xstatic void get_class(void);
  776. Xstatic int monval(int8u);
  777. Xstatic void get_money(void);
  778. X#endif
  779. X
  780. X/* Generates character's stats                -JWT-    */
  781. Xstatic void get_stats()
  782. X{
  783. X  register int i, tot;
  784. X  int dice[18];
  785. X
  786. X  do
  787. X    {
  788. X      tot = 0;
  789. X      for (i = 0; i < 18; i++)
  790. X    {
  791. X      dice[i] = randint (3 + i % 3);  /* Roll 3,4,5 sided dice once each */
  792. X      tot += dice[i];
  793. X    }
  794. X    }
  795. X  while (tot <= 42 || tot >= 54);
  796. X
  797. X  for (i = 0; i < 6; i++)
  798. X    py.stats.max_stat[i] = 5 + dice[3*i] + dice[3*i+1] + dice[3*i+2];
  799. X}
  800. X
  801. X
  802. X/* Changes stats by given amount                -JWT-    */
  803. Xstatic void change_stat(stat, amount)
  804. Xint stat;
  805. Xint16 amount;
  806. X{
  807. X  register int i;
  808. X  register int tmp_stat;
  809. X
  810. X  tmp_stat = py.stats.max_stat[stat];
  811. X  if (amount < 0)
  812. X    for (i = 0; i > amount; i--)
  813. X      {
  814. X    if (tmp_stat > 108)
  815. X      tmp_stat--;
  816. X    else if (tmp_stat > 88)
  817. X      tmp_stat += -randint(6) - 2;
  818. X    else if (tmp_stat > 18)
  819. X      {
  820. X        tmp_stat += -randint(15) - 5;
  821. X        if (tmp_stat < 18)
  822. X          tmp_stat = 18;
  823. X      }
  824. X    else if (tmp_stat > 3)
  825. X      tmp_stat--;
  826. X      }
  827. X  else
  828. X    for (i = 0; i < amount; i++)
  829. X      {
  830. X    if (tmp_stat < 18)
  831. X      tmp_stat++;
  832. X    else if (tmp_stat < 88)
  833. X      tmp_stat += randint(15) + 5;
  834. X    else if (tmp_stat < 108)
  835. X      tmp_stat += randint(6) + 2;
  836. X    else if (tmp_stat < 118)
  837. X      tmp_stat++;
  838. X      }
  839. X  py.stats.max_stat[stat] = tmp_stat;
  840. X}
  841. X
  842. X
  843. X/* generate all stats and modify for race. needed in a separate module so
  844. X   looping of character selection would be allowed     -RGM- */
  845. Xstatic void get_all_stats ()
  846. X{
  847. X  register player_type *p_ptr;
  848. X  register race_type *r_ptr;
  849. X  register int j;
  850. X
  851. X  p_ptr = &py;
  852. X  r_ptr = &race[p_ptr->misc.prace];
  853. X  get_stats ();
  854. X  change_stat (A_STR, r_ptr->str_adj);
  855. X  change_stat (A_INT, r_ptr->int_adj);
  856. X  change_stat (A_WIS, r_ptr->wis_adj);
  857. X  change_stat (A_DEX, r_ptr->dex_adj);
  858. X  change_stat (A_CON, r_ptr->con_adj);
  859. X  change_stat (A_CHR, r_ptr->chr_adj);
  860. X  for (j = 0; j < 6; j++)
  861. X    {
  862. X      py.stats.cur_stat[j] = py.stats.max_stat[j];
  863. X      set_use_stat (j);
  864. X    }
  865. X
  866. X  p_ptr->misc.srh    = r_ptr->srh;
  867. X  p_ptr->misc.bth    = r_ptr->bth;
  868. X  p_ptr->misc.bthb   = r_ptr->bthb;
  869. X  p_ptr->misc.fos    = r_ptr->fos;
  870. X  p_ptr->misc.stl    = r_ptr->stl;
  871. X  p_ptr->misc.save   = r_ptr->bsav;
  872. X  p_ptr->misc.hitdie = r_ptr->bhitdie;
  873. X  p_ptr->misc.lev    = 1;
  874. X  p_ptr->misc.ptodam = todam_adj();
  875. X  p_ptr->misc.ptohit = tohit_adj();
  876. X  p_ptr->misc.ptoac  = 0;
  877. X  p_ptr->misc.pac    = toac_adj();
  878. X  p_ptr->misc.expfact = r_ptr->b_exp;
  879. X  p_ptr->flags.see_infra = r_ptr->infra;
  880. X}
  881. X
  882. X
  883. X/* Allows player to select a race            -JWT-    */
  884. Xstatic void choose_race()
  885. X{
  886. X  register int j, k;
  887. X  int l, m, exit_flag;
  888. X  char s;
  889. X  char tmp_str[80];
  890. X  register player_type *p_ptr;
  891. X  register race_type *r_ptr;
  892. X
  893. X  j = 0;
  894. X  k = 0;
  895. X  l = 2;
  896. X  m = 21;
  897. X  clear_from (20);
  898. X  put_buffer("Choose a race (? for Help):", 20, 2);
  899. X  do
  900. X    {
  901. X      (void) sprintf(tmp_str, "%c) %s", k+'a', race[j].trace);
  902. X      put_buffer(tmp_str, m, l);
  903. X      k++;
  904. X      l += 15;
  905. X      if (l > 70)
  906. X    {
  907. X      l = 2;
  908. X      m++;
  909. X    }
  910. X      j++;
  911. X    }
  912. X  while (j < MAX_RACES);
  913. X  exit_flag = FALSE;
  914. X  do
  915. X    {
  916. X      move_cursor (20, 30);
  917. X      s = inkey();
  918. X      j = s - 'a';
  919. X      if ((j < MAX_RACES) && (j >= 0))
  920. X    exit_flag = TRUE;
  921. X      else if (s == '?')
  922. X    helpfile (MORIA_WELCOME);
  923. X      else
  924. X    bell ();
  925. X    }
  926. X  while (!exit_flag);
  927. X
  928. X  p_ptr = &py;
  929. X  r_ptr = &race[j];
  930. X  p_ptr->misc.prace  = j;
  931. X  put_buffer(r_ptr->trace, 3, 15);
  932. X}
  933. X
  934. X
  935. X/* Will print the history of a character            -JWT-    */
  936. Xstatic void print_history()
  937. X{
  938. X  register int i;
  939. X
  940. X  put_buffer("Character Background", 14, 27);
  941. X  for (i = 0; i < 4; i++)
  942. X    prt(py.misc.history[i], i+15, 10);
  943. X}
  944. X
  945. X
  946. X/* Get the racial history, determines social class    -RAK-    */
  947. X/* Assumptions:    Each race has init history beginning at        */
  948. X/*        (race-1)*3+1                    */
  949. X/*        All history parts are in ascending order    */
  950. Xstatic void get_history()
  951. X{
  952. X  int hist_ptr, cur_ptr, test_roll, flag;
  953. X  register int start_pos, end_pos, cur_len;
  954. X  int line_ctr, new_start, social_class;
  955. X  char history_block[240];
  956. X  register background_type *b_ptr;
  957. X
  958. X  /* Get a block of history text                */
  959. X  hist_ptr = py.misc.prace*3 + 1;
  960. X  history_block[0] = '\0';
  961. X  social_class = randint(4);
  962. X  cur_ptr = 0;
  963. X  do
  964. X    {
  965. X      flag = FALSE;
  966. X      do
  967. X    {
  968. X      if (background[cur_ptr].chart == hist_ptr)
  969. X        {
  970. X          test_roll = randint(100);
  971. X          while (test_roll > background[cur_ptr].roll)
  972. X        cur_ptr++;
  973. X          b_ptr = &background[cur_ptr];
  974. X          (void) strcat(history_block, b_ptr->info);
  975. X          social_class += b_ptr->bonus - 50;
  976. X          if (hist_ptr > b_ptr->next)
  977. X        cur_ptr = 0;
  978. X          hist_ptr = b_ptr->next;
  979. X          flag = TRUE;
  980. X        }
  981. X      else
  982. X        cur_ptr++;
  983. X    }
  984. X      while (!flag);
  985. X    }
  986. X  while (hist_ptr >= 1);
  987. X
  988. X  /* clear the previous history strings */
  989. X  for (hist_ptr = 0; hist_ptr < 4; hist_ptr++)
  990. X    py.misc.history[hist_ptr][0] = '\0';
  991. X
  992. X  /* Process block of history text for pretty output    */
  993. X  start_pos = 0;
  994. X  end_pos   = strlen(history_block) - 1;
  995. X  line_ctr  = 0;
  996. X  flag = FALSE;
  997. X  while (history_block[end_pos] == ' ')
  998. X    end_pos--;
  999. X  do
  1000. X    {
  1001. X      while (history_block[start_pos] == ' ')
  1002. X    start_pos++;
  1003. X      cur_len = end_pos - start_pos + 1;
  1004. X      if (cur_len > 60)
  1005. X    {
  1006. X      cur_len = 60;
  1007. X      while (history_block[start_pos+cur_len-1] != ' ')
  1008. X        cur_len--;
  1009. X      new_start = start_pos + cur_len;
  1010. X      while (history_block[start_pos+cur_len-1] == ' ')
  1011. X        cur_len--;
  1012. X    }
  1013. X      else
  1014. X    flag = TRUE;
  1015. X      (void) strncpy(py.misc.history[line_ctr], &history_block[start_pos],
  1016. X             cur_len);
  1017. X      py.misc.history[line_ctr][cur_len] = '\0';
  1018. X      line_ctr++;
  1019. X      start_pos = new_start;
  1020. X    }
  1021. X  while (!flag);
  1022. X
  1023. X  /* Compute social class for player            */
  1024. X  if (social_class > 100)
  1025. X    social_class = 100;
  1026. X  else if (social_class < 1)
  1027. X    social_class = 1;
  1028. X  py.misc.sc = social_class;
  1029. X}
  1030. X
  1031. X
  1032. X/* Gets the character's sex                -JWT-    */
  1033. Xstatic void get_sex()
  1034. X{
  1035. X  register int exit_flag;
  1036. X  char c;
  1037. X
  1038. X  exit_flag = FALSE;
  1039. X  clear_from (20);
  1040. X  put_buffer("Choose a sex (? for Help):", 20, 2);
  1041. X  put_buffer("m) Male       f) Female", 21, 2);
  1042. X  do
  1043. X    {
  1044. X      move_cursor (20, 29);
  1045. X      /* speed not important here */
  1046. X      c = inkey();
  1047. X      if (c == 'f' || c == 'F')
  1048. X    {
  1049. X      py.misc.male = FALSE;
  1050. X      put_buffer("Female", 4, 15);
  1051. X      exit_flag = TRUE;
  1052. X    }
  1053. X      else if (c == 'm' || c == 'M')
  1054. X    {
  1055. X      py.misc.male = TRUE;
  1056. X      put_buffer("Male", 4, 15);
  1057. X      exit_flag = TRUE;
  1058. X    }
  1059. X      else if (c == '?')
  1060. X    helpfile (MORIA_WELCOME);
  1061. X      else
  1062. X    bell ();
  1063. X    }
  1064. X  while (!exit_flag);
  1065. X}
  1066. X
  1067. X
  1068. X/* Computes character's age, height, and weight        -JWT-    */
  1069. Xstatic void get_ahw()
  1070. X{
  1071. X  register int i;
  1072. X
  1073. X  i = py.misc.prace;
  1074. X  py.misc.age = race[i].b_age + randint((int)race[i].m_age);
  1075. X  if (py.misc.male)
  1076. X    {
  1077. X      py.misc.ht = randnor((int)race[i].m_b_ht, (int)race[i].m_m_ht);
  1078. X      py.misc.wt = randnor((int)race[i].m_b_wt, (int)race[i].m_m_wt);
  1079. X    }
  1080. X  else
  1081. X    {
  1082. X      py.misc.ht = randnor((int)race[i].f_b_ht, (int)race[i].f_m_ht);
  1083. X      py.misc.wt = randnor((int)race[i].f_b_wt, (int)race[i].f_m_wt);
  1084. X    }
  1085. X  py.misc.disarm = race[i].b_dis + todis_adj();
  1086. X}
  1087. X
  1088. X
  1089. X/* Gets a character class                -JWT-    */
  1090. Xstatic void get_class()
  1091. X{
  1092. X  register int i, j;
  1093. X  int k, l, m, min_value, max_value;
  1094. X  int cl[MAX_CLASS], exit_flag;
  1095. X  register struct misc *m_ptr;
  1096. X  register player_type *p_ptr;
  1097. X  class_type *c_ptr;
  1098. X  char tmp_str[80], s;
  1099. X  int32u mask;
  1100. X
  1101. X  for (j = 0; j < MAX_CLASS; j++)
  1102. X    cl[j] = 0;
  1103. X  i = py.misc.prace;
  1104. X  j = 0;
  1105. X  k = 0;
  1106. X  l = 2;
  1107. X  m = 21;
  1108. X  mask = 0x1;
  1109. X  clear_from (20);
  1110. X  put_buffer("Choose a class (? for Help):", 20, 2);
  1111. X  do
  1112. X    {
  1113. X      if (race[i].rtclass & mask)
  1114. X    {
  1115. X      (void) sprintf(tmp_str, "%c) %s", k+'a', class[j].title);
  1116. X      put_buffer(tmp_str, m, l);
  1117. X      cl[k] = j;
  1118. X      l += 15;
  1119. X      if (l > 70)
  1120. X        {
  1121. X          l = 2;
  1122. X          m++;
  1123. X        }
  1124. X      k++;
  1125. X    }
  1126. X      j++;
  1127. X      mask <<= 1;
  1128. X    }
  1129. X  while (j < MAX_CLASS);
  1130. X  py.misc.pclass = 0;
  1131. X  exit_flag = FALSE;
  1132. X  do
  1133. X    {
  1134. X      move_cursor (20, 31);
  1135. X      s = inkey();
  1136. X      j = s - 'a';
  1137. X      if ((j < k) && (j >= 0))
  1138. X    {
  1139. X      py.misc.pclass = cl[j];
  1140. X      c_ptr = &class[py.misc.pclass];
  1141. X      exit_flag = TRUE;
  1142. X      clear_from (20);
  1143. X      put_buffer(c_ptr->title, 5, 15);
  1144. X
  1145. X      /* Adjust the stats for the class adjustment        -RAK-    */
  1146. X      p_ptr = &py;
  1147. X      change_stat (A_STR, c_ptr->madj_str);
  1148. X      change_stat (A_INT, c_ptr->madj_int);
  1149. X      change_stat (A_WIS, c_ptr->madj_wis);
  1150. X      change_stat (A_DEX, c_ptr->madj_dex);
  1151. X      change_stat (A_CON, c_ptr->madj_con);
  1152. X      change_stat (A_CHR, c_ptr->madj_chr);
  1153. X      for(i = 0; i < 6; i++)
  1154. X        {
  1155. X          p_ptr->stats.cur_stat[i] = p_ptr->stats.max_stat[i];
  1156. X          set_use_stat(i);
  1157. X        }
  1158. X
  1159. X      p_ptr->misc.ptodam = todam_adj();    /* Real values        */
  1160. X      p_ptr->misc.ptohit = tohit_adj();
  1161. X      p_ptr->misc.ptoac  = toac_adj();
  1162. X      p_ptr->misc.pac    = 0;
  1163. X      p_ptr->misc.dis_td = p_ptr->misc.ptodam; /* Displayed values    */
  1164. X      p_ptr->misc.dis_th = p_ptr->misc.ptohit;
  1165. X      p_ptr->misc.dis_tac= p_ptr->misc.ptoac;
  1166. X      p_ptr->misc.dis_ac = p_ptr->misc.pac + p_ptr->misc.dis_tac;
  1167. X
  1168. X      /* now set misc stats, do this after setting stats because
  1169. X         of con_adj() for hitpoints */
  1170. X      m_ptr = &py.misc;
  1171. X      m_ptr->hitdie += c_ptr->adj_hd;
  1172. X      m_ptr->mhp = con_adj() + m_ptr->hitdie;
  1173. X      m_ptr->chp = m_ptr->mhp;
  1174. X      m_ptr->chp_frac = 0;
  1175. X
  1176. X      /* initialize hit_points array */
  1177. X      /* put bounds on total possible hp, only succeed if it is within
  1178. X         1/8 of average value */
  1179. X      min_value = (MAX_PLAYER_LEVEL*3/8 * (m_ptr->hitdie-1)) +
  1180. X        MAX_PLAYER_LEVEL;
  1181. X      max_value = (MAX_PLAYER_LEVEL*5/8 * (m_ptr->hitdie-1)) +
  1182. X        MAX_PLAYER_LEVEL;
  1183. X      player_hp[0] = m_ptr->hitdie;
  1184. X      do
  1185. X        {
  1186. X          for (i = 1; i < MAX_PLAYER_LEVEL; i++)
  1187. X        {
  1188. X#ifdef AMIGA        /* Stupid Aztec C 5.0 bug work around CBG */
  1189. X          player_hp[i] = player_hp[i-1] + randint ((int)m_ptr->hitdie);
  1190. X#else
  1191. X          player_hp[i] = randint((int)m_ptr->hitdie);
  1192. X          player_hp[i] += player_hp[i-1];
  1193. X#endif
  1194. X        }
  1195. X        }
  1196. X      while ((player_hp[MAX_PLAYER_LEVEL-1] < min_value) ||
  1197. X         (player_hp[MAX_PLAYER_LEVEL-1] > max_value));
  1198. X
  1199. X      m_ptr->bth += c_ptr->mbth;
  1200. X      m_ptr->bthb += c_ptr->mbthb;    /*RAK*/
  1201. X      m_ptr->srh += c_ptr->msrh;
  1202. X      m_ptr->disarm += c_ptr->mdis;
  1203. X      m_ptr->fos += c_ptr->mfos;
  1204. X      m_ptr->stl += c_ptr->mstl;
  1205. X      m_ptr->save += c_ptr->msav;
  1206. X      m_ptr->expfact += c_ptr->m_exp;
  1207. X    }
  1208. X      else if (s == '?')
  1209. X    helpfile (MORIA_WELCOME);
  1210. X      else
  1211. X    bell ();
  1212. X    }
  1213. X  while (!exit_flag);
  1214. X}
  1215. X
  1216. X
  1217. X/* Given a stat value, return a monetary value, which affects the amount
  1218. X   of gold a player has. */
  1219. Xstatic int monval (i)
  1220. Xint8u i;
  1221. X{
  1222. X  return 5 * ((int)i - 10);
  1223. X}
  1224. X
  1225. X
  1226. Xstatic void get_money()
  1227. X{
  1228. X  register int tmp, gold;
  1229. X  register int8u *a_ptr;
  1230. X
  1231. X  a_ptr = py.stats.max_stat;
  1232. X  tmp = monval (a_ptr[A_STR]) + monval (a_ptr[A_INT])
  1233. X      + monval (a_ptr[A_WIS]) + monval (a_ptr[A_CON])
  1234. X      + monval (a_ptr[A_DEX]);
  1235. X
  1236. X  gold = py.misc.sc*6 + randint (25) + 325;    /* Social Class adj */
  1237. X  gold -= tmp;                    /* Stat adj */
  1238. X  gold += monval (a_ptr[A_CHR]);        /* Charisma adj    */
  1239. X  if (!py.misc.male)
  1240. X    gold += 50;            /* She charmed the banker into it! -CJS- */
  1241. X  if (gold < 80)
  1242. X    gold = 80;            /* Minimum */
  1243. X  py.misc.au = gold;
  1244. X}
  1245. X
  1246. X
  1247. X/* ---------- M A I N  for Character Creation Routine ---------- */
  1248. X/*                            -JWT-    */
  1249. Xvoid create_character()
  1250. X{
  1251. X  register int exit_flag = 1;
  1252. X  register char c;
  1253. X
  1254. X  put_character();
  1255. X  choose_race();
  1256. X  get_sex();
  1257. X
  1258. X  /* here we start a loop giving a player a choice of characters -RGM- */
  1259. X  get_all_stats ();
  1260. X  get_history();
  1261. X  get_ahw();
  1262. X  print_history();
  1263. X  put_misc1();
  1264. X  put_stats();
  1265. X
  1266. X  clear_from (20);
  1267. X  put_buffer("Hit space to reroll or ESC to accept characteristics: ", 20, 2);
  1268. X  do
  1269. X    {
  1270. X      move_cursor (20, 56);
  1271. X      c = inkey();
  1272. X      if (c == ESCAPE)
  1273. X    exit_flag = 0;
  1274. X      else if (c == ' ')
  1275. X    {
  1276. X      get_all_stats ();
  1277. X      get_history();
  1278. X      get_ahw();
  1279. X      print_history();
  1280. X      put_misc1();
  1281. X      put_stats();
  1282. X    }
  1283. X      else
  1284. X    bell ();
  1285. X    }            /* done with stats generation */
  1286. X  while (exit_flag == 1);
  1287. X
  1288. X  get_class();
  1289. X  get_money();
  1290. X  put_stats();
  1291. X  put_misc2();
  1292. X  put_misc3();
  1293. X  get_name();
  1294. X
  1295. X  /* This delay may be reduced, but is recommended to keep players    */
  1296. X  /* from continuously rolling up characters, which can be VERY    */
  1297. X  /* expensive CPU wise.                        */
  1298. X  pause_exit(23, PLAYER_EXIT_PAUSE);
  1299. X}
  1300. END_OF_FILE
  1301. if test 12803 -ne `wc -c <'source/create.c'`; then
  1302.     echo shar: \"'source/create.c'\" unpacked with wrong size!
  1303. fi
  1304. # end of 'source/create.c'
  1305. fi
  1306. if test -f 'source/main.c' -a "${1}" != "-c" ; then 
  1307.   echo shar: Will not clobber existing file \"'source/main.c'\"
  1308. else
  1309. echo shar: Extracting \"'source/main.c'\" \(12154 characters\)
  1310. sed "s/^X//" >'source/main.c' <<'END_OF_FILE'
  1311. X/* UNIX Moria Version 5.x
  1312. X   source/main.c: initialization, main() function and main loop
  1313. X   Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  1314. X
  1315. X   This software may be copied and distributed for educational, research, and
  1316. X   not for profit purposes provided that this copyright and statement are
  1317. X   included in all such copies. */
  1318. X
  1319. X
  1320. X/* Original copyright message follows. */
  1321. X
  1322. X/* Moria Version 4.8    COPYRIGHT (c) Robert Alan Koeneke        */
  1323. X/*                                     */
  1324. X/*     I lovingly dedicate this game to hackers and adventurers     */
  1325. X/*     everywhere...                             */
  1326. X/*                                     */
  1327. X/*                                     */
  1328. X/*     Designer and Programmer : Robert Alan Koeneke             */
  1329. X/*                   University of Oklahoma         */
  1330. X/*                                     */
  1331. X/*     Assistant Programmers     : Jimmey Wayne Todd             */
  1332. X/*                   University of Oklahoma         */
  1333. X/*                                     */
  1334. X/*                   Gary D. McAdoo             */
  1335. X/*                   University of Oklahoma         */
  1336. X/*                                     */
  1337. X/*     UNIX Port         : James E. Wilson             */
  1338. X/*                   UC Berkeley                 */
  1339. X/*                   wilson@kithrup.com             */
  1340. X/*                                     */
  1341. X/*     MSDOS Port         : Don Kneller                 */
  1342. X/*                   1349 - 10th ave             */
  1343. X/*                   San Francisco, CA 94122         */
  1344. X/*                   kneller@cgl.ucsf.EDU             */
  1345. X/*                   ...ucbvax!ucsfcgl!kneller         */
  1346. X/*                   kneller@ucsf-cgl.BITNET         */
  1347. X/*                                     */
  1348. X/*     BRUCE Moria         : Christopher Stuart             */
  1349. X/*                   Monash University             */
  1350. X/*                   Melbourne, Victoria, AUSTRALIA     */
  1351. X/*                   cjs@moncsbruce.oz             */
  1352. X/*                                     */
  1353. X/*       Amiga Port              : Corey Gehman                          */
  1354. X/*                                 Clemson University                    */
  1355. X/*                                 cg377170@eng.clemson.edu              */
  1356. X/*                                     */
  1357. X/*     Version 5.5         : David Grabiner             */
  1358. X/*                   Harvard University             */
  1359. X/*                   grabiner@math.harvard.edu         */
  1360. X/*                                                                       */
  1361. X/*     Moria may be copied and modified freely as long as the above     */
  1362. X/*     credits are retained.    No one who-so-ever may sell or market     */
  1363. X/*     this software in any form without the expressed written consent */
  1364. X/*     of the author Robert Alan Koeneke.                 */
  1365. X/*                                     */
  1366. X
  1367. X#ifdef __TURBOC__
  1368. X#include    <io.h>
  1369. X#include    <stdio.h>
  1370. X#include    <stdlib.h>
  1371. X#endif /* __TURBOC__ */
  1372. X#include "config.h"
  1373. X#include "constant.h"
  1374. X#include "types.h"
  1375. X#include "externs.h"
  1376. X
  1377. X#ifndef USG
  1378. X#include <sys/types.h>
  1379. X#include <sys/param.h>
  1380. X#endif
  1381. X
  1382. X#ifdef USG
  1383. X#ifndef ATARIST_MWC
  1384. X#include <string.h>
  1385. X#else
  1386. X#include "string.h"
  1387. X#endif
  1388. X#else
  1389. X#include <strings.h>
  1390. X#endif
  1391. X
  1392. X#include <ctype.h>
  1393. X
  1394. X#ifdef Pyramid
  1395. X#include <sys/time.h>
  1396. X#else
  1397. X#include <time.h>
  1398. X#endif
  1399. X
  1400. X#ifndef VMS
  1401. X#ifndef MAC
  1402. X#ifndef GEMDOS
  1403. X#ifndef AMIGA
  1404. Xlong time();
  1405. X#endif
  1406. X#endif
  1407. Xchar *getenv();
  1408. X#endif
  1409. X#endif
  1410. X
  1411. X#ifndef MAC
  1412. X#ifndef AMIGA
  1413. X#ifdef USG
  1414. X#if !defined(MSDOS) && !defined(ATARIST_TC)
  1415. Xunsigned short getuid(), getgid();
  1416. X#endif
  1417. X#else
  1418. X#ifndef SECURE
  1419. X#ifdef BSD4_3
  1420. Xuid_t getuid(), getgid();
  1421. X#else  /* other BSD versions */
  1422. Xint getuid(), getgid();
  1423. X#endif
  1424. X#endif
  1425. X#endif
  1426. X#endif
  1427. X#endif
  1428. X
  1429. X#ifndef VMS
  1430. X#ifndef MAC
  1431. X#if defined(ultrix) || defined(USG)
  1432. Xvoid perror();
  1433. X#endif
  1434. X#endif
  1435. X#endif
  1436. X
  1437. X#ifndef VMS
  1438. X#ifndef MAC
  1439. X#ifdef USG
  1440. Xvoid exit();
  1441. X#endif
  1442. X#endif
  1443. X#endif
  1444. X
  1445. X/*
  1446. X#if defined(atarist) && defined(__GNUC__)
  1447. Xlong _stksize = 64*1024;
  1448. X#endif
  1449. X*/
  1450. X
  1451. X#ifdef ATARIST_MWC
  1452. Xlong _stksize = 18000;        /*(SAJ) for MWC    */
  1453. X#endif
  1454. X
  1455. X#ifdef __TURBOC__
  1456. Xunsigned _stklen = 0x3fff;    /* increase stack from 4K to 16K */
  1457. X#endif
  1458. X
  1459. X#if defined(LINT_ARGS)
  1460. Xstatic void char_inven_init(void);
  1461. Xstatic void init_m_level(void);
  1462. Xstatic void init_t_level(void);
  1463. X#if (COST_ADJ != 100)
  1464. Xstatic void price_adjust(void);
  1465. X#endif
  1466. X#else
  1467. Xstatic void char_inven_init();
  1468. Xstatic void init_m_level();
  1469. Xstatic void init_t_level();
  1470. X#if (COST_ADJ != 100)
  1471. Xstatic void price_adjust();
  1472. X#endif
  1473. X#endif
  1474. X
  1475. X/* Initialize, restore, and get the ball rolling.    -RAK-    */
  1476. X#ifdef MAC
  1477. X/* This is just a subroutine for the Mac version */
  1478. X/* only options passed in are -orn */
  1479. X/* save file name is never passed */
  1480. Xint moria_main(argc, argv)
  1481. Xint argc;
  1482. Xchar *argv[];
  1483. X#else
  1484. Xint main(argc, argv)
  1485. Xint argc;
  1486. Xchar *argv[];
  1487. X#endif
  1488. X{
  1489. X  int32u seed;
  1490. X  int generate;
  1491. X  int result;
  1492. X#ifndef MAC
  1493. X  char *p;
  1494. X#endif
  1495. X  int new_game = FALSE;
  1496. X  int force_rogue_like = FALSE;
  1497. X  int force_keys_to;
  1498. X
  1499. X  /* default command set defined in config.h file */
  1500. X  rogue_like_commands = ROGUE_LIKE;
  1501. X
  1502. X#ifdef SECURE
  1503. X  Authenticate();
  1504. X#endif
  1505. X
  1506. X#ifdef MSDOS
  1507. X  msdos_init();        /* find out where everything is */
  1508. X#endif
  1509. X
  1510. X  /* call this routine to grab a file pointer to the highscore file */
  1511. X  /* and prepare things to relinquish setuid privileges */
  1512. X  init_scorefile();
  1513. X
  1514. X#ifndef SECURE
  1515. X#if !defined(MSDOS) && !defined(ATARIST_MWC) && !defined(MAC)
  1516. X#if !defined(AMIGA) && !defined(ATARIST_TC)
  1517. X#if !defined(atarist)
  1518. X  if (0 != setuid(getuid()))
  1519. X    {
  1520. X      perror("Can't set permissions correctly!  Setuid call failed.\n");
  1521. X      exit(0);
  1522. X    }
  1523. X  if (0 != setgid(getgid()))
  1524. X    {
  1525. X      perror("Can't set permissions correctly!  Setgid call failed.\n");
  1526. X      exit(0);
  1527. X    }
  1528. X#endif
  1529. X#endif
  1530. X#endif
  1531. X#endif
  1532. X
  1533. X  /* use curses */
  1534. X  init_curses();
  1535. X
  1536. X#ifdef VMS
  1537. X  /* Bizarre, but yes this really is needed to make moria work correctly
  1538. X     under VMS.  */
  1539. X  restore_screen ();
  1540. X#endif
  1541. X
  1542. X  /* catch those nasty signals */
  1543. X  /* must come after init_curses as some of the signal handlers use curses */
  1544. X  init_signals();
  1545. X
  1546. X  seed = 0; /* let wizard specify rng seed */
  1547. X  /* check for user interface option */
  1548. X  for (--argc, ++argv; argc > 0 && argv[0][0] == '-'; --argc, ++argv)
  1549. X    switch (argv[0][1])
  1550. X      {
  1551. X      case 'N':
  1552. X      case 'n': new_game = TRUE; break;
  1553. X      case 'O':
  1554. X      case 'o':
  1555. X    /* rogue_like_commands may be set in get_char(), so delay this
  1556. X       until after read savefile if any */
  1557. X    force_rogue_like = TRUE;
  1558. X    force_keys_to = FALSE;
  1559. X    break;
  1560. X      case 'R':
  1561. X      case 'r':
  1562. X    force_rogue_like = TRUE;
  1563. X    force_keys_to = TRUE;
  1564. X    break;
  1565. X#ifndef MAC
  1566. X      case 'S': display_scores(TRUE); exit_game();
  1567. X      case 's': display_scores(FALSE); exit_game();
  1568. X      case 'W':
  1569. X      case 'w':
  1570. X    to_be_wizard = TRUE;
  1571. X
  1572. X    if (isdigit((int)argv[0][2]))
  1573. X      seed = atoi(&argv[0][2]);
  1574. X    break;
  1575. X      default: (void) printf("Usage: moria [-norsw] [savefile]\n");
  1576. X    exit_game();
  1577. X#endif
  1578. X      }
  1579. X
  1580. X#ifndef MAC
  1581. X  /* Check operating hours            */
  1582. X  /* If not wizard  No_Control_Y           */
  1583. X  read_times();
  1584. X#endif
  1585. X
  1586. X  /* Some necessary initializations        */
  1587. X  /* all made into constants or initialized in variables.c */
  1588. X
  1589. X#if (COST_ADJ != 100)
  1590. X  price_adjust();
  1591. X#endif
  1592. X
  1593. X  /* Grab a random seed from the clock        */
  1594. X  init_seeds(seed);
  1595. X
  1596. X  /* Init monster and treasure levels for allocate */
  1597. X  init_m_level();
  1598. X  init_t_level();
  1599. X
  1600. X  /* Init the store inventories            */
  1601. X  store_init();
  1602. X
  1603. X#ifndef MAC
  1604. X  /* On Mac, if -n is passed, no savefile is used */
  1605. X  /* If -n is not passed, the calling routine will know savefile name,
  1606. X     hence, this code is not necessary */
  1607. X
  1608. X  /* Auto-restart of saved file */
  1609. X  if (argv[0] != CNIL)
  1610. X    (void) strcpy (savefile, argv[0]);
  1611. X  else if ((p = getenv("MORIA_SAV")) != CNIL)
  1612. X    (void) strcpy(savefile, p);
  1613. X  else if ((p = getenv("HOME")) != CNIL)
  1614. X#if defined(ATARIST_MWC) || defined(ATARIST_TC)
  1615. X    (void) sprintf(savefile, "%s\\%s", p, MORIA_SAV);
  1616. X#else
  1617. X#ifdef VMS
  1618. X    (void) sprintf(savefile, "%s%s", p, MORIA_SAV);
  1619. X#else
  1620. X    (void) sprintf(savefile, "%s/%s", p, MORIA_SAV);
  1621. X#endif
  1622. X#endif
  1623. X  else
  1624. X    (void) strcpy(savefile, MORIA_SAV);
  1625. X#endif
  1626. X
  1627. X/* This restoration of a saved character may get ONLY the monster memory. In
  1628. X   this case, get_char returns false. It may also resurrect a dead character
  1629. X   (if you are the wizard). In this case, it returns true, but also sets the
  1630. X   parameter "generate" to true, as it does not recover any cave details. */
  1631. X
  1632. X  result = FALSE;
  1633. X#ifdef MAC
  1634. X  if ((new_game == FALSE) && get_char(&generate))
  1635. X#else
  1636. X  if ((new_game == FALSE) && !access(savefile, 0) && get_char(&generate))
  1637. X#endif
  1638. X    result = TRUE;
  1639. X
  1640. X  /* enter wizard mode before showing the character display, but must wait
  1641. X     until after get_char in case it was just a resurrection */
  1642. X  if (to_be_wizard)
  1643. X    if (!enter_wiz_mode())
  1644. X      exit_game();
  1645. X
  1646. X  if (result)
  1647. X    {
  1648. X      change_name();
  1649. X
  1650. X      /* could be restoring a dead character after a signal or HANGUP */
  1651. X      if (py.misc.chp < 0)
  1652. X    death = TRUE;
  1653. X    }
  1654. X  else
  1655. X    {      /* Create character       */
  1656. X      create_character();
  1657. X#ifdef MAC
  1658. X      birth_date = time ((time_t *)0);
  1659. X#else
  1660. X      birth_date = time ((long *)0);
  1661. X#endif
  1662. X      char_inven_init();
  1663. X      py.flags.food = 7500;
  1664. X      py.flags.food_digested = 2;
  1665. X      if (class[py.misc.pclass].spell == MAGE)
  1666. X    {      /* Magic realm   */
  1667. X      clear_screen(); /* makes spell list easier to read */
  1668. X      calc_spells(A_INT);
  1669. X      calc_mana(A_INT);
  1670. X    }
  1671. X      else if (class[py.misc.pclass].spell == PRIEST)
  1672. X    {      /* Clerical realm*/
  1673. X      calc_spells(A_WIS);
  1674. X      clear_screen(); /* force out the 'learn prayer' message */
  1675. X      calc_mana(A_WIS);
  1676. X    }
  1677. X      /* prevent ^c quit from entering score into scoreboard,
  1678. X     and prevent signal from creating panic save until this point,
  1679. X     all info needed for save file is now valid */
  1680. X      character_generated = 1;
  1681. X      generate = TRUE;
  1682. X    }
  1683. X
  1684. X  if (force_rogue_like)
  1685. X    rogue_like_commands = force_keys_to;
  1686. X
  1687. X  magic_init();
  1688. X
  1689. X  /* Begin the game                */
  1690. X  clear_screen();
  1691. X  prt_stat_block();
  1692. X  if (generate)
  1693. X    generate_cave();
  1694. X
  1695. X  /* Loop till dead, or exit            */
  1696. X  while(!death)
  1697. X    {
  1698. X      dungeon();                  /* Dungeon logic */
  1699. X
  1700. X#ifndef MAC
  1701. X      /* check for eof here, see inkey() in io.c */
  1702. X      /* eof can occur if the process gets a HANGUP signal */
  1703. X      if (eof_flag)
  1704. X    {
  1705. X      (void) strcpy(died_from, "(end of input: saved)");
  1706. X      if (!save_char())
  1707. X        {
  1708. X          (void) strcpy(died_from, "unexpected eof");
  1709. X        }
  1710. X      /* should not reach here, by if we do, this guarantees exit */
  1711. X      death = TRUE;
  1712. X    }
  1713. X#endif
  1714. X
  1715. X      if (!death) generate_cave();           /* New level    */
  1716. X    }
  1717. X
  1718. X  exit_game();        /* Character gets buried. */
  1719. X  /* should never reach here, but just in case */
  1720. X  return (0);
  1721. X}
  1722. X
  1723. X/* Init players with some belongings            -RAK-    */
  1724. Xstatic void char_inven_init()
  1725. X{
  1726. X  register int i, j;
  1727. X  inven_type inven_init;
  1728. X
  1729. X  /* this is needed for bash to work right, it can't hurt anyway */
  1730. X  for (i = 0; i < INVEN_ARRAY_SIZE; i++)
  1731. X    invcopy(&inventory[i], OBJ_NOTHING);
  1732. X
  1733. X  for (i = 0; i < 5; i++)
  1734. X    {
  1735. X      j = player_init[py.misc.pclass][i];
  1736. X      invcopy(&inven_init, j);
  1737. X      /* this makes it known2 and known1 */
  1738. X      store_bought(&inven_init);
  1739. X      /* must set this bit to display tohit/todam for stiletto */
  1740. X      if (inven_init.tval == TV_SWORD)
  1741. X    inven_init.ident |= ID_SHOW_HITDAM;
  1742. X      (void) inven_carry(&inven_init);
  1743. X    }
  1744. X
  1745. X  /* wierd place for it, but why not? */
  1746. X  for (i = 0; i < 32; i++)
  1747. X    spell_order[i] = 99;
  1748. X}
  1749. X
  1750. X
  1751. X/* Initializes M_LEVEL array for use with PLACE_MONSTER    -RAK-    */
  1752. Xstatic void init_m_level()
  1753. X{
  1754. X  register int i, k;
  1755. X
  1756. X  for (i = 0; i <= MAX_MONS_LEVEL; i++)
  1757. X    m_level[i] = 0;
  1758. X
  1759. X  k = MAX_CREATURES - WIN_MON_TOT;
  1760. X  for (i = 0; i < k; i++)
  1761. X    m_level[c_list[i].level]++;
  1762. X
  1763. X  for (i = 1; i <= MAX_MONS_LEVEL; i++)
  1764. X#ifdef AMIGA  /* fix a stupid MANX Aztec C 5.0 bug again */
  1765. X    m_level[i] = m_level[i] + m_level[i-1];
  1766. X#else
  1767. X    m_level[i] += m_level[i-1];
  1768. X#endif
  1769. X}
  1770. X
  1771. X
  1772. X/* Initializes T_LEVEL array for use with PLACE_OBJECT    -RAK-    */
  1773. Xstatic void init_t_level()
  1774. X{
  1775. X  register int i, l;
  1776. X  int tmp[MAX_OBJ_LEVEL+1];
  1777. X
  1778. X  for (i = 0; i <= MAX_OBJ_LEVEL; i++)
  1779. X    t_level[i] = 0;
  1780. X  for (i = 0; i < MAX_DUNGEON_OBJ; i++)
  1781. X    t_level[object_list[i].level]++;
  1782. X  for (i = 1; i <= MAX_OBJ_LEVEL; i++)
  1783. X#ifdef AMIGA  /* fix a stupid MANX Aztec C 5.0 bug again */
  1784. X    t_level[i] = t_level[i] + t_level[i-1];
  1785. X#else
  1786. X    t_level[i] += t_level[i-1];
  1787. X#endif
  1788. X
  1789. X  /* now produce an array with object indexes sorted by level, by using
  1790. X     the info in t_level, this is an O(n) sort! */
  1791. X  /* this is not a stable sort, but that does not matter */
  1792. X  for (i = 0; i <= MAX_OBJ_LEVEL; i++)
  1793. X    tmp[i] = 1;
  1794. X  for (i = 0; i < MAX_DUNGEON_OBJ; i++)
  1795. X    {
  1796. X      l = object_list[i].level;
  1797. X      sorted_objects[t_level[l] - tmp[l]] = i;
  1798. X      tmp[l]++;
  1799. X    }
  1800. X}
  1801. X
  1802. X
  1803. X#if (COST_ADJ != 100)
  1804. X/* Adjust prices of objects                -RAK-    */
  1805. Xstatic void price_adjust()
  1806. X{
  1807. X  register int i;
  1808. X
  1809. X  /* round half-way cases up */
  1810. X  for (i = 0; i < MAX_OBJECTS; i++)
  1811. X    object_list[i].cost = ((object_list[i].cost * COST_ADJ) + 50) / 100;
  1812. X}
  1813. X#endif
  1814. END_OF_FILE
  1815. if test 12154 -ne `wc -c <'source/main.c'`; then
  1816.     echo shar: \"'source/main.c'\" unpacked with wrong size!
  1817. fi
  1818. # end of 'source/main.c'
  1819. fi
  1820. if test -f 'source/types.h' -a "${1}" != "-c" ; then 
  1821.   echo shar: Will not clobber existing file \"'source/types.h'\"
  1822. else
  1823. echo shar: Extracting \"'source/types.h'\" \(13447 characters\)
  1824. sed "s/^X//" >'source/types.h' <<'END_OF_FILE'
  1825. X/* source/types.h: global type declarations
  1826. X
  1827. X   Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  1828. X
  1829. X   This software may be copied and distributed for educational, research, and
  1830. X   not for profit purposes provided that this copyright and statement are
  1831. X   included in all such copies. */
  1832. X
  1833. Xtypedef unsigned long  int32u;
  1834. Xtypedef long           int32;
  1835. Xtypedef unsigned short int16u;
  1836. Xtypedef short           int16;
  1837. Xtypedef unsigned char  int8u;
  1838. X/* some machines will not accept 'signed char' as a type, and some accept it
  1839. X   but still treat it like an unsigned character, let's just avoid it,
  1840. X   any variable which can ever hold a negative value must be 16 or 32 bits */
  1841. X
  1842. X#define VTYPESIZ    80
  1843. X#define BIGVTYPESIZ    160
  1844. Xtypedef char vtype[VTYPESIZ];
  1845. X/* note that since its output can easily exceed 80 characters, objdes must
  1846. X   always be called with a bigvtype as the first paramter */
  1847. Xtypedef char bigvtype[BIGVTYPESIZ];
  1848. Xtypedef char stat_type[7];
  1849. X
  1850. X/* Many of the character fields used to be fixed length, which greatly
  1851. X   increased the size of the executable.  I have replaced many fixed
  1852. X   length fields with variable length ones. */
  1853. X
  1854. X/* all fields are given the smallest possbile type, and all fields are
  1855. X   aligned within the structure to their natural size boundary, so that
  1856. X   the structures contain no padding and are minimum size */
  1857. X
  1858. X/* bit fields are only used where they would cause a large reduction in
  1859. X   data size, they should not be used otherwise because their use
  1860. X   results in larger and slower code */
  1861. X
  1862. Xtypedef struct creature_type
  1863. X{
  1864. X  char *name;        /* Descrip of creature    */
  1865. X  int32u cmove;        /* Bit field        */
  1866. X  int32u spells;    /* Creature spells    */
  1867. X  int16u cdefense;    /* Bit field        */
  1868. X  int16u mexp;        /* Exp value for kill    */
  1869. X  int8u sleep;        /* Inactive counter/10    */
  1870. X  int8u aaf;        /* Area affect radius    */
  1871. X  int8u ac;        /* AC            */
  1872. X  int8u speed;        /* Movement speed+10    */
  1873. X  int8u cchar;        /* Character rep.    */
  1874. X  int8u hd[2];        /* Creatures hit die    */
  1875. X  int8u damage[4];    /* Type attack and damage*/
  1876. X  int8u level;        /* Level of creature    */
  1877. X} creature_type;
  1878. X
  1879. Xtypedef struct m_attack_type    /* Monster attack and damage types */
  1880. X  {
  1881. X    int8u attack_type;
  1882. X    int8u attack_desc;
  1883. X    int8u attack_dice;
  1884. X    int8u attack_sides;
  1885. X  } m_attack_type;
  1886. X
  1887. Xtypedef struct recall_type    /* Monster memories. -CJS- */
  1888. X  {
  1889. X    int32u r_cmove;
  1890. X    int32u r_spells;
  1891. X    int16u r_kills, r_deaths;
  1892. X    int16u r_cdefense;
  1893. X    int8u r_wake, r_ignore;
  1894. X    int8u r_attacks[MAX_MON_NATTACK];
  1895. X  } recall_type;
  1896. X
  1897. Xtypedef struct monster_type
  1898. X{
  1899. X  int16 hp;        /* Hit points        */
  1900. X  int16 csleep;        /* Inactive counter    */
  1901. X  int16 cspeed;        /* Movement speed    */
  1902. X  int16u mptr;        /* Pointer into creature*/
  1903. X  /* Note: fy, fx, and cdis constrain dungeon size to less than 256 by 256 */
  1904. X  int8u fy;        /* Y Pointer into map    */
  1905. X  int8u fx;        /* X Pointer into map    */
  1906. X  int8u cdis;        /* Cur dis from player    */
  1907. X  int8u ml;
  1908. X  int8u stunned;
  1909. X  int8u confused;
  1910. X} monster_type;
  1911. X
  1912. Xtypedef struct treasure_type
  1913. X{
  1914. X  char *name;        /* Object name        */
  1915. X  int32u flags;        /* Special flags    */
  1916. X  int8u tval;        /* Category number    */
  1917. X  int8u tchar;        /* Character representation*/
  1918. X  int16 p1;        /* Misc. use variable    */
  1919. X  int32 cost;        /* Cost of item        */
  1920. X  int8u subval;        /* Sub-category number    */
  1921. X  int8u number;        /* Number of items    */
  1922. X  int16u weight;    /* Weight        */
  1923. X  int16 tohit;        /* Plusses to hit    */
  1924. X  int16 todam;        /* Plusses to damage    */
  1925. X  int16 ac;        /* Normal AC        */
  1926. X  int16 toac;        /* Plusses to AC    */
  1927. X  int8u damage[2];    /* Damage when hits    */
  1928. X  int8u level;        /* Level item first found */
  1929. X} treasure_type;
  1930. X
  1931. X/* only damage, ac, and tchar are constant; level could possibly be made
  1932. X   constant by changing index instead; all are used rarely */
  1933. X/* extra fields x and y for location in dungeon would simplify pusht() */
  1934. X/* making inscrip a pointer and mallocing space does not work, there are
  1935. X   two many places where inven_types are copied, which results in dangling
  1936. X   pointers, so we use a char array for them instead */
  1937. X#define INSCRIP_SIZE 13  /* notice alignment, must be 4*x + 1 */
  1938. Xtypedef struct inven_type
  1939. X{
  1940. X  int16u index;        /* Index to object_list */
  1941. X  int8u name2;        /* Object special name  */
  1942. X  char inscrip[INSCRIP_SIZE]; /* Object inscription   */
  1943. X  int32u flags;        /* Special flags    */
  1944. X  int8u tval;        /* Category number    */
  1945. X  int8u tchar;        /* Character representation*/
  1946. X  int16 p1;        /* Misc. use variable    */
  1947. X  int32 cost;        /* Cost of item        */
  1948. X  int8u subval;        /* Sub-category number    */
  1949. X  int8u number;        /* Number of items    */
  1950. X  int16u weight;    /* Weight        */
  1951. X  int16 tohit;        /* Plusses to hit    */
  1952. X  int16 todam;        /* Plusses to damage    */
  1953. X  int16 ac;        /* Normal AC        */
  1954. X  int16 toac;        /* Plusses to AC    */
  1955. X  int8u damage[2];    /* Damage when hits    */
  1956. X  int8u level;        /* Level item first found */
  1957. X  int8u ident;        /* Identify information */
  1958. X} inven_type;
  1959. X
  1960. X#define PLAYER_NAME_SIZE 27
  1961. X
  1962. Xtypedef struct player_type
  1963. X{
  1964. X  struct misc
  1965. X    {
  1966. X      char name[PLAYER_NAME_SIZE];    /* Name of character    */
  1967. X      int8u male;    /* Sex of character    */
  1968. X      int32 au;        /* Gold            */
  1969. X      int32 max_exp;    /* Max experience    */
  1970. X      int32 exp;    /* Cur experience    */
  1971. X      int16u exp_frac;    /* Cur exp fraction * 2^16 */
  1972. X      int16u age;    /* Characters age    */
  1973. X      int16u ht;    /* Height        */
  1974. X      int16u wt;    /* Weight        */
  1975. X      int16u lev;    /* Level        */
  1976. X      int16u max_dlv;    /* Max level explored    */
  1977. X      int16 srh;    /* Chance in search    */
  1978. X      int16 fos;    /* Frenq of search    */
  1979. X      int16 bth;    /* Base to hit        */
  1980. X      int16 bthb;    /* BTH with bows    */
  1981. X      int16 mana;    /* Mana points        */
  1982. X      int16 mhp;    /* Max hit pts        */
  1983. X      int16 ptohit;    /* Plusses to hit    */
  1984. X      int16 ptodam;    /* Plusses to dam    */
  1985. X      int16 pac;    /* Total AC        */
  1986. X      int16 ptoac;    /* Magical AC        */
  1987. X      int16 dis_th;    /* Display +ToHit    */
  1988. X      int16 dis_td;    /* Display +ToDam    */
  1989. X      int16 dis_ac;    /* Display +ToAC    */
  1990. X      int16 dis_tac;    /* Display +ToTAC    */
  1991. X      int16 disarm;    /* % to Disarm        */
  1992. X      int16 save;    /* Saving throw        */
  1993. X      int16 sc;        /* Social Class        */
  1994. X      int16 stl;    /* Stealth factor    */
  1995. X      int8u pclass;    /* # of class        */
  1996. X      int8u prace;    /* # of race        */
  1997. X      int8u hitdie;    /* Char hit die        */
  1998. X      int8u expfact;    /* Experience factor    */
  1999. X      int16 cmana;    /* Cur mana pts        */
  2000. X      int16u cmana_frac; /* Cur mana fraction * 2^16 */
  2001. X      int16 chp;    /* Cur hit pts        */
  2002. X      int16u chp_frac;    /* Cur hit fraction * 2^16 */
  2003. X      char history[4][60]; /* History record    */
  2004. X    } misc;
  2005. X  /* Stats now kept in arrays, for more efficient access. -CJS- */
  2006. X  struct stats
  2007. X    {
  2008. X      int8u max_stat[6];    /* What is restored */
  2009. X      int8u cur_stat[6];    /* What is natural */
  2010. X      int16 mod_stat[6];    /* What is modified, may be +/- */
  2011. X      int8u use_stat[6];    /* What is used */
  2012. X    } stats;
  2013. X  struct flags
  2014. X    {
  2015. X      int32u status;        /* Status of player    */
  2016. X      int16 rest;        /* Rest counter           */
  2017. X      int16 blind;        /* Blindness counter   */
  2018. X      int16 paralysis;        /* Paralysis counter   */
  2019. X      int16 confused;        /* Confusion counter   */
  2020. X      int16 food;        /* Food counter           */
  2021. X      int16 food_digested;    /* Food per round      */
  2022. X      int16 protection;        /* Protection fr. evil */
  2023. X      int16 speed;        /* Cur speed adjust    */
  2024. X      int16 fast;        /* Temp speed change   */
  2025. X      int16 slow;        /* Temp speed change   */
  2026. X      int16 afraid;        /* Fear               */
  2027. X      int16 poisoned;        /* Poisoned           */
  2028. X      int16 image;        /* Hallucinate           */
  2029. X      int16 protevil;        /* Protect VS evil     */
  2030. X      int16 invuln;        /* Increases AC           */
  2031. X      int16 hero;        /* Heroism           */
  2032. X      int16 shero;        /* Super Heroism       */
  2033. X      int16 blessed;        /* Blessed           */
  2034. X      int16 resist_heat;    /* Timed heat resist   */
  2035. X      int16 resist_cold;    /* Timed cold resist   */
  2036. X      int16 detect_inv;        /* Timed see invisible */
  2037. X      int16 word_recall;    /* Timed teleport level*/
  2038. X      int16 see_infra;        /* See warm creatures  */
  2039. X      int16 tim_infra;        /* Timed infra vision  */
  2040. X      int8u see_inv;        /* Can see invisible   */
  2041. X      int8u teleport;        /* Random teleportation*/
  2042. X      int8u free_act;        /* Never paralyzed     */
  2043. X      int8u slow_digest;    /* Lower food needs    */
  2044. X      int8u aggravate;        /* Aggravate monsters  */
  2045. X      int8u fire_resist;    /* Resistance to fire  */
  2046. X      int8u cold_resist;    /* Resistance to cold  */
  2047. X      int8u acid_resist;    /* Resistance to acid  */
  2048. X      int8u regenerate;        /* Regenerate hit pts  */
  2049. X      int8u lght_resist;    /* Resistance to light */
  2050. X      int8u ffall;        /* No damage falling   */
  2051. X      int8u sustain_str;    /* Keep strength       */
  2052. X      int8u sustain_int;    /* Keep intelligence   */
  2053. X      int8u sustain_wis;    /* Keep wisdom           */
  2054. X      int8u sustain_con;    /* Keep constitution   */
  2055. X      int8u sustain_dex;    /* Keep dexterity      */
  2056. X      int8u sustain_chr;    /* Keep charisma       */
  2057. X      int8u confuse_monster;    /* Glowing hands.    */
  2058. X      int8u new_spells;        /* Number of spells can learn. */
  2059. X    } flags;
  2060. X} player_type;
  2061. X
  2062. Xtypedef struct spell_type
  2063. X{  /* spell name is stored in spell_names[] array at index i, +31 if priest */
  2064. X  int8u slevel;
  2065. X  int8u smana;
  2066. X  int8u sfail;
  2067. X  int8u sexp;    /* 1/4 of exp gained for learning spell */
  2068. X} spell_type;
  2069. X
  2070. Xtypedef struct race_type
  2071. X{
  2072. X  char    *trace;        /* Type of race            */
  2073. X  int16 str_adj;    /* adjustments            */
  2074. X  int16 int_adj;
  2075. X  int16 wis_adj;
  2076. X  int16 dex_adj;
  2077. X  int16 con_adj;
  2078. X  int16 chr_adj;
  2079. X  int8u b_age;           /* Base age of character        */
  2080. X  int8u m_age;           /* Maximum age of character    */
  2081. X  int8u m_b_ht;          /* base height for males        */
  2082. X  int8u m_m_ht;          /* mod height for males        */
  2083. X  int8u m_b_wt;          /* base weight for males        */
  2084. X  int8u m_m_wt;          /* mod weight for males        */
  2085. X  int8u f_b_ht;          /* base height females        */
  2086. X  int8u f_m_ht;          /* mod height for females    */
  2087. X  int8u f_b_wt;          /* base weight for female    */
  2088. X  int8u f_m_wt;          /* mod weight for females    */
  2089. X  int16 b_dis;           /* base chance to disarm        */
  2090. X  int16 srh;           /* base chance for search    */
  2091. X  int16 stl;           /* Stealth of character        */
  2092. X  int16 fos;           /* frequency of auto search    */
  2093. X  int16 bth;           /* adj base chance to hit    */
  2094. X  int16 bthb;           /* adj base to hit with bows    */
  2095. X  int16 bsav;           /* Race base for saving throw    */
  2096. X  int8u bhitdie;           /* Base hit points for race    */
  2097. X  int8u infra;           /* See infra-red            */
  2098. X  int8u b_exp;           /* Base experience factor    */
  2099. X  int8u rtclass;       /* Bit field for class types    */
  2100. X} race_type;
  2101. X
  2102. Xtypedef struct class_type
  2103. X{
  2104. X  char *title;        /* type of class        */
  2105. X  int8u adj_hd;        /* Adjust hit points        */
  2106. X  int8u mdis;        /* mod disarming traps        */
  2107. X  int8u msrh;        /* modifier to searching    */
  2108. X  int8u mstl;        /* modifier to stealth        */
  2109. X  int8u mfos;        /* modifier to freq-of-search    */
  2110. X  int8u mbth;        /* modifier to base to hit    */
  2111. X  int8u mbthb;        /* modifier to base to hit - bows*/
  2112. X  int8u msav;        /* Class modifier to save    */
  2113. X  int16 madj_str;    /* Class modifier for strength    */
  2114. X  int16 madj_int;    /* Class modifier for intelligence*/
  2115. X  int16 madj_wis;    /* Class modifier for wisdom    */
  2116. X  int16 madj_dex;    /* Class modifier for dexterity */
  2117. X  int16 madj_con;    /* Class modifier for constitution*/
  2118. X  int16 madj_chr;    /* Class modifier for charisma    */
  2119. X  int8u spell;        /* class use mage spells    */
  2120. X  int8u m_exp;        /* Class experience factor    */
  2121. X  int8u first_spell_lev;/* First level where class can use spells. */
  2122. X} class_type;
  2123. X
  2124. Xtypedef struct background_type
  2125. X{
  2126. X  char *info;        /* History information        */
  2127. X  int8u roll;        /* Die roll needed for history    */
  2128. X  int8u chart;        /* Table number            */
  2129. X  int8u next;        /* Pointer to next table    */
  2130. X  int8u bonus;        /* Bonus to the Social Class+50    */
  2131. X} background_type;
  2132. X
  2133. Xtypedef struct cave_type
  2134. X{
  2135. X#ifdef AMIGA
  2136. X  /* This reduces the size from 64 bits to 32 bits. */
  2137. X  unsigned int cptr : 8;
  2138. X  unsigned int tptr : 8;
  2139. X  unsigned int fval : 8;
  2140. X#else
  2141. X  int8u cptr;
  2142. X  int8u tptr;
  2143. X  int8u fval;
  2144. X#endif
  2145. X#if !defined(MSDOS) && !defined(ATARIST_MWC)
  2146. X  unsigned int lr : 1;  /* room should be lit with perm light, walls with
  2147. X               this set should be perm lit after tunneled out */
  2148. X  unsigned int fm : 1;    /* field mark, used for traps/doors/stairs, object is
  2149. X               hidden if fm is FALSE */
  2150. X  unsigned int pl : 1;    /* permanent light, used for walls and lighted rooms */
  2151. X  unsigned int tl : 1;    /* temporary light, used for player's lamp light,etc.*/
  2152. X#else
  2153. X#ifndef __TURBOC__
  2154. X  /* this is not legal ANSI C, this is a MSC extension, which will use 1 byte
  2155. X     for the bitfields whereas MSC uses 2 bytes for the bitfields above */
  2156. X  /* this is also a MWC extension on the Atari ST */
  2157. X  unsigned char lr : 1;
  2158. X  unsigned char fm : 1;
  2159. X  unsigned char pl : 1;
  2160. X  unsigned char tl : 1;
  2161. X#else
  2162. X  unsigned lr : 1;
  2163. X  unsigned fm : 1;
  2164. X  unsigned pl : 1;
  2165. X  unsigned tl : 1;
  2166. X#endif
  2167. X#endif
  2168. X} cave_type;
  2169. X
  2170. Xtypedef struct owner_type
  2171. X{
  2172. X  char *owner_name;
  2173. X  int16 max_cost;
  2174. X  int8u max_inflate;
  2175. X  int8u min_inflate;
  2176. X  int8u haggle_per;
  2177. X  int8u owner_race;
  2178. X  int8u insult_max;
  2179. X} owner_type;
  2180. X
  2181. Xtypedef struct inven_record
  2182. X{
  2183. X  int32 scost;
  2184. X  inven_type sitem;
  2185. X} inven_record;
  2186. X
  2187. Xtypedef struct store_type
  2188. X{
  2189. X  int32 store_open;
  2190. X  int16 insult_cur;
  2191. X  int8u owner;
  2192. X  int8u store_ctr;
  2193. X  int16u good_buy;
  2194. X  int16u bad_buy;
  2195. X  inven_record store_inven[STORE_INVEN_MAX];
  2196. X} store_type;
  2197. X
  2198. X/* 64 bytes for this structure */
  2199. Xtypedef struct high_scores
  2200. X{
  2201. X  int32 points;
  2202. X  int32 birth_date;
  2203. X  int16 uid;
  2204. X  int16 mhp;
  2205. X  int16 chp;
  2206. X  int8u dun_level;
  2207. X  int8u lev;
  2208. X  int8u max_dlv;
  2209. X  int8u sex;
  2210. X  int8u race;
  2211. X  int8u class;
  2212. X  char name[PLAYER_NAME_SIZE];
  2213. X  char died_from[25];
  2214. X} high_scores;
  2215. END_OF_FILE
  2216. if test 13447 -ne `wc -c <'source/types.h'`; then
  2217.     echo shar: \"'source/types.h'\" unpacked with wrong size!
  2218. fi
  2219. # end of 'source/types.h'
  2220. fi
  2221. echo shar: End of archive 30 \(of 39\).
  2222. cp /dev/null ark30isdone
  2223. MISSING=""
  2224. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 ; do
  2225.     if test ! -f ark${I}isdone ; then
  2226.     MISSING="${MISSING} ${I}"
  2227.     fi
  2228. done
  2229. if test "${MISSING}" = "" ; then
  2230.     echo You have unpacked all 39 archives.
  2231.     echo "Now run "bldfiles.sh" to build split files"
  2232.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2233. else
  2234.     echo You still need to unpack the following archives:
  2235.     echo "        " ${MISSING}
  2236. fi
  2237. ##  End of shell archive.
  2238. exit 0
  2239.