home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / games / volume14 / umoria4 / part22 < prev    next >
Internet Message Format  |  1992-08-31  |  58KB

  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: v14i054:  umoria4 - single player dungeon simulation (ver. 5.5), Part22/39
  5. Message-ID: <3418@master.CNA.TEK.COM>
  6. Date: 22 Aug 92 22:12:36 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 2292
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: grabiner@math.harvard.edu (David Grabiner)
  12. Posting-number: Volume 14, Issue 54
  13. Archive-name: umoria4/Part22
  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 22 (of 39)."
  26. # Contents:  source/death.c source/externs.h
  27. # Wrapped by billr@saab on Thu Aug 20 09:11:32 1992
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'source/death.c' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'source/death.c'\"
  31. else
  32. echo shar: Extracting \"'source/death.c'\" \(23954 characters\)
  33. sed "s/^X//" >'source/death.c' <<'END_OF_FILE'
  34. X/* source/death.c: code executed when player dies
  35. X
  36. X   Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  37. X
  38. X   This software may be copied and distributed for educational, research, and
  39. X   not for profit purposes provided that this copyright and statement are
  40. X   included in all such copies. */
  41. X
  42. X/* Must read this before externs.h, as some global declarations use FILE. */
  43. X#include <stdio.h>
  44. X
  45. X#ifndef STDIO_LOADED
  46. X#define STDIO_LOADED
  47. X#endif
  48. X
  49. X#include "config.h"
  50. X#include "constant.h"
  51. X#include "types.h"
  52. X
  53. X#ifdef Pyramid
  54. X#include <sys/time.h>
  55. X#else
  56. X#include <time.h>
  57. X#endif
  58. X
  59. X#include <ctype.h>
  60. X
  61. X#ifndef USG
  62. X/* only needed for Berkeley UNIX */
  63. X#include <sys/param.h>
  64. X#include <sys/types.h>
  65. X#include <sys/file.h>
  66. X#endif
  67. X
  68. X#ifdef MSDOS
  69. X#include <io.h>
  70. X#else
  71. X#if !defined(ATARIST_MWC) && !defined(MAC) && !defined(AMIGA)
  72. X#if !defined(ATARIST_TC)
  73. X#ifndef VMS
  74. X#include <pwd.h>
  75. X#else
  76. X#include <file.h>
  77. X#endif
  78. X#endif
  79. X#endif
  80. X#endif
  81. X
  82. X#ifdef VMS
  83. Xunsigned int getuid(), getgid();
  84. X#else
  85. X#ifdef unix
  86. X#ifdef USG
  87. Xunsigned short getuid(), getgid();
  88. X#else
  89. X#ifndef SECURE
  90. X#ifdef BSD4_3
  91. Xuid_t getuid(), getgid();
  92. X#else  /* other BSD versions */
  93. Xint getuid(), getgid();
  94. X#endif
  95. X#endif
  96. X#endif
  97. X#endif
  98. X#endif
  99. X
  100. X#ifdef USG
  101. X#ifndef ATARIST_MWC
  102. X#include <string.h>
  103. X#ifndef VMS
  104. X#ifndef ATARIST_TC
  105. X#include <fcntl.h>
  106. X#endif
  107. X#endif
  108. X#endif
  109. X#else
  110. X#include <strings.h>
  111. X#endif
  112. X
  113. X/* This must be included after fcntl.h, which has a prototype for `open'
  114. X   on some systems.  Otherwise, the `open' prototype conflicts with the
  115. X   `topen' declaration.  */
  116. X#include "externs.h"
  117. X
  118. X#ifndef BSD4_3
  119. X#ifndef ATARIST_TC
  120. Xlong lseek();
  121. X#endif /* ATARTIST_TC */
  122. X#else
  123. Xoff_t lseek();
  124. X#endif
  125. X
  126. X#if defined(USG) || defined(VMS) || defined(atarist)
  127. X#ifndef L_SET
  128. X#define L_SET 0
  129. X#endif
  130. X#ifndef L_INCR
  131. X#define L_INCR 1
  132. X#endif
  133. X#endif
  134. X
  135. X#ifndef VMS
  136. X#ifndef MAC
  137. X#if defined(ultrix) || defined(USG)
  138. Xvoid exit ();
  139. X#endif
  140. X#endif
  141. X#endif
  142. X
  143. X#if defined(LINT_ARGS)
  144. Xstatic void date(char *);
  145. Xstatic char *center_string(char *, char *);
  146. Xstatic void print_tomb(void);
  147. Xstatic void kingly(void);
  148. X#endif
  149. X
  150. X#ifdef ATARIST_TC
  151. X/* Include this to get prototypes for standard library functions.  */
  152. X#include <stdlib.h>
  153. X#endif
  154. X
  155. X#ifndef VMS
  156. X#ifndef MAC
  157. X#if !defined(ATARIST_MWC) && !defined(AMIGA)
  158. Xlong time();
  159. X#endif
  160. X#endif
  161. X#endif
  162. X
  163. Xstatic void date(day)
  164. Xchar *day;
  165. X{
  166. X  register char *tmp;
  167. X#ifdef MAC
  168. X  time_t clockvar;
  169. X#else
  170. X  long clockvar;
  171. X#endif
  172. X
  173. X#ifdef MAC
  174. X  clockvar = time((time_t *) 0);
  175. X#else
  176. X  clockvar = time((long *) 0);
  177. X#endif
  178. X  tmp = ctime(&clockvar);
  179. X  tmp[10] = '\0';
  180. X  (void) strcpy(day, tmp);
  181. X}
  182. X
  183. X/* Centers a string within a 31 character string        -JWT-     */
  184. Xstatic char *center_string(centered_str, in_str)
  185. Xchar *centered_str;
  186. Xchar *in_str;
  187. X{
  188. X  register int i, j;
  189. X
  190. X  i = strlen(in_str);
  191. X  j = 15 - i/2;
  192. X  (void) sprintf (centered_str, "%*s%s%*s", j, "", in_str, 31 - i - j, "");
  193. X  return centered_str;
  194. X}
  195. X
  196. X
  197. X#ifndef __TURBOC__
  198. X#if (defined(USG) || defined(atarist)) && !defined(VMS)
  199. X#if !defined(AMIGA) && !defined(MAC) && !defined(ATARIST_TC)
  200. X
  201. X#include <sys/stat.h>
  202. X#include <errno.h>
  203. X
  204. X/* The following code is provided especially for systems which        -CJS-
  205. X   have no flock system call. It has never been tested.        */
  206. X
  207. X#define LOCK_EX    1
  208. X#define LOCK_SH    2
  209. X#define LOCK_NB    4
  210. X#define LOCK_UN    8
  211. X
  212. X/* An flock HACK.  LOCK_SH and LOCK_EX are not distinguished.  DO NOT release
  213. X   a lock which you failed to set!  ALWAYS release a lock you set! */
  214. Xstatic int flock(f, l)
  215. Xint f, l;
  216. X{
  217. X  struct stat sbuf;
  218. X  char lockname[80];
  219. X
  220. X  if (fstat (f, &sbuf) < 0)
  221. X    return -1;
  222. X#ifdef atarist
  223. X  (void) sprintf (lockname, (char *)prefix_file((char *)"moria.%d"),
  224. X          sbuf.st_ino);
  225. X#else
  226. X  (void) sprintf (lockname, "/tmp/moria.%d", sbuf.st_ino);
  227. X#endif
  228. X  if (l & LOCK_UN)
  229. X    return unlink(lockname);
  230. X
  231. X  while (open (lockname, O_WRONLY|O_CREAT|O_EXCL, 0644) < 0)
  232. X    {
  233. X      if (errno != EEXIST)
  234. X    return -1;
  235. X      if (stat(lockname, &sbuf) < 0)
  236. X    return -1;
  237. X      /* Locks which last more than 10 seconds get deleted. */
  238. X      if (time((long *)0) - sbuf.st_mtime > 10)
  239. X    {
  240. X      if (unlink(lockname) < 0)
  241. X        return -1;
  242. X    }
  243. X      else if (l & LOCK_NB)
  244. X    return -1;
  245. X      else
  246. X    (void) sleep(1);
  247. X    }
  248. X  return 0;
  249. X}
  250. X#endif
  251. X#endif
  252. X#endif
  253. X
  254. Xvoid display_scores(show_player)
  255. Xint show_player;
  256. X{
  257. X  register int i, rank;
  258. X  high_scores score;
  259. X  char input;
  260. X  char string[100];
  261. X  int8u version_maj, version_min, patch_level;
  262. X#if defined(unix) || defined(VMS)
  263. X  int16 player_uid;
  264. X#endif
  265. X
  266. X#if defined(MSDOS) || defined(VMS) || defined(AMIGA) || defined(MAC)
  267. X#if defined(MAC) || defined(MSDOS)
  268. X  if ((highscore_fp = fopen(MORIA_TOP, "rb")) == NULL)
  269. X#else
  270. X  if ((highscore_fp = fopen(MORIA_TOP, "r")) == NULL)
  271. X#endif
  272. X    {
  273. X      (void) sprintf (string, "Error opening score file \"%s\"\n", MORIA_TOP);
  274. X      msg_print(string);
  275. X      msg_print(CNIL);
  276. X      return;
  277. X    }
  278. X#endif
  279. X
  280. X#ifndef BSD4_3
  281. X  (void) fseek(highscore_fp, (long)0, L_SET);
  282. X#else
  283. X  (void) fseek(highscore_fp, (off_t)0, L_SET);
  284. X#endif
  285. X
  286. X  /* Read version numbers from the score file, and check for validity.  */
  287. X  version_maj = getc (highscore_fp);
  288. X  version_min = getc (highscore_fp);
  289. X  patch_level = getc (highscore_fp);
  290. X  /* Support score files from 5.2.2 to present.  */
  291. X  if (feof (highscore_fp))
  292. X    /* An empty score file. */
  293. X    ;
  294. X  else if ((version_maj != CUR_VERSION_MAJ)
  295. X       || (version_min > CUR_VERSION_MIN)
  296. X       || (version_min == CUR_VERSION_MIN && patch_level > PATCH_LEVEL)
  297. X       || (version_min == 2 && patch_level < 2)
  298. X       || (version_min < 2))
  299. X    {
  300. X      msg_print("Sorry. This scorefile is from a different version of \
  301. Xumoria.");
  302. X      msg_print (CNIL);
  303. X#if defined(MSDOS) || defined(VMS) || defined(AMIGA) || defined(MAC)
  304. X      (void) fclose (highscore_fp);
  305. X#endif
  306. X      return;
  307. X    }
  308. X
  309. X#ifdef unix
  310. X  player_uid = getuid ();
  311. X#else
  312. X#ifdef VMS
  313. X  player_uid = (getgid()*1000) + getuid();
  314. X#else
  315. X  /* Otherwise player_uid is not used.  */
  316. X#endif
  317. X#endif
  318. X
  319. X  /* set the static fileptr in save.c to the highscore file pointer */
  320. X  set_fileptr(highscore_fp);
  321. X
  322. X  rank = 1;
  323. X  rd_highscore(&score);
  324. X  while (!feof(highscore_fp))
  325. X    {
  326. X      i = 1;
  327. X      clear_screen();
  328. X      /* Put twenty scores on each page, on lines 2 through 21. */
  329. X      while (!feof(highscore_fp) && i < 21)
  330. X    {
  331. X      /* Only show the entry if show_player false, or if the entry
  332. X         belongs to the current player.  */
  333. X      if (! show_player ||
  334. X#if defined(unix) || defined(VMS)
  335. X          score.uid == player_uid
  336. X#else
  337. X          /* Assume microcomputers should always show every entry. */
  338. X          TRUE
  339. X#endif
  340. X          )
  341. X        {
  342. X          (void) sprintf(string,
  343. X               "%-4d%8ld %-19.19s %c %-10.10s %-7.7s%3d %-22.22s",
  344. X                 rank, score.points, score.name, score.sex,
  345. X                 race[score.race].trace, class[score.class].title,
  346. X                 score.lev, score.died_from);
  347. X          prt(string, ++i, 0);
  348. X        }
  349. X      rank++;
  350. X      rd_highscore(&score);
  351. X    }
  352. X      prt("Rank  Points Name              Sex Race       Class  Lvl Killed By"
  353. X      , 0, 0);
  354. X      erase_line (1, 0);
  355. X      prt("[Press any key to continue.]", 23, 23);
  356. X      input = inkey();
  357. X      if (input == ESCAPE)
  358. X    break;
  359. X    }
  360. X#if defined(MSDOS) || defined(VMS) || defined(AMIGA) || defined(MAC)
  361. X  (void) fclose (highscore_fp);
  362. X#endif
  363. X}
  364. X
  365. X
  366. Xint duplicate_character ()
  367. X{
  368. X  /* Only check for duplicate characters under unix and VMS.  */
  369. X#if !defined (unix) && !defined(VMS)
  370. X  return FALSE;
  371. X
  372. X#else /* ! unix && ! VMS */
  373. X
  374. X  high_scores score;
  375. X  int8u version_maj, version_min, patch_level;
  376. X  int16 player_uid;
  377. X#if defined(MSDOS) || defined(VMS) || defined(AMIGA) || defined(MAC)
  378. X  char string[80];
  379. X#endif
  380. X
  381. X#if defined(MSDOS) || defined(VMS) || defined(AMIGA) || defined(MAC)
  382. X#if defined(MAC) || defined(MSDOS)
  383. X  if ((highscore_fp = fopen(MORIA_TOP, "rb")) == NULL)
  384. X#else
  385. X  if ((highscore_fp = fopen(MORIA_TOP, "r")) == NULL)
  386. X#endif
  387. X    {
  388. X      (void) sprintf (string, "Error opening score file \"%s\"\n", MORIA_TOP);
  389. X      msg_print(string);
  390. X      msg_print(CNIL);
  391. X      return FALSE;
  392. X    }
  393. X#endif
  394. X
  395. X#ifndef BSD4_3
  396. X  (void) fseek(highscore_fp, (long)0, L_SET);
  397. X#else
  398. X  (void) fseek(highscore_fp, (off_t)0, L_SET);
  399. X#endif
  400. X
  401. X  /* Read version numbers from the score file, and check for validity.  */
  402. X  version_maj = getc (highscore_fp);
  403. X  version_min = getc (highscore_fp);
  404. X  patch_level = getc (highscore_fp);
  405. X  /* Support score files from 5.2.2 to present.  */
  406. X  if (feof (highscore_fp))
  407. X    /* An empty score file.  */
  408. X    return FALSE;
  409. X  if ((version_maj != CUR_VERSION_MAJ)
  410. X      || (version_min > CUR_VERSION_MIN)
  411. X      || (version_min == CUR_VERSION_MIN && patch_level > PATCH_LEVEL)
  412. X      || (version_min == 2 && patch_level < 2)
  413. X      || (version_min < 2))
  414. X    {
  415. X      msg_print("Sorry. This scorefile is from a different version of \
  416. Xumoria.");
  417. X      msg_print (CNIL);
  418. X#if defined(MSDOS) || defined(VMS) || defined(AMIGA) || defined(MAC)
  419. X      (void) fclose (highscore_fp);
  420. X#endif
  421. X      return FALSE;
  422. X    }
  423. X
  424. X  /* set the static fileptr in save.c to the highscore file pointer */
  425. X  set_fileptr(highscore_fp);
  426. X
  427. X#ifdef unix
  428. X  player_uid = getuid ();
  429. X#else
  430. X#ifdef VMS
  431. X  player_uid = (getgid()*1000) + getuid();
  432. X#else
  433. X  player_uid = 0;
  434. X#endif
  435. X#endif
  436. X
  437. X  rd_highscore(&score);
  438. X  while (!feof(highscore_fp))
  439. X    {
  440. X      if (score.uid == player_uid && score.birth_date == birth_date
  441. X      && score.class == py.misc.pclass && score.race == py.misc.prace
  442. X      && score.sex == (py.misc.male ? 'M' : 'F')
  443. X      && strcmp (score.died_from, "(saved)"))
  444. X    return TRUE;
  445. X
  446. X      rd_highscore(&score);
  447. X    }
  448. X#if defined(MSDOS) || defined(VMS) || defined(AMIGA) || defined(MAC)
  449. X  (void) fclose (highscore_fp);
  450. X#endif
  451. X
  452. X  return FALSE;
  453. X#endif  /* ! unix && ! VMS */
  454. X}
  455. X
  456. X
  457. X
  458. X/* Prints the gravestone of the character        -RAK-     */
  459. Xstatic void print_tomb()
  460. X{
  461. X  vtype str, tmp_str;
  462. X  register int i;
  463. X  char day[11];
  464. X  register char *p;
  465. X#ifdef MAC
  466. X  char func;
  467. X  int ok;
  468. X#endif
  469. X
  470. X  clear_screen();
  471. X  put_buffer ("_______________________", 1, 15);
  472. X  put_buffer ("/", 2, 14);
  473. X  put_buffer ("\\         ___", 2, 38);
  474. X  put_buffer ("/", 3, 13);
  475. X  put_buffer ("\\ ___   /   \\      ___", 3, 39);
  476. X  put_buffer ("/            RIP            \\   \\  :   :     /   \\", 4, 12);
  477. X  put_buffer ("/", 5, 11);
  478. X  put_buffer ("\\  : _;,,,;_    :   :", 5, 41);
  479. X  (void) sprintf (str, "/%s\\,;_          _;,,,;_",
  480. X          center_string (tmp_str, py.misc.name));
  481. X  put_buffer (str, 6, 10);
  482. X  put_buffer ("|               the               |   ___", 7, 9);
  483. X  if (!total_winner)
  484. X    p = title_string ();
  485. X  else
  486. X    p = "Magnificent";
  487. X  (void) sprintf (str, "| %s |  /   \\", center_string (tmp_str, p));
  488. X  put_buffer (str, 8, 9);
  489. X  put_buffer ("|", 9, 9);
  490. X  put_buffer ("|  :   :", 9, 43);
  491. X  if (!total_winner)
  492. X    p = class[py.misc.pclass].title;
  493. X  else if (py.misc.male)
  494. X    p = "*King*";
  495. X  else
  496. X    p = "*Queen*";
  497. X  (void) sprintf(str,"| %s | _;,,,;_   ____", center_string (tmp_str, p));
  498. X  put_buffer (str, 10, 9);
  499. X  (void) sprintf (str, "Level : %d", (int) py.misc.lev);
  500. X  (void) sprintf (str,"| %s |          /    \\",
  501. X          center_string (tmp_str, str));
  502. X  put_buffer (str, 11, 9);
  503. X  (void) sprintf(str, "%ld Exp", py.misc.exp);
  504. X  (void) sprintf(str,"| %s |          :    :", center_string (tmp_str, str));
  505. X  put_buffer (str, 12, 9);
  506. X  (void) sprintf(str, "%ld Au", py.misc.au);
  507. X  (void) sprintf(str,"| %s |          :    :", center_string (tmp_str, str));
  508. X  put_buffer (str, 13, 9);
  509. X  (void) sprintf(str, "Died on Level : %d", dun_level);
  510. X  (void) sprintf(str,"| %s |         _;,,,,;_", center_string (tmp_str, str));
  511. X  put_buffer (str, 14, 9);
  512. X  put_buffer ("|            killed by            |", 15, 9);
  513. X  p = died_from;
  514. X  i = strlen (p);
  515. X  p[i] = '.';  /* add a trailing period */
  516. X  p[i+1] = '\0';
  517. X  (void) sprintf(str, "| %s |", center_string (tmp_str, p));
  518. X  put_buffer (str, 16, 9);
  519. X  p[i] = '\0';     /* strip off the period */
  520. X  date(day);
  521. X  (void) sprintf(str, "| %s |", center_string (tmp_str, day));
  522. X  put_buffer (str, 17, 9);
  523. X  put_buffer ("*|   *     *     *    *   *     *  | *", 18, 8);
  524. X  put_buffer ("________)/\\\\_)_/___(\\/___(//_\\)/_\\//__\\\\(/_|_)_______",
  525. X          19, 0);
  526. X
  527. X retry:
  528. X  flush();
  529. X#ifdef MAC
  530. X  /* On Mac, file_character() gets file name via std file dialog */
  531. X  /* So, the prompt for character record cannot be made to do double duty */
  532. X  put_buffer ("('F' - Save record in file / 'Y' - Display record on screen \
  533. X/ 'N' - Abort)", 23, 0);
  534. X  put_buffer ("Character record [F/Y/N]?", 22, 0);
  535. X  do
  536. X    {
  537. X      func = inkey();
  538. X      switch (func)
  539. X    {
  540. X    case 'f': case 'F':
  541. X      func = 'F';
  542. X      ok = TRUE;
  543. X      break;
  544. X    case 'y': case 'Y':
  545. X      func = 'Y';
  546. X      ok = TRUE;
  547. X      break;
  548. X    case 'n': case 'N':
  549. X      func = 'N';
  550. X      ok = TRUE;
  551. X      break;
  552. X    default:
  553. X      bell();
  554. X      ok = FALSE;
  555. X      break;
  556. X    }
  557. X    }
  558. X  while (!ok);
  559. X  if (func != 'N')
  560. X#else
  561. X  put_buffer ("(ESC to abort, return to print on screen, or file name)",
  562. X          23, 0);
  563. X  put_buffer ("Character record?", 22, 0);
  564. X  if (get_string (str, 22, 18, 60))
  565. X#endif
  566. X    {
  567. X      for (i = 0; i < INVEN_ARRAY_SIZE; i++)
  568. X    {
  569. X      known1(&inventory[i]);
  570. X      known2(&inventory[i]);
  571. X    }
  572. X      calc_bonuses ();
  573. X#ifdef MAC
  574. X      if (func == 'F')
  575. X    {
  576. X      if (!file_character())
  577. X        goto retry;
  578. X    }
  579. X#else
  580. X      if (str[0])
  581. X    {
  582. X      if (!file_character (str))
  583. X        goto retry;
  584. X    }
  585. X#endif
  586. X      else
  587. X    {
  588. X      clear_screen ();
  589. X      display_char ();
  590. X      put_buffer ("Type ESC to skip the inventory:", 23, 0);
  591. X      if (inkey() != ESCAPE)
  592. X        {
  593. X          clear_screen ();
  594. X          msg_print ("You are using:");
  595. X          (void) show_equip (TRUE, 0);
  596. X          msg_print (CNIL);
  597. X          msg_print ("You are carrying:");
  598. X          clear_from (1);
  599. X          (void) show_inven (0, inven_ctr-1, TRUE, 0, CNIL);
  600. X          msg_print (CNIL);
  601. X        }
  602. X    }
  603. X    }
  604. X}
  605. X
  606. X
  607. X/* Calculates the total number of points earned        -JWT-     */
  608. Xint32 total_points()
  609. X{
  610. X  int32 total;
  611. X  int i;
  612. X
  613. X  total = py.misc.max_exp + (100 * py.misc.max_dlv);
  614. X  total += py.misc.au / 100;
  615. X  for (i = 0; i < INVEN_ARRAY_SIZE; i++)
  616. X    total += item_value(&inventory[i]);
  617. X  total += dun_level*50;
  618. X
  619. X  /* Don't ever let the score decrease from one save to the next.  */
  620. X  if (max_score > total)
  621. X    return max_score;
  622. X
  623. X  return total;
  624. X}
  625. X
  626. X
  627. X/* Enters a players name on the top twenty list        -JWT-     */
  628. Xstatic void highscores()
  629. X{
  630. X  high_scores old_entry, new_entry, entry;
  631. X  int i;
  632. X  char *tmp;
  633. X  int8u version_maj, version_min, patch_level;
  634. X  long curpos;
  635. X#if defined(VMS) || defined(MSDOS) || defined(AMIGA) || defined(MAC)
  636. X  char string[100];
  637. X#endif
  638. X
  639. X  clear_screen();
  640. X
  641. X  if (noscore)
  642. X    return;
  643. X
  644. X  if (panic_save == 1)
  645. X    {
  646. X      msg_print("Sorry, scores for games restored from panic save files \
  647. Xare not saved.");
  648. X      return;
  649. X    }
  650. X
  651. X  new_entry.points = total_points();
  652. X  new_entry.birth_date = birth_date;
  653. X#ifdef unix
  654. X  new_entry.uid = getuid();
  655. X#else
  656. X#ifdef VMS
  657. X  new_entry.uid = (getgid()*1000) + getuid();
  658. X#else
  659. X  new_entry.uid = 0;
  660. X#endif
  661. X#endif
  662. X  new_entry.mhp = py.misc.mhp;
  663. X  new_entry.chp = py.misc.chp;
  664. X  new_entry.dun_level = dun_level;
  665. X  new_entry.lev = py.misc.lev;
  666. X  new_entry.max_dlv = py.misc.max_dlv;
  667. X  new_entry.sex = (py.misc.male ? 'M' : 'F');
  668. X  new_entry.race = py.misc.prace;
  669. X  new_entry.class = py.misc.pclass;
  670. X  (void) strcpy(new_entry.name, py.misc.name);
  671. X  tmp = died_from;
  672. X  if ('a' == *tmp)
  673. X    {
  674. X      if ('n' == *(++tmp))
  675. X    {
  676. X      tmp++;
  677. X    }
  678. X      while (isspace(*tmp))
  679. X    {
  680. X      tmp++;
  681. X    }
  682. X    }
  683. X  (void) strcpy(new_entry.died_from, tmp);
  684. X
  685. X  /*  First, get a lock on the high score file so no-one else tries */
  686. X  /*  to write to it while we are using it, on VMS and IBMPCs only one
  687. X      process can have the file open at a time, so we just open it here */
  688. X#if defined(MSDOS) || defined(VMS) || defined(AMIGA) || defined(MAC)
  689. X#if defined(MAC) || defined(MSDOS)
  690. X  if ((highscore_fp = fopen(MORIA_TOP, "rb+")) == NULL)
  691. X#else
  692. X  if ((highscore_fp = fopen(MORIA_TOP, "r+")) == NULL)
  693. X#endif
  694. X    {
  695. X      (void) sprintf (string, "Error opening score file \"%s\"\n", MORIA_TOP);
  696. X      msg_print(string);
  697. X      msg_print(CNIL);
  698. X      return;
  699. X    }
  700. X#else
  701. X#ifdef ATARIST_TC
  702. X  /* 'lock' always succeeds on the Atari ST */
  703. X#else
  704. X  if (0 != flock((int)fileno(highscore_fp), LOCK_EX))
  705. X    {
  706. X      msg_print("Error gaining lock for score file");
  707. X      msg_print(CNIL);
  708. X      return;
  709. X    }
  710. X#endif
  711. X#endif
  712. X
  713. X  /* Search file to find where to insert this character, if uid != 0 and
  714. X     find same uid/sex/race/class combo then exit without saving this score */
  715. X  /* Seek to the beginning of the file just to be safe. */
  716. X#ifndef BSD4_3
  717. X  (void) fseek(highscore_fp, (long)0, L_SET);
  718. X#else
  719. X  (void) fseek(highscore_fp, (off_t)0, L_SET);
  720. X#endif
  721. X
  722. X  /* Read version numbers from the score file, and check for validity.  */
  723. X  version_maj = getc (highscore_fp);
  724. X  version_min = getc (highscore_fp);
  725. X  patch_level = getc (highscore_fp);
  726. X  /* If this is a new scorefile, it should be empty.  Write the current
  727. X     version numbers to the score file.  */
  728. X  if (feof (highscore_fp))
  729. X    {
  730. X      /* Seek to the beginning of the file just to be safe. */
  731. X#ifndef BSD4_3
  732. X      (void) fseek(highscore_fp, (long)0, L_SET);
  733. X#else
  734. X      (void) fseek(highscore_fp, (off_t)0, L_SET);
  735. X#endif
  736. X
  737. X      (void) putc (CUR_VERSION_MAJ, highscore_fp);
  738. X      (void) putc (CUR_VERSION_MIN, highscore_fp);
  739. X      (void) putc (PATCH_LEVEL, highscore_fp);
  740. X
  741. X      /* must fseek() before can change read/write mode */
  742. X#ifndef BSD4_3
  743. X#ifdef ATARIST_TC
  744. X      /* no fseek relative to current position allowed */
  745. X      (void) fseek (highscore_fp, (long)ftell (highscore_fp), L_SET);
  746. X#else
  747. X      (void) fseek(highscore_fp, (long)0, L_INCR);
  748. X#endif
  749. X#else
  750. X      (void) fseek(highscore_fp, (off_t)0, L_INCR);
  751. X#endif
  752. X    }
  753. X  /* Support score files from 5.2.2 to present.  */
  754. X  else if ((version_maj != CUR_VERSION_MAJ)
  755. X       || (version_min > CUR_VERSION_MIN)
  756. X       || (version_min == CUR_VERSION_MIN && patch_level > PATCH_LEVEL)
  757. X       || (version_min == 2 && patch_level < 2)
  758. X       || (version_min < 2))
  759. X    {
  760. X      /* No need to print a message, a subsequent call to display_scores()
  761. X     will print a message.  */
  762. X#if defined(MSDOS) || defined(VMS) || defined(AMIGA) || defined(MAC)
  763. X      (void) fclose (highscore_fp);
  764. X#endif
  765. X      return;
  766. X    }
  767. X
  768. X  /* set the static fileptr in save.c to the highscore file pointer */
  769. X  set_fileptr(highscore_fp);
  770. X
  771. X  i = 0;
  772. X  curpos = ftell (highscore_fp);
  773. X  rd_highscore(&old_entry);
  774. X  while (!feof(highscore_fp))
  775. X    {
  776. X      if (new_entry.points >= old_entry.points)
  777. X    break;
  778. X      /* under unix and VMS, only allow one sex/race/class combo per person,
  779. X     on single user system, allow any number of entries, but try to
  780. X     prevent multiple entries per character by checking for case when
  781. X     birthdate/sex/race/class are the same, and died_from of scorefile
  782. X     entry is "(saved)" */
  783. X      else if (((new_entry.uid != 0 && new_entry.uid == old_entry.uid)
  784. X        || (new_entry.uid == 0 &&!strcmp(old_entry.died_from,"(saved)")
  785. X            && new_entry.birth_date == old_entry.birth_date))
  786. X           && new_entry.sex == old_entry.sex
  787. X           && new_entry.race == old_entry.race
  788. X           && new_entry.class == old_entry.class)
  789. X    {
  790. X#if defined(MSDOS) || defined(VMS) || defined(AMIGA) || defined(MAC)
  791. X      (void) fclose (highscore_fp);
  792. X#endif
  793. X      return;
  794. X    }
  795. X      else if (++i >= SCOREFILE_SIZE)
  796. X    {
  797. X      /* only allow one thousand scores in the score file */
  798. X#if defined(MSDOS) || defined(VMS) || defined(AMIGA) || defined(MAC)
  799. X      (void) fclose (highscore_fp);
  800. X#endif
  801. X      return;
  802. X    }
  803. X      curpos = ftell (highscore_fp);
  804. X      rd_highscore(&old_entry);
  805. X    }
  806. X
  807. X  if (feof(highscore_fp))
  808. X    {
  809. X      /* write out new_entry at end of file */
  810. X#ifndef BSD4_3
  811. X      (void) fseek (highscore_fp, curpos, L_SET);
  812. X#else
  813. X      (void) fseek (highscore_fp, (off_t)curpos, L_SET);
  814. X#endif
  815. X      wr_highscore(&new_entry);
  816. X    }
  817. X  else
  818. X    {
  819. X      entry = new_entry;
  820. X      while (!feof(highscore_fp))
  821. X    {
  822. X#ifndef BSD4_3
  823. X#ifdef ATARIST_TC || defined(__TURBOC__)
  824. X      /* No fseek with negative offset allowed.  */
  825. X      (void) fseek(highscore_fp, (long)ftell(highscore_fp) -
  826. X               sizeof(high_scores) - sizeof (char), L_SET);
  827. X#else
  828. X      (void) fseek(highscore_fp,
  829. X               -(long)sizeof(high_scores)-(long)sizeof(char),
  830. X               L_INCR);
  831. X#endif
  832. X#else
  833. X      (void) fseek(highscore_fp,
  834. X               -(off_t)sizeof(high_scores)-(off_t)sizeof(char),
  835. X               L_INCR);
  836. X#endif
  837. X      wr_highscore(&entry);
  838. X      /* under unix and VMS, only allow one sex/race/class combo per
  839. X         person, on single user system, allow any number of entries, but
  840. X         try to prevent multiple entries per character by checking for
  841. X         case when birthdate/sex/race/class are the same, and died_from of
  842. X         scorefile entry is "(saved)" */
  843. X      if (((new_entry.uid != 0 && new_entry.uid == old_entry.uid)
  844. X        || (new_entry.uid == 0 &&!strcmp(old_entry.died_from,"(saved)")
  845. X            && new_entry.birth_date == old_entry.birth_date))
  846. X          && new_entry.sex == old_entry.sex
  847. X          && new_entry.race == old_entry.race
  848. X          && new_entry.class == old_entry.class)
  849. X        break;
  850. X      entry = old_entry;
  851. X      /* must fseek() before can change read/write mode */
  852. X#ifndef BSD4_3
  853. X#ifdef ATARIST_TC
  854. X      /* No fseek relative to current position allowed.  */
  855. X      (void) fseek(highscore_fp, (long)ftell(highscore_fp), L_SET);
  856. X#else
  857. X      (void) fseek(highscore_fp, (long)0, L_INCR);
  858. X#endif
  859. X#else
  860. X      (void) fseek(highscore_fp, (off_t)0, L_INCR);
  861. X#endif
  862. X      curpos = ftell (highscore_fp);
  863. X      rd_highscore(&old_entry);
  864. X    }
  865. X      if (feof(highscore_fp))
  866. X    {
  867. X#ifndef BSD4_3
  868. X      (void) fseek (highscore_fp, curpos, L_SET);
  869. X#else
  870. X      (void) fseek (highscore_fp, (off_t)curpos, L_SET);
  871. X#endif
  872. X      wr_highscore(&entry);
  873. X    }
  874. X    }
  875. X
  876. X#if !defined(VMS) && !defined(MSDOS) && !defined(AMIGA) && !defined(MAC)
  877. X#ifdef ATARIST_TC
  878. X  /* Flock never called for Atari ST with TC.  */
  879. X#else
  880. X  (void) flock((int)fileno(highscore_fp), LOCK_UN);
  881. X#endif
  882. X#else
  883. X  (void) fclose (highscore_fp);
  884. X#endif
  885. X}
  886. X
  887. X
  888. X/* Change the player into a King!            -RAK-     */
  889. Xstatic void kingly()
  890. X{
  891. X  register struct misc *p_ptr;
  892. X  register char *p;
  893. X
  894. X  /* Change the character attributes.         */
  895. X  dun_level = 0;
  896. X  (void) strcpy(died_from, "Ripe Old Age");
  897. X  p_ptr = &py.misc;
  898. X  (void) restore_level ();
  899. X  p_ptr->lev += MAX_PLAYER_LEVEL;
  900. X  p_ptr->au += 250000L;
  901. X  p_ptr->max_exp += 5000000L;
  902. X  p_ptr->exp = p_ptr->max_exp;
  903. X
  904. X  /* Let the player know that he did good.     */
  905. X  clear_screen();
  906. X  put_buffer("#", 1, 34);
  907. X  put_buffer("#####", 2, 32);
  908. X  put_buffer("#", 3, 34);
  909. X  put_buffer(",,,  $$$  ,,,", 4, 28);
  910. X  put_buffer(",,=$   \"$$$$$\"   $=,,", 5, 24);
  911. X  put_buffer(",$$        $$$        $$,", 6, 22);
  912. X  put_buffer("*>         <*>         <*", 7, 22);
  913. X  put_buffer("$$         $$$         $$", 8, 22);
  914. X  put_buffer("\"$$        $$$        $$\"", 9, 22);
  915. X  put_buffer("\"$$       $$$       $$\"", 10, 23);
  916. X  p = "*#########*#########*";
  917. X  put_buffer(p, 11, 24);
  918. X  put_buffer(p, 12, 24);
  919. X  put_buffer("Veni, Vidi, Vici!", 15, 26);
  920. X  put_buffer("I came, I saw, I conquered!", 16, 21);
  921. X  if (p_ptr->male)
  922. X    put_buffer("All Hail the Mighty King!", 17, 22);
  923. X  else
  924. X    put_buffer("All Hail the Mighty Queen!", 17, 22);
  925. X  flush();
  926. X  pause_line(23);
  927. X}
  928. X
  929. X
  930. X/* Handles the gravestone end top-twenty routines    -RAK-     */
  931. Xvoid exit_game ()
  932. X{
  933. X#ifdef MAC
  934. X  /* Prevent strange things from happening */
  935. X  enablefilemenu(FALSE);
  936. X#endif
  937. X
  938. X  /* What happens upon dying.                -RAK-     */
  939. X  msg_print(CNIL);
  940. X  flush ();  /* flush all input */
  941. X  nosignals ();     /* Can't interrupt or suspend. */
  942. X  /* If the game has been saved, then save sets turn back to -1, which
  943. X     inhibits the printing of the tomb.     */
  944. X  if (turn >= 0)
  945. X    {
  946. X      if (total_winner)
  947. X    kingly();
  948. X      print_tomb();
  949. X    }
  950. X  if (character_generated && !character_saved)
  951. X#ifdef MAC
  952. X    (void) save_char (TRUE);        /* Save the memory at least. */
  953. X#else
  954. X    (void) save_char ();        /* Save the memory at least. */
  955. X#endif
  956. X  /* add score to scorefile if applicable */
  957. X  if (character_generated)
  958. X    {
  959. X      /* Clear character_saved, strange thing to do, but it prevents inkey()
  960. X     from recursively calling exit_game() when there has been an eof
  961. X     on stdin detected.  */
  962. X      character_saved = FALSE;
  963. X      highscores();
  964. X      display_scores (TRUE);
  965. X    }
  966. X  erase_line (23, 0);
  967. X  restore_term ();
  968. X#ifdef MAC
  969. X  /* Undo what has been done */
  970. X  enablefilemenu(TRUE);
  971. X  /* Long jump back into the Mac wrapper, in lieu of exit () */
  972. X  goback();
  973. X#else
  974. X  exit (0);
  975. X#endif
  976. X}
  977. END_OF_FILE
  978. if test 23954 -ne `wc -c <'source/death.c'`; then
  979.     echo shar: \"'source/death.c'\" unpacked with wrong size!
  980. fi
  981. # end of 'source/death.c'
  982. fi
  983. if test -f 'source/externs.h' -a "${1}" != "-c" ; then 
  984.   echo shar: Will not clobber existing file \"'source/externs.h'\"
  985. else
  986. echo shar: Extracting \"'source/externs.h'\" \(29501 characters\)
  987. sed "s/^X//" >'source/externs.h' <<'END_OF_FILE'
  988. X/* source/externs.h: declarations for global variables and initialized data
  989. X
  990. X   Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  991. X
  992. X   This software may be copied and distributed for educational, research, and
  993. X   not for profit purposes provided that this copyright and statement are
  994. X   included in all such copies. */
  995. X
  996. X/* VMS requires that this be in externs.h, not files.c; this prevents a
  997. X   'psect' error for the variable errno */
  998. X#include <errno.h>
  999. X
  1000. X/* Atari TC requires prototypes, but does not have __STDC__.
  1001. X   Hence, we check for ATARIST_TC here, and define LINT_ARGS if true.  */
  1002. X#ifdef ATARIST_TC
  1003. X#define LINT_ARGS
  1004. X#endif
  1005. X
  1006. X/* This causes more trouble than it is worth, and very few systems still
  1007. X   have this bug in their include files.  */
  1008. X#if 0
  1009. X/* many systems don't define these anywhere */
  1010. X#ifndef NeXT
  1011. X#ifndef AMIGA
  1012. X#if !defined(atarist) || !defined(__GNUC__)
  1013. X#ifndef __TURBOC__
  1014. X#if defined(USG) || defined(DGUX)
  1015. Xextern int sprintf();
  1016. X#else
  1017. Xextern char *sprintf();
  1018. X#endif
  1019. X#endif
  1020. X#endif
  1021. X#endif
  1022. X#endif
  1023. X#endif
  1024. X
  1025. X/* to avoid 'psect' problem with VMS declaration of errno */
  1026. X#ifndef VMS
  1027. Xextern int errno;
  1028. X#endif
  1029. X
  1030. Xextern char *copyright[5];
  1031. X
  1032. X/* horrible hack: needed because compact_monster() can be called from deep
  1033. X   within creatures() via place_monster() and summon_monster() */
  1034. Xextern int hack_monptr;
  1035. X
  1036. Xextern vtype died_from;
  1037. Xextern vtype savefile;            /* The save file. -CJS- */
  1038. Xextern int32 birth_date;
  1039. X
  1040. X/* These are options, set with set_options command -CJS- */
  1041. Xextern int rogue_like_commands;
  1042. Xextern int find_cut;            /* Cut corners on a run */
  1043. Xextern int find_examine;        /* Check corners on a run */
  1044. Xextern int find_prself;            /* Print yourself on a run (slower) */
  1045. Xextern int find_bound;            /* Stop run when the map shifts */
  1046. Xextern int prompt_carry_flag;        /* Prompt to pick something up */
  1047. Xextern int show_weight_flag;        /* Display weights in inventory */
  1048. Xextern int highlight_seams;        /* Highlight magma and quartz */
  1049. Xextern int find_ignore_doors;        /* Run through open doors */
  1050. Xextern int sound_beep_flag;        /* Beep for invalid character */
  1051. Xextern int display_counts;        /* Display rest/repeat counts */
  1052. X
  1053. X/* global flags */
  1054. Xextern int new_level_flag;      /* Next level when true  */
  1055. Xextern int teleport_flag;    /* Handle teleport traps  */
  1056. Xextern int eof_flag;        /* Used to handle eof/HANGUP */
  1057. Xextern int player_light;      /* Player carrying light */
  1058. Xextern int find_flag;    /* Used in MORIA          */
  1059. Xextern int free_turn_flag;    /* Used in MORIA          */
  1060. Xextern int weapon_heavy;    /* Flag if the weapon too heavy -CJS- */
  1061. Xextern int pack_heavy;        /* Flag if the pack too heavy -CJS- */
  1062. Xextern char doing_inven;    /* Track inventory commands */
  1063. Xextern int screen_change;    /* Screen changes (used in inven_commands) */
  1064. X
  1065. Xextern int character_generated;     /* don't save score until char gen finished*/
  1066. Xextern int character_saved;     /* prevents save on kill after save_char() */
  1067. X#if defined(STDIO_LOADED)
  1068. Xextern FILE *highscore_fp;    /* High score file pointer */
  1069. X#endif
  1070. Xextern int command_count;    /* Repetition of commands. -CJS- */
  1071. Xextern int default_dir;        /* Use last direction in repeated commands */
  1072. Xextern int16 noscore;        /* Don't score this game. -CJS- */
  1073. Xextern int32u randes_seed;    /* For encoding colors */
  1074. Xextern int32u town_seed;        /* Seed for town genera*/
  1075. Xextern int16 dun_level;    /* Cur dungeon level   */
  1076. Xextern int16 missile_ctr;    /* Counter for missiles */
  1077. Xextern int msg_flag;    /* Set with first msg  */
  1078. Xextern vtype old_msg[MAX_SAVE_MSG];    /* Last messages -CJS- */
  1079. Xextern int16 last_msg;            /* Where in the array is the last */
  1080. Xextern int death;    /* True if died          */
  1081. Xextern int32 turn;    /* Cur trun of game    */
  1082. Xextern int wizard;    /* Wizard flag          */
  1083. Xextern int to_be_wizard;
  1084. Xextern int16 panic_save; /* this is true if playing from a panic save */
  1085. X
  1086. Xextern int wait_for_more;
  1087. X
  1088. Xextern char days[7][29];
  1089. Xextern int closing_flag;    /* Used for closing   */
  1090. X
  1091. Xextern int16 cur_height, cur_width;    /* Cur dungeon size    */
  1092. X/*  Following are calculated from max dungeon sizes        */
  1093. Xextern int16 max_panel_rows, max_panel_cols;
  1094. Xextern int panel_row, panel_col;
  1095. Xextern int panel_row_min, panel_row_max;
  1096. Xextern int panel_col_min, panel_col_max;
  1097. Xextern int panel_col_prt, panel_row_prt;
  1098. X
  1099. X/*  Following are all floor definitions                */
  1100. X#ifdef MAC
  1101. Xextern cave_type (*cave)[MAX_WIDTH];
  1102. X#else
  1103. Xextern cave_type cave[MAX_HEIGHT][MAX_WIDTH];
  1104. X#endif
  1105. X
  1106. X/* Following are player variables                */
  1107. Xextern player_type py;
  1108. X#ifdef MACGAME
  1109. Xextern char *(*player_title)[MAX_PLAYER_LEVEL];
  1110. Xextern race_type *race;
  1111. Xextern background_type *background;
  1112. X#else
  1113. Xextern char *player_title[MAX_CLASS][MAX_PLAYER_LEVEL];
  1114. Xextern race_type race[MAX_RACES];
  1115. Xextern background_type background[MAX_BACKGROUND];
  1116. X#endif
  1117. Xextern int32u player_exp[MAX_PLAYER_LEVEL];
  1118. Xextern int16u player_hp[MAX_PLAYER_LEVEL];
  1119. Xextern int16 char_row;
  1120. Xextern int16 char_col;
  1121. X
  1122. Xextern int8u rgold_adj[MAX_RACES][MAX_RACES];
  1123. X
  1124. Xextern class_type class[MAX_CLASS];
  1125. Xextern int16 class_level_adj[MAX_CLASS][MAX_LEV_ADJ];
  1126. X
  1127. X/* Warriors don't have spells, so there is no entry for them. */
  1128. X#ifdef MACGAME
  1129. Xextern spell_type (*magic_spell)[31];
  1130. X#else
  1131. Xextern spell_type magic_spell[MAX_CLASS-1][31];
  1132. X#endif
  1133. Xextern char *spell_names[62];
  1134. Xextern int32u spell_learned;    /* Bit field for spells learnt -CJS- */
  1135. Xextern int32u spell_worked;    /* Bit field for spells tried -CJS- */
  1136. Xextern int32u spell_forgotten;    /* Bit field for spells forgotten -JEW- */
  1137. Xextern int8u spell_order[32];    /* remember order that spells are learned in */
  1138. Xextern int16u player_init[MAX_CLASS][5];
  1139. Xextern int16 total_winner;
  1140. Xextern int32 max_score;
  1141. X
  1142. X/* Following are store definitions                */
  1143. X#ifdef MACGAME
  1144. Xextern owner_type *owners;
  1145. X#else
  1146. Xextern owner_type owners[MAX_OWNERS];
  1147. X#endif
  1148. X#ifdef MAC
  1149. Xextern store_type *store;
  1150. X#else
  1151. Xextern store_type store[MAX_STORES];
  1152. X#endif
  1153. Xextern int16u store_choice[MAX_STORES][STORE_CHOICES];
  1154. X#ifndef MAC
  1155. Xextern int (*store_buy[MAX_STORES])();
  1156. X#endif
  1157. X
  1158. X/* Following are treasure arrays    and variables            */
  1159. X#ifdef MACGAME
  1160. Xextern treasure_type *object_list;
  1161. X#else
  1162. Xextern treasure_type object_list[MAX_OBJECTS];
  1163. X#endif
  1164. Xextern int8u object_ident[OBJECT_IDENT_SIZE];
  1165. Xextern int16 t_level[MAX_OBJ_LEVEL+1];
  1166. Xextern inven_type t_list[MAX_TALLOC];
  1167. Xextern inven_type inventory[INVEN_ARRAY_SIZE];
  1168. Xextern char *special_names[SN_ARRAY_SIZE];
  1169. Xextern int16 sorted_objects[MAX_DUNGEON_OBJ];
  1170. Xextern int16 inven_ctr;        /* Total different obj's    */
  1171. Xextern int16 inven_weight;    /* Cur carried weight    */
  1172. Xextern int16 equip_ctr;    /* Cur equipment ctr    */
  1173. Xextern int16 tcptr;    /* Cur treasure heap ptr    */
  1174. X
  1175. X/* Following are creature arrays and variables            */
  1176. X#ifdef MACGAME
  1177. Xextern creature_type *c_list;
  1178. X#else
  1179. Xextern creature_type c_list[MAX_CREATURES];
  1180. X#endif
  1181. Xextern monster_type m_list[MAX_MALLOC];
  1182. Xextern int16 m_level[MAX_MONS_LEVEL+1];
  1183. Xextern m_attack_type monster_attacks[N_MONS_ATTS];
  1184. X#ifdef MAC
  1185. Xextern recall_type *c_recall;
  1186. X#else
  1187. Xextern recall_type c_recall[MAX_CREATURES];    /* Monster memories. -CJS- */
  1188. X#endif
  1189. Xextern monster_type blank_monster;    /* Blank monster values    */
  1190. Xextern int16 mfptr;    /* Cur free monster ptr    */
  1191. Xextern int16 mon_tot_mult;    /* # of repro's of creature    */
  1192. X
  1193. X/* Following are arrays for descriptive pieces            */
  1194. X#ifdef MACGAME
  1195. Xextern char **colors;
  1196. Xextern char **mushrooms;
  1197. Xextern char **woods;
  1198. Xextern char **metals;
  1199. Xextern char **rocks;
  1200. Xextern char **amulets;
  1201. Xextern char **syllables;
  1202. X#else
  1203. Xextern char *colors[MAX_COLORS];
  1204. Xextern char *mushrooms[MAX_MUSH];
  1205. Xextern char *woods[MAX_WOODS];
  1206. Xextern char *metals[MAX_METALS];
  1207. Xextern char *rocks[MAX_ROCKS];
  1208. Xextern char *amulets[MAX_AMULETS];
  1209. Xextern char *syllables[MAX_SYLLABLES];
  1210. X#endif
  1211. X
  1212. Xextern int8u blows_table[7][6];
  1213. X
  1214. Xextern int16u normal_table[NORMAL_TABLE_SIZE];
  1215. X
  1216. X/* Initialized data which had to be moved from some other file */
  1217. X/* Since these get modified, macrsrc.c must be able to access them */
  1218. X/* Otherwise, game cannot be made restartable */
  1219. X/* dungeon.c */
  1220. Xextern char last_command;  /* Memory of previous command. */
  1221. X/* moria1.c */
  1222. X/* Track if temporary light about player.  */
  1223. Xextern int light_flag;
  1224. X
  1225. X#ifdef MSDOS
  1226. Xextern int8u    floorsym, wallsym;
  1227. Xextern int    ansi, saveprompt;
  1228. Xextern char    moriatop[], moriasav[];
  1229. X#endif
  1230. X
  1231. X/* function return values */
  1232. X/* only extern functions declared here, static functions declared inside
  1233. X   the file that defines them */
  1234. X#if defined(LINT_ARGS)
  1235. X/* these prototypes can be used by MSC and TC for type checking of arguments
  1236. X   WARNING: note that this does not work for all ANSI C compilers, e.g. Gnu C,
  1237. X   will give error messages if you use these prototypes.
  1238. X   This is due to differing interpretations of the ANSI C standard,
  1239. X   specifically how to handle promotion of parameters.  In my reading of
  1240. X   the standard, I believe that Gnu C's behaviour is correct.  */
  1241. X
  1242. X#ifdef ATARI_ST
  1243. X/* atarist.c */
  1244. Xint check_input(int microsec);
  1245. Xvoid user_name(char * buf);
  1246. Xint access(char * name, int dum);
  1247. Xvoid chmod(char * name, int mode); /* dummy function */
  1248. X#endif
  1249. X
  1250. X/* create.c */
  1251. Xvoid create_character(void);
  1252. X
  1253. X/* creature.c */
  1254. Xvoid update_mon(int);
  1255. Xint multiply_monster(int, int, int, int);
  1256. Xvoid creatures(int);
  1257. X
  1258. X/* death.c */
  1259. Xvoid display_scores(int);
  1260. Xint duplicate_character(void);
  1261. Xint32 total_points(void);
  1262. Xvoid exit_game(void);
  1263. X
  1264. X/* desc.c */
  1265. Xint is_a_vowel(char);
  1266. Xvoid magic_init(void);
  1267. Xint16 object_offset(struct inven_type *);
  1268. Xvoid known1(struct inven_type *);
  1269. Xint known1_p(struct inven_type *);
  1270. Xvoid known2(struct inven_type *);
  1271. Xint known2_p(struct inven_type *);
  1272. Xvoid clear_known2(struct inven_type *);
  1273. Xvoid clear_empty(inven_type *);
  1274. Xvoid store_bought(inven_type *);
  1275. Xint store_bought_p(inven_type *);
  1276. Xvoid sample(struct inven_type *);
  1277. Xvoid identify(int *);
  1278. Xvoid unmagic_name(struct inven_type *);
  1279. Xvoid objdes(char *, struct inven_type *, int);
  1280. Xvoid invcopy(inven_type *, int);
  1281. Xvoid desc_charges(int);
  1282. Xvoid desc_remain(int);
  1283. X
  1284. X/* dungeon.c */
  1285. Xvoid dungeon(void);
  1286. X
  1287. X/* eat.c */
  1288. Xvoid eat(void);
  1289. X
  1290. X/* files.c */
  1291. Xvoid init_scorefile(void);
  1292. Xvoid read_times(void);
  1293. Xvoid helpfile(char *);
  1294. Xvoid print_objects(void);
  1295. X#ifdef MAC
  1296. Xint file_character(void);
  1297. X#else
  1298. Xint file_character(char *);
  1299. X#endif
  1300. X
  1301. X/* generate.c */
  1302. Xvoid generate_cave(void);
  1303. X
  1304. X#ifdef VMS
  1305. X/* getch.c */
  1306. Xint kbhit (void);
  1307. Xvoid user_name (char *);
  1308. Xvoid vms_crmode (void);
  1309. Xvoid vms_nocrmode (void);
  1310. Xint opengetch (void);
  1311. Xint closegetch (void);
  1312. Xchar vms_getch (void);
  1313. X#endif
  1314. X
  1315. X/* help.c */
  1316. Xvoid ident_char(void);
  1317. X
  1318. X/* io.c */
  1319. X#ifdef SIGTSTP
  1320. Xint suspend(void);
  1321. X#endif
  1322. Xvoid init_curses(void);
  1323. Xvoid moriaterm(void);
  1324. Xvoid put_buffer(char *, int, int);
  1325. Xvoid put_qio(void);
  1326. Xvoid restore_term(void);
  1327. Xvoid shell_out(void);
  1328. Xchar inkey(void);
  1329. Xvoid flush(void);
  1330. Xvoid erase_line(int, int);
  1331. Xvoid clear_screen(void);
  1332. Xvoid clear_from(int);
  1333. Xvoid print(char, int, int);
  1334. Xvoid move_cursor_relative(int, int);
  1335. Xvoid count_msg_print(char *);
  1336. Xvoid prt(char *, int, int);
  1337. Xvoid move_cursor(int, int);
  1338. Xvoid msg_print(char *);
  1339. Xint get_check(char *);
  1340. Xint get_com(char *, char *);
  1341. Xint get_string(char *, int, int, int);
  1342. Xvoid pause_line(int);
  1343. Xvoid pause_exit(int, int);
  1344. Xvoid save_screen(void);
  1345. Xvoid restore_screen(void);
  1346. Xvoid bell(void);
  1347. Xvoid screen_map(void);
  1348. X
  1349. X/* magic.c */
  1350. Xvoid cast(void);
  1351. X
  1352. X/* main.c */
  1353. Xint main(int, char **);
  1354. X
  1355. X/* misc1.c */
  1356. Xvoid init_seeds(int32u);
  1357. Xvoid set_seed(int32u);
  1358. Xvoid reset_seed(void);
  1359. Xint check_time(void);
  1360. Xint randint(int);
  1361. Xint randnor(int, int);
  1362. Xint bit_pos(int32u *);
  1363. Xint in_bounds(int, int);
  1364. Xvoid panel_bounds(void);
  1365. Xint get_panel(int, int, int);
  1366. Xint panel_contains(int, int);
  1367. Xint distance(int, int, int, int);
  1368. Xint next_to_wall(int, int);
  1369. Xint next_to_corr(int, int);
  1370. Xint damroll(int, int);
  1371. Xint pdamroll(unsigned char *);
  1372. Xint los(int, int, int, int);
  1373. Xunsigned char loc_symbol(int, int);
  1374. Xint test_light(int, int);
  1375. Xvoid prt_map(void);
  1376. Xint compact_monsters(void);
  1377. Xvoid add_food(int);
  1378. Xint popm(void);
  1379. Xint max_hp(unsigned char *);
  1380. Xint place_monster(int, int, int, int);
  1381. Xvoid place_win_monster(void);
  1382. Xint get_mons_num(int);
  1383. Xvoid alloc_monster(int, int, int);
  1384. Xint summon_monster(int * ,int *, int);
  1385. Xint summon_undead(int *, int *);
  1386. Xint popt(void);
  1387. Xvoid pusht(int8u);
  1388. Xint magik(int);
  1389. Xint m_bonus(int, int, int);
  1390. X
  1391. X/* misc2.c */
  1392. Xvoid magic_treasure(int, int);
  1393. Xvoid set_options(void);
  1394. X
  1395. X/* misc3.c */
  1396. Xvoid place_trap(int, int, int);
  1397. Xvoid place_rubble(int, int);
  1398. Xvoid place_gold(int, int);
  1399. Xint get_obj_num(int);
  1400. Xvoid place_object(int, int);
  1401. Xvoid alloc_object(int (*)(), int, int);
  1402. Xvoid random_object(int, int, int);
  1403. Xvoid cnv_stat(int8u, char *);
  1404. Xvoid prt_stat(int);
  1405. Xvoid prt_field(char *, int, int);
  1406. Xint stat_adj(int);
  1407. Xint chr_adj(void);
  1408. Xint con_adj(void);
  1409. Xchar *title_string(void);
  1410. Xvoid prt_title(void);
  1411. Xvoid prt_level(void);
  1412. Xvoid prt_cmana(void);
  1413. Xvoid prt_mhp(void);
  1414. Xvoid prt_chp(void);
  1415. Xvoid prt_pac(void);
  1416. Xvoid prt_gold(void);
  1417. Xvoid prt_depth(void);
  1418. Xvoid prt_hunger(void);
  1419. Xvoid prt_blind(void);
  1420. Xvoid prt_confused(void);
  1421. Xvoid prt_afraid(void);
  1422. Xvoid prt_poisoned(void);
  1423. Xvoid prt_state(void);
  1424. Xvoid prt_speed(void);
  1425. Xvoid prt_study(void);
  1426. Xvoid prt_winner(void);
  1427. Xint8u modify_stat(int, int16);
  1428. Xvoid set_use_stat(int);
  1429. Xint inc_stat(int);
  1430. Xint dec_stat(int);
  1431. Xint res_stat(int);
  1432. Xvoid bst_stat(int, int);
  1433. Xint tohit_adj(void);
  1434. Xint toac_adj(void);
  1435. Xint todis_adj(void);
  1436. Xint todam_adj(void);
  1437. Xvoid prt_stat_block(void);
  1438. Xvoid draw_cave(void);
  1439. Xvoid put_character(void);
  1440. Xvoid put_stats(void);
  1441. Xchar *likert(int, int);
  1442. Xvoid put_misc1(void);
  1443. Xvoid put_misc2(void);
  1444. Xvoid put_misc3(void);
  1445. Xvoid display_char(void);
  1446. Xvoid get_name(void);
  1447. Xvoid change_name(void);
  1448. Xvoid inven_destroy(int);
  1449. Xvoid take_one_item(struct inven_type *, struct inven_type *);
  1450. Xvoid inven_drop(int, int);
  1451. Xint inven_damage(int (*)(), int);
  1452. Xint weight_limit(void);
  1453. Xint inven_check_num(struct inven_type *);
  1454. Xint inven_check_weight(struct inven_type *);
  1455. Xvoid check_strength(void);
  1456. Xint inven_carry(struct inven_type *);
  1457. Xint spell_chance(int);
  1458. Xvoid print_spells(int *, int, int, int);
  1459. Xint get_spell(int *, int, int *, int *, char *, int);
  1460. Xvoid calc_spells(int);
  1461. Xvoid gain_spells(void);
  1462. Xvoid calc_mana(int);
  1463. Xvoid prt_experience(void);
  1464. Xvoid calc_hitpoints(void);
  1465. Xvoid insert_str(char *, char *, char *);
  1466. Xvoid insert_lnum(char *, char *, int32, int);
  1467. Xint enter_wiz_mode(void);
  1468. Xint attack_blows(int, int *);
  1469. Xint tot_dam(struct inven_type *, int, int);
  1470. Xint critical_blow(int, int, int, int);
  1471. Xint mmove(int, int *, int *);
  1472. Xint player_saves(void);
  1473. Xint find_range(int, int, int *, int *);
  1474. Xvoid teleport(int);
  1475. X
  1476. X/* misc4.c */
  1477. Xvoid scribe_object(void);
  1478. Xvoid add_inscribe(struct inven_type *, int8u);
  1479. Xvoid inscribe(struct inven_type *, char *);
  1480. Xvoid check_view(void);
  1481. X
  1482. X/* monsters.c */
  1483. X
  1484. X/* moria1.c */
  1485. Xvoid change_speed(int);
  1486. Xvoid py_bonuses(struct inven_type *, int);
  1487. Xvoid calc_bonuses(void);
  1488. Xint show_inven(int, int, int, int, char *);
  1489. Xchar *describe_use(int);
  1490. Xint show_equip(int, int);
  1491. Xvoid takeoff(int, int);
  1492. Xint verify(char *, int);
  1493. Xvoid inven_command(char);
  1494. Xint get_item(int *, char *, int, int, char *, char *);
  1495. Xint no_light(void);
  1496. Xint get_dir(char *, int *);
  1497. Xint get_alldir(char *, int *);
  1498. Xvoid move_rec(int, int, int, int);
  1499. Xvoid light_room(int, int);
  1500. Xvoid lite_spot(int, int);
  1501. Xvoid move_light(int, int, int, int);
  1502. Xvoid disturb(int, int);
  1503. Xvoid search_on(void);
  1504. Xvoid search_off(void);
  1505. Xvoid rest(void);
  1506. Xvoid rest_off(void);
  1507. Xint test_hit(int, int, int, int, int);
  1508. Xvoid take_hit(int, char *);
  1509. X
  1510. X/* moria2.c */
  1511. Xvoid change_trap(int, int);
  1512. Xvoid search(int, int, int);
  1513. Xvoid find_init(int);
  1514. Xvoid find_run(void);
  1515. Xvoid end_find(void);
  1516. Xvoid area_affect(int, int, int);
  1517. Xint minus_ac(int32u);
  1518. Xvoid corrode_gas(char *);
  1519. Xvoid poison_gas(int, char *);
  1520. Xvoid fire_dam(int, char *);
  1521. Xvoid cold_dam(int, char *);
  1522. Xvoid light_dam(int, char *);
  1523. Xvoid acid_dam(int, char *);
  1524. X
  1525. X/* moria3.c */
  1526. Xint cast_spell(char * ,int, int *, int *);
  1527. Xvoid delete_monster(int);
  1528. Xvoid fix1_delete_monster(int);
  1529. Xvoid fix2_delete_monster(int);
  1530. Xint delete_object(int, int);
  1531. Xint32u monster_death(int, int, int32u);
  1532. Xint mon_take_hit(int, int);
  1533. Xvoid py_attack(int, int);
  1534. Xvoid move_char(int, int);
  1535. Xvoid chest_trap(int, int);
  1536. Xvoid openobject(void);
  1537. Xvoid closeobject(void);
  1538. Xint twall(int, int, int, int);
  1539. X
  1540. X/* moria4.c */
  1541. Xvoid tunnel(int);
  1542. Xvoid disarm_trap(void);
  1543. Xvoid look(void);
  1544. Xvoid throw_object(void);
  1545. Xvoid bash(void);
  1546. X
  1547. X#ifdef MSDOS
  1548. X/* ms_misc.c */
  1549. Xvoid user_name(char *);
  1550. Xchar *getlogin(void);
  1551. X#ifdef __TURBOC__
  1552. Xvoid sleep(unsigned);
  1553. X#else
  1554. Xunsigned int sleep(int);
  1555. X#endif
  1556. Xvoid error(char *, ...);
  1557. Xvoid warn(char *, ...);
  1558. Xvoid msdos_init(void);
  1559. Xvoid msdos_raw(void);
  1560. Xvoid msdos_noraw(void);
  1561. Xint bios_getch(void);
  1562. Xint msdos_getch(void);
  1563. Xvoid bios_clear(void);
  1564. Xvoid msdos_intro(void);
  1565. Xvoid bios_clear(void);
  1566. X#endif
  1567. X
  1568. X/* potions.c */
  1569. Xvoid quaff(void);
  1570. X
  1571. X/* prayer.c */
  1572. Xvoid pray(void);
  1573. X
  1574. X/* recall.c */
  1575. Xint bool_roff_recall(int);
  1576. Xint roff_recall(int);
  1577. X
  1578. X/* rnd.c */
  1579. Xint32u get_rnd_seed(void);
  1580. Xvoid set_rnd_seed(int32u);
  1581. Xint32 rnd(void);
  1582. X
  1583. X/* save.c */
  1584. X#ifdef MAC
  1585. Xint save_char(int);
  1586. X#else
  1587. Xint save_char(void);
  1588. X#endif
  1589. Xint _save_char(char *);
  1590. Xint get_char(int *);
  1591. X#if defined(STDIO_LOADED)
  1592. Xvoid set_fileptr(FILE *);
  1593. X#endif
  1594. Xvoid wr_highscore(high_scores *);
  1595. Xvoid rd_highscore(high_scores *);
  1596. X
  1597. X/* scrolls.c */
  1598. Xvoid read_scroll(void);
  1599. X
  1600. X/* sets.c */
  1601. Xint set_room(int);
  1602. Xint set_corr(int);
  1603. Xint set_floor(int);
  1604. Xint set_corrodes(inven_type *);
  1605. Xint set_flammable(inven_type *);
  1606. Xint set_frost_destroy(inven_type *);
  1607. Xint set_acid_affect(inven_type *);
  1608. Xint set_lightning_destroy(inven_type *);
  1609. Xint set_null(inven_type *);
  1610. Xint set_acid_destroy(inven_type *);
  1611. Xint set_fire_destroy(inven_type *);
  1612. Xint general_store(int);
  1613. Xint armory(int);
  1614. Xint weaponsmith(int);
  1615. Xint temple(int);
  1616. Xint alchemist(int);
  1617. Xint magic_shop(int);
  1618. X#ifdef MAC
  1619. Xint store_buy(int, int);
  1620. X#endif
  1621. X
  1622. X/* signals.c */
  1623. Xvoid nosignals(void);
  1624. Xvoid signals(void);
  1625. Xvoid init_signals(void);
  1626. Xvoid ignore_signals(void);
  1627. Xvoid default_signals(void);
  1628. Xvoid restore_signals(void);
  1629. X
  1630. X/* spells.c */
  1631. Xvoid monster_name(char *, struct monster_type *, struct creature_type *);
  1632. Xvoid lower_monster_name(char *, struct monster_type *,
  1633. X            struct creature_type *);
  1634. Xint sleep_monsters1(int, int);
  1635. Xint detect_treasure(void);
  1636. Xint detect_object(void);
  1637. Xint detect_trap(void);
  1638. Xint detect_sdoor(void);
  1639. Xint detect_invisible(void);
  1640. Xint light_area(int, int);
  1641. Xint unlight_area(int, int);
  1642. Xvoid map_area(void);
  1643. Xint ident_spell(void);
  1644. Xint aggravate_monster(int);
  1645. Xint trap_creation(void);
  1646. Xint door_creation(void);
  1647. Xint td_destroy(void);
  1648. Xint detect_monsters(void);
  1649. Xvoid light_line(int, int, int);
  1650. Xvoid starlite(int, int);
  1651. Xint disarm_all(int, int, int);
  1652. Xvoid get_flags(int, int32u *, int *, int (**)());
  1653. Xvoid fire_bolt(int, int, int, int, int, char *);
  1654. Xvoid fire_ball(int, int, int, int, int, char *);
  1655. Xvoid breath(int, int, int, int, char *, int);
  1656. Xint recharge(int);
  1657. Xint hp_monster(int, int, int, int);
  1658. Xint drain_life(int, int, int);
  1659. Xint speed_monster(int, int, int, int);
  1660. Xint confuse_monster(int, int, int);
  1661. Xint sleep_monster(int, int, int);
  1662. Xint wall_to_mud(int, int, int);
  1663. Xint td_destroy2(int, int, int);
  1664. Xint poly_monster(int, int, int);
  1665. Xint build_wall(int, int, int);
  1666. Xint clone_monster(int, int, int);
  1667. Xvoid teleport_away(int, int);
  1668. Xvoid teleport_to(int, int);
  1669. Xint teleport_monster(int, int, int);
  1670. Xint mass_genocide(void);
  1671. Xint genocide(void);
  1672. Xint speed_monsters(int);
  1673. Xint sleep_monsters2(void);
  1674. Xint mass_poly(void);
  1675. Xint detect_evil(void);
  1676. Xint hp_player(int);
  1677. Xint cure_confusion(void);
  1678. Xint cure_blindness(void);
  1679. Xint cure_poison(void);
  1680. Xint remove_fear(void);
  1681. Xvoid earthquake(void);
  1682. Xint protect_evil(void);
  1683. Xvoid create_food(void);
  1684. Xint dispel_creature(int, int);
  1685. Xint turn_undead(void);
  1686. Xvoid warding_glyph(void);
  1687. Xvoid lose_str(void);
  1688. Xvoid lose_int(void);
  1689. Xvoid lose_wis(void);
  1690. Xvoid lose_dex(void);
  1691. Xvoid lose_con(void);
  1692. Xvoid lose_chr(void);
  1693. Xvoid lose_exp(int32);
  1694. Xint slow_poison(void);
  1695. Xvoid bless(int);
  1696. Xvoid detect_inv2(int);
  1697. Xvoid destroy_area(int, int);
  1698. Xint enchant(int16 *, int16);
  1699. Xint remove_curse(void);
  1700. Xint restore_level(void);
  1701. X
  1702. X/* staffs.c */
  1703. Xvoid use(void);
  1704. X
  1705. X/* store1.c */
  1706. Xint32 item_value(struct inven_type *);
  1707. Xint32 sell_price(int, int32 *, int32 *, struct inven_type *);
  1708. Xint store_check_num(struct inven_type *, int);
  1709. Xvoid store_carry(int, int *, struct inven_type *);
  1710. Xvoid store_destroy(int, int, int);
  1711. Xvoid store_init(void);
  1712. Xvoid store_maint(void);
  1713. Xint noneedtobargain(int, int32);
  1714. Xvoid updatebargain(int, int32, int32);
  1715. X
  1716. X/* store2.c */
  1717. Xvoid enter_store(int);
  1718. X
  1719. X/* treasur1.c */
  1720. X
  1721. X/* treasur2.c */
  1722. X
  1723. X#ifdef VMS
  1724. X/* uexit.c */
  1725. Xvoid uexit (int);
  1726. X#endif
  1727. X
  1728. X#ifdef unix
  1729. X/* unix.c */
  1730. Xint check_input(int);
  1731. X#if 0
  1732. Xint system_cmd(char *);
  1733. X#endif
  1734. Xvoid user_name(char *);
  1735. Xint tilde(char *, char *);
  1736. X/* only declare this if stdio.h has been previously included, STDIO_LOADED
  1737. X   is defined after stdio.h is included */
  1738. X#if defined(STDIO_LOADED)
  1739. XFILE *tfopen(char *, char *);
  1740. X#endif
  1741. Xint topen(char *, int, int);
  1742. X#endif
  1743. X
  1744. X/* variable.c */
  1745. X
  1746. X/* wands.c */
  1747. Xvoid aim(void);
  1748. X
  1749. X/* wizard.c */
  1750. Xvoid wizard_light(void);
  1751. Xvoid change_character(void);
  1752. Xvoid wizard_create(void);
  1753. X
  1754. X#else
  1755. X/* !defined (LINT_ARGS) */
  1756. X
  1757. X#ifdef ATARI_ST
  1758. X/* atarist.c */
  1759. Xint check_input ();
  1760. Xvoid user_name ();
  1761. Xint access ();
  1762. Xvoid chmod ();
  1763. X#endif
  1764. X
  1765. X/* create.c */
  1766. Xvoid create_character();
  1767. X
  1768. X/* creature.c */
  1769. Xvoid update_mon();
  1770. Xint multiply_monster();
  1771. Xvoid creatures();
  1772. X
  1773. X/* death.c */
  1774. Xvoid display_scores();
  1775. Xint duplicate_character();
  1776. Xint32 total_points();
  1777. Xvoid exit_game();
  1778. X
  1779. X/* desc.c */
  1780. Xint is_a_vowel();
  1781. Xvoid magic_init();
  1782. Xint16 object_offset();
  1783. Xvoid known1();
  1784. Xint known1_p();
  1785. Xvoid known2();
  1786. Xint known2_p();
  1787. Xvoid clear_known2();
  1788. Xvoid clear_empty();
  1789. Xvoid store_bought();
  1790. Xint store_bought_p();
  1791. Xvoid sample();
  1792. Xvoid identify();
  1793. Xvoid unmagic_name();
  1794. Xvoid objdes();
  1795. Xvoid invcopy();
  1796. Xvoid desc_charges();
  1797. Xvoid desc_remain();
  1798. X
  1799. X/* dungeon.c */
  1800. Xvoid dungeon();
  1801. X
  1802. X/* eat.c */
  1803. Xvoid eat();
  1804. X
  1805. X/* files.c */
  1806. Xvoid init_scorefile();
  1807. Xvoid read_times();
  1808. Xvoid helpfile();
  1809. Xvoid print_objects();
  1810. Xint file_character();
  1811. X
  1812. X/* generate.c */
  1813. Xvoid generate_cave();
  1814. X
  1815. X#ifdef VMS
  1816. X/* getch.c */
  1817. Xint kbhit ();
  1818. Xvoid user_name ();
  1819. Xvoid vms_crmode ();
  1820. Xvoid vms_nocrmode ();
  1821. Xint opengetch ();
  1822. Xint closegetch ();
  1823. Xchar vms_getch ();
  1824. X#endif
  1825. X
  1826. X/* help.c */
  1827. Xvoid ident_char();
  1828. X
  1829. X/* io.c */
  1830. X#ifdef SIGTSTP
  1831. Xint suspend();
  1832. X#endif
  1833. Xvoid init_curses();
  1834. Xvoid moriaterm();
  1835. Xvoid put_buffer();
  1836. Xvoid put_qio();
  1837. Xvoid restore_term();
  1838. Xvoid shell_out();
  1839. Xchar inkey();
  1840. Xvoid flush();
  1841. Xvoid erase_line();
  1842. Xvoid clear_screen();
  1843. Xvoid clear_from();
  1844. Xvoid print();
  1845. Xvoid move_cursor_relative();
  1846. Xvoid count_msg_print();
  1847. Xvoid prt();
  1848. Xvoid move_cursor();
  1849. Xvoid msg_print();
  1850. Xint get_check();
  1851. Xint get_com();
  1852. Xint get_string();
  1853. Xvoid pause_line();
  1854. Xvoid pause_exit();
  1855. Xvoid save_screen();
  1856. Xvoid restore_screen();
  1857. Xvoid bell();
  1858. Xvoid screen_map();
  1859. X
  1860. X/* magic.c */
  1861. Xvoid cast();
  1862. X
  1863. X/* main.c */
  1864. Xint main();
  1865. X
  1866. X/* misc1.c */
  1867. Xvoid init_seeds();
  1868. Xvoid set_seed();
  1869. Xvoid reset_seed();
  1870. Xint check_time();
  1871. Xint randint();
  1872. Xint randnor();
  1873. Xint bit_pos();
  1874. Xint in_bounds();
  1875. Xvoid panel_bounds();
  1876. Xint get_panel();
  1877. Xint panel_contains();
  1878. Xint distance();
  1879. Xint next_to_walls();
  1880. Xint next_to_corr();
  1881. Xint damroll();
  1882. Xint pdamroll();
  1883. Xint los();
  1884. Xunsigned char loc_symbol();
  1885. Xint test_light();
  1886. Xvoid prt_map();
  1887. Xint compact_monsters();
  1888. Xvoid add_food();
  1889. Xint popm();
  1890. Xint max_hp();
  1891. Xint place_monster();
  1892. Xvoid place_win_monster();
  1893. Xint get_mons_num();
  1894. Xvoid alloc_monster();
  1895. Xint summon_monster();
  1896. Xint summon_undead();
  1897. Xint popt();
  1898. Xvoid pusht();
  1899. Xint magik();
  1900. Xint m_bonus();
  1901. X
  1902. X/* misc2.c */
  1903. Xvoid magic_treasure();
  1904. Xvoid set_options();
  1905. X
  1906. X/* misc3.c */
  1907. Xvoid place_trap();
  1908. Xvoid place_rubble();
  1909. Xvoid place_gold();
  1910. Xint get_obj_num();
  1911. Xvoid place_object();
  1912. Xvoid alloc_object();
  1913. Xvoid random_object();
  1914. Xvoid cnv_stat();
  1915. Xvoid prt_stat();
  1916. Xvoid prt_field();
  1917. Xint stat_adj();
  1918. Xint chr_adj();
  1919. Xint con_adj();
  1920. Xchar *title_string();
  1921. Xvoid prt_title();
  1922. Xvoid prt_level();
  1923. Xvoid prt_cmana();
  1924. Xvoid prt_mhp();
  1925. Xvoid prt_chp();
  1926. Xvoid prt_pac();
  1927. Xvoid prt_gold();
  1928. Xvoid prt_depth();
  1929. Xvoid prt_hunger();
  1930. Xvoid prt_blind();
  1931. Xvoid prt_confused();
  1932. Xvoid prt_afraid();
  1933. Xvoid prt_poisoned();
  1934. Xvoid prt_state();
  1935. Xvoid prt_speed();
  1936. Xvoid prt_study();
  1937. Xvoid prt_winner();
  1938. Xint8u modify_stat();
  1939. Xvoid set_use_stat();
  1940. Xint inc_stat();
  1941. Xint dec_stat();
  1942. Xint res_stat();
  1943. Xvoid bst_stat();
  1944. Xint tohit_adj();
  1945. Xint toac_adj();
  1946. Xint todis_adj();
  1947. Xint todam_adj();
  1948. Xvoid prt_stat_block();
  1949. Xvoid draw_cave();
  1950. Xvoid put_character();
  1951. Xvoid put_stats();
  1952. Xchar *likert();
  1953. Xvoid put_misc1();
  1954. Xvoid put_misc2();
  1955. Xvoid put_misc3();
  1956. Xvoid display_char();
  1957. Xvoid get_name();
  1958. Xvoid change_name();
  1959. Xvoid inven_destroy();
  1960. Xvoid take_one_item();
  1961. Xvoid inven_drop();
  1962. Xint inven_damage();
  1963. Xint weight_limit();
  1964. Xint inven_check_num();
  1965. Xint inven_check_weight();
  1966. Xvoid check_strength();
  1967. Xint inven_carry();
  1968. Xint spell_chance();
  1969. Xvoid print_spells();
  1970. Xint get_spell();
  1971. Xvoid calc_spells();
  1972. Xvoid gain_spells();
  1973. Xvoid calc_mana();
  1974. Xvoid prt_experience();
  1975. Xvoid calc_hitpoints();
  1976. Xvoid insert_str();
  1977. Xvoid insert_lnum();
  1978. Xint enter_wiz_mode();
  1979. Xint attack_blows();
  1980. Xint tot_dam();
  1981. Xint critical_blow();
  1982. Xint mmove();
  1983. Xint player_saves();
  1984. Xint find_range();
  1985. Xvoid teleport();
  1986. X
  1987. X/* misc4.c */
  1988. Xvoid scribe_object();
  1989. Xvoid add_inscribe();
  1990. Xvoid inscribe();
  1991. Xvoid check_view();
  1992. X
  1993. X/* monsters.c */
  1994. X
  1995. X/* moria1.c */
  1996. Xvoid change_speed();
  1997. Xvoid py_bonuses();
  1998. Xvoid calc_bonuses();
  1999. Xint show_inven();
  2000. Xchar *describe_use();
  2001. Xint show_equip();
  2002. Xvoid takeoff();
  2003. Xint verify();
  2004. Xvoid inven_command();
  2005. Xint get_item();
  2006. Xint no_light();
  2007. Xint get_dir();
  2008. Xint get_alldir();
  2009. Xvoid move_rec();
  2010. Xvoid light_room();
  2011. Xvoid lite_spot();
  2012. Xvoid move_light();
  2013. Xvoid disturb();
  2014. Xvoid search_on();
  2015. Xvoid search_off();
  2016. Xvoid rest();
  2017. Xvoid rest_off();
  2018. Xint test_hit();
  2019. Xvoid take_hit();
  2020. X
  2021. X/* moria2.c */
  2022. Xvoid change_trap();
  2023. Xvoid search();
  2024. Xvoid find_init();
  2025. Xvoid find_run();
  2026. Xvoid end_find();
  2027. Xvoid area_affect();
  2028. Xint minus_ac();
  2029. Xvoid corrode_gas();
  2030. Xvoid poison_gas();
  2031. Xvoid fire_dam();
  2032. Xvoid cold_dam();
  2033. Xvoid light_dam();
  2034. Xvoid acid_dam();
  2035. X
  2036. X/* moria3.c */
  2037. Xint cast_spell();
  2038. Xvoid delete_monster();
  2039. Xvoid fix1_delete_monster();
  2040. Xvoid fix2_delete_monster();
  2041. Xint delete_object();
  2042. Xint32u monster_death();
  2043. Xint mon_take_hit();
  2044. Xvoid py_attack();
  2045. Xvoid move_char();
  2046. Xvoid chest_trap();
  2047. Xvoid openobject();
  2048. Xvoid closeobject();
  2049. Xint twall();
  2050. X
  2051. X/* moria4.c */
  2052. Xvoid tunnel();
  2053. Xvoid disarm_trap();
  2054. Xvoid look();
  2055. Xvoid throw_object();
  2056. Xvoid bash();
  2057. X
  2058. X#ifdef MSDOS
  2059. X/* ms_misc.c */
  2060. Xvoid user_name();
  2061. Xchar *getlogin();
  2062. X#ifdef __TURBOC__
  2063. Xvoid sleep();
  2064. X#else
  2065. Xunsigned int sleep();
  2066. X#endif
  2067. X#if 0
  2068. Xvoid error();
  2069. Xvoid warn();
  2070. X#else
  2071. X/* Because an empty parameter list in a declaration can not match a parameter
  2072. X   list with an elipsis in a definition.  */
  2073. Xvoid error (char *fmt, ...);
  2074. Xvoid warn (char *fmt, ...);
  2075. X#endif
  2076. Xvoid msdos_init();
  2077. Xvoid msdos_raw();
  2078. Xvoid msdos_noraw();
  2079. Xint bios_getch();
  2080. Xint msdos_getch();
  2081. Xvoid bios_clear();
  2082. Xvoid msdos_intro();
  2083. Xvoid bios_clear();
  2084. X#endif
  2085. X
  2086. X/* potions.c */
  2087. Xvoid quaff();
  2088. X
  2089. X/* prayer.c */
  2090. Xvoid pray();
  2091. X
  2092. X/* recall.c */
  2093. Xint bool_roff_recall();
  2094. Xint roff_recall();
  2095. X
  2096. X/* rnd.c */
  2097. Xint32u get_rnd_seed();
  2098. Xvoid set_rnd_seed();
  2099. Xint32 rnd();
  2100. X
  2101. X/* save.c */
  2102. Xint save_char();
  2103. Xint _save_char();
  2104. Xint get_char();
  2105. X#if defined(STDIO_LOADED)
  2106. Xvoid set_fileptr();
  2107. X#endif
  2108. Xvoid wr_highscore();
  2109. Xvoid rd_highscore();
  2110. X
  2111. X/* scrolls.c */
  2112. Xvoid read_scroll();
  2113. X
  2114. X/* sets.c */
  2115. Xint set_room();
  2116. Xint set_corr();
  2117. Xint set_floor();
  2118. Xint set_corrodes();
  2119. Xint set_flammable();
  2120. Xint set_frost_destroy();
  2121. Xint set_acid_affect();
  2122. Xint set_lightning_destroy();
  2123. Xint set_null();
  2124. Xint set_acid_destroy();
  2125. Xint set_fire_destroy();
  2126. Xint general_store();
  2127. Xint armory();
  2128. Xint weaponsmith();
  2129. Xint temple();
  2130. Xint alchemist();
  2131. Xint magic_shop();
  2132. X#ifdef MAC
  2133. Xint store_buy();
  2134. X#endif
  2135. X
  2136. X/* signals.c */
  2137. Xvoid nosignals();
  2138. Xvoid signals();
  2139. Xvoid init_signals();
  2140. Xvoid ignore_signals();
  2141. Xvoid default_signals();
  2142. Xvoid restore_signals();
  2143. X
  2144. X/* spells.c */
  2145. Xvoid monster_name();
  2146. Xvoid lower_monster_name();
  2147. Xint sleep_monsters1();
  2148. Xint detect_treasure();
  2149. Xint detect_object();
  2150. Xint detect_trap();
  2151. Xint detect_sdoor();
  2152. Xint detect_invisible();
  2153. Xint light_area();
  2154. Xint unlight_area();
  2155. Xvoid map_area();
  2156. Xint ident_spell();
  2157. Xint aggravate_monster();
  2158. Xint trap_creation();
  2159. Xint door_creation();
  2160. Xint td_destroy();
  2161. Xint detect_monsters();
  2162. Xvoid light_line();
  2163. Xvoid starlite();
  2164. Xint disarm_all();
  2165. Xvoid get_flags();
  2166. Xvoid fire_bolt();
  2167. Xvoid fire_ball();
  2168. Xvoid breath();
  2169. Xint recharge();
  2170. Xint hp_monster();
  2171. Xint drain_life();
  2172. Xint speed_monster();
  2173. Xint confuse_monster();
  2174. Xint sleep_monster();
  2175. Xint wall_to_mud();
  2176. Xint td_destroy2();
  2177. Xint poly_monster();
  2178. Xint build_wall();
  2179. Xint clone_monster();
  2180. Xvoid teleport_away();
  2181. Xvoid teleport_to();
  2182. Xint teleport_monster();
  2183. Xint mass_genocide();
  2184. Xint genocide();
  2185. Xint speed_monsters();
  2186. Xint sleep_monsters2();
  2187. Xint mass_poly();
  2188. Xint detect_evil();
  2189. Xint hp_player();
  2190. Xint cure_confusion();
  2191. Xint cure_blindness();
  2192. Xint cure_poison();
  2193. Xint remove_fear();
  2194. Xvoid earthquake();
  2195. Xint protect_evil();
  2196. Xvoid create_food();
  2197. Xint dispel_creature();
  2198. Xint turn_undead();
  2199. Xvoid warding_glyph();
  2200. Xvoid lose_str();
  2201. Xvoid lose_int();
  2202. Xvoid lose_wis();
  2203. Xvoid lose_dex();
  2204. Xvoid lose_con();
  2205. Xvoid lose_chr();
  2206. Xvoid lose_exp();
  2207. Xint slow_poison();
  2208. Xvoid bless();
  2209. Xvoid detect_inv2();
  2210. Xvoid destroy_area();
  2211. Xint enchant();
  2212. Xint remove_curse();
  2213. Xint restore_level();
  2214. X
  2215. X/* staffs.c */
  2216. Xvoid use();
  2217. X
  2218. X/* store1.c */
  2219. Xint32 item_value();
  2220. Xint32 sell_price();
  2221. Xint store_check_num();
  2222. Xvoid store_carry();
  2223. Xvoid store_destroy();
  2224. Xvoid store_init();
  2225. Xvoid store_maint();
  2226. Xint noneedtobargain();
  2227. Xvoid updatebargain();
  2228. X
  2229. X/* store2.c */
  2230. Xvoid enter_store();
  2231. X
  2232. X/* treasur1.c */
  2233. X
  2234. X/* treasur2.c */
  2235. X
  2236. X#ifdef VMS
  2237. X/* uexit.c */
  2238. Xvoid uexit ();
  2239. X#endif
  2240. X
  2241. X#ifdef unix
  2242. X/* unix.c */
  2243. Xint check_input();
  2244. X#if 0
  2245. Xint system_cmd();
  2246. X#endif
  2247. Xvoid user_name();
  2248. Xint tilde();
  2249. X/* only declare this if stdio.h has been previously included, STDIO_LOADED
  2250. X   is defined after stdio.h is included  */
  2251. X#if defined(STDIO_LOADED)
  2252. XFILE *tfopen();
  2253. X#endif
  2254. Xint topen();
  2255. X#endif
  2256. X
  2257. X/* variable.c */
  2258. X
  2259. X/* wands.c */
  2260. Xvoid aim();
  2261. X
  2262. X/* wizard.c */
  2263. Xvoid wizard_light();
  2264. Xvoid change_character();
  2265. Xvoid wizard_create();
  2266. X
  2267. X#endif
  2268. X
  2269. X#ifdef unix
  2270. X/* call functions which expand tilde before calling open/fopen */
  2271. X#define open topen
  2272. X#define fopen tfopen
  2273. X#endif
  2274. X
  2275. X/* st-stuff.c for the atari ST */
  2276. X#if defined(atarist) && defined(__GNUC__)
  2277. Xextern char extended_file_name[80];
  2278. X#endif
  2279. END_OF_FILE
  2280. if test 29501 -ne `wc -c <'source/externs.h'`; then
  2281.     echo shar: \"'source/externs.h'\" unpacked with wrong size!
  2282. fi
  2283. # end of 'source/externs.h'
  2284. fi
  2285. echo shar: End of archive 22 \(of 39\).
  2286. cp /dev/null ark22isdone
  2287. MISSING=""
  2288. 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
  2289.     if test ! -f ark${I}isdone ; then
  2290.     MISSING="${MISSING} ${I}"
  2291.     fi
  2292. done
  2293. if test "${MISSING}" = "" ; then
  2294.     echo You have unpacked all 39 archives.
  2295.     echo "Now run "bldfiles.sh" to build split files"
  2296.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2297. else
  2298.     echo You still need to unpack the following archives:
  2299.     echo "        " ${MISSING}
  2300. fi
  2301. ##  End of shell archive.
  2302. exit 0
  2303.