home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume17 / napoleon / part03 < prev    next >
Encoding:
Text File  |  1993-03-03  |  54.7 KB  |  1,847 lines

  1. Subject:  v17i040:  napoleon - text adventure game, Part03/04
  2. Newsgroups: comp.sources.games
  3. Approved: billr@saab.CNA.TEK.COM
  4.  
  5. Submitted-by: pc123@cus.cam.ac.uk (Pete Chown)
  6. Posting-number: Volume 17, Issue 40
  7. Archive-name: napoleon/Part03
  8. Environment: Unix, ASNI-C
  9.  
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 3 (of 4)."
  18. # Contents:  describe.c difftime.c file.c lex.c line.c napoleon.nr
  19. #   noughts.c parse.c
  20. # Wrapped by billr@saab on Thu Mar  4 09:46:52 1993
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. if test -f 'describe.c' -a "${1}" != "-c" ; then 
  23.   echo shar: Will not clobber existing file \"'describe.c'\"
  24. else
  25. echo shar: Extracting \"'describe.c'\" \(6045 characters\)
  26. sed "s/^X//" >'describe.c' <<'END_OF_FILE'
  27. X/* Copyright (C) 1992 Pete Chown.
  28. X
  29. X   Here is my latest adventure game, Napoleon (see the documentation
  30. X   if you don't know why it's called that).  Have fun... (don't cheat,
  31. X   even though you've got the source :-) ).
  32. X
  33. X   This game is free software; you can redistribute it and/or modify
  34. X   it under the terms of the GNU General Public License as published by
  35. X   the Free Software Foundation; either version 1, or (at your option)
  36. X   any later version.
  37. X
  38. X   The game is distributed in the hope that it will be useful, but
  39. X   WITHOUT ANY WARRANTY; without even the implied warranty of
  40. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  41. X   General Public License for more details.
  42. X
  43. X   The GNU General Public License is often shipped with GNU software, and
  44. X   is generally kept in a file called COPYING or LICENSE.  If you do not
  45. X   have a copy of the license, write to the Free Software Foundation,
  46. X   675 Mass Ave, Cambridge, MA 02139, USA. */
  47. X
  48. X#include "adv.h"
  49. X
  50. Xextern void resumscore(void)
  51. X{
  52. X  int i,roomsvisited = 0;
  53. X
  54. X  for(i = 0;objects [i].examine != 0;i++)
  55. X  {
  56. X    if(objects [i].objtype.visited) roomsvisited++;
  57. X  }
  58. X
  59. X  score = (+(roomsvisited * 100)) / i;
  60. X}
  61. X
  62. X/* detachfromchain() has a rather obscure function: it deletes the object
  63. X   from the list it is currently in, ready to be reattached somewhere else.
  64. X   It is included as a special function on the basis that removing an object
  65. X   from a list is very much harder than adding it.  */
  66. X
  67. Xextern void detachfromchain(int this)
  68. X{
  69. X  int parent = objects [this].parent,*whichchain = 0;
  70. X
  71. X  if(objects [parent].above == this) whichchain = & objects [parent].above;
  72. X  if(objects [parent].below == this) whichchain = & objects [parent].below;
  73. X  if(objects [parent].inside == this) whichchain = & objects [parent].inside;
  74. X  if(objects [parent].next == this) whichchain = & objects [parent].next;
  75. X
  76. X  if(whichchain == 0) fail(); /* Parent pointer goes to the wrong place */
  77. X
  78. X  *whichchain = objects [this].next;
  79. X  if(objects [this].next != 0) objects [objects [this].next].parent = parent;
  80. X}
  81. X
  82. X/* addtochain() puts an object into a specified chain.  */
  83. X
  84. Xextern void addtochain(int toadd,int parent,int *chain)
  85. X{
  86. X  objects [toadd].parent = parent;
  87. X  objects [toadd].next = *chain;
  88. X  objects [*chain].parent = toadd;
  89. X  *chain = toadd;
  90. X}
  91. X
  92. Xextern int getroom(int player)
  93. X{
  94. X  int room = player;
  95. X
  96. X  while(objects [room].objtype.room == FALSE) room = objects [room].parent;
  97. X
  98. X  return room;
  99. X}
  100. X
  101. Xextern bool ancestor(int elder,int younger)
  102. X{
  103. X  while(younger != 0)
  104. X  {
  105. X    younger = objects [younger].parent;
  106. X    if(younger == elder) return TRUE;
  107. X  }
  108. X
  109. X  return FALSE;
  110. X}
  111. X
  112. Xstatic void listchain(int this,char *start,char *end)
  113. X{
  114. X  bool reportedone = FALSE;
  115. X  int nextone = -1;
  116. X  char buffer [4096] = "";
  117. X
  118. X  while(this != 0)
  119. X  {
  120. X    if(! objects [this].objtype.virtual) {
  121. X      if(nextone != -1) {
  122. X    if(reportedone) {
  123. X      strcat(buffer,", ");
  124. X      strcat(buffer,objects [nextone].longname);
  125. X    } else {
  126. X      reportedone = TRUE;
  127. X      strcat(buffer,start);
  128. X      strcat(buffer,objects [nextone].longname);
  129. X    }
  130. X      }
  131. X      nextone = this;
  132. X    }
  133. X    this = objects [this].next;
  134. X  }
  135. X  if(nextone != -1) {
  136. X    if(reportedone) {
  137. X      strcat(buffer," and ");
  138. X      strcat(buffer,objects [nextone].longname);
  139. X      strcat(buffer,end);
  140. X    } else {
  141. X      sprintf(buffer,"%s%s%s",start,objects [nextone].longname,end);
  142. X    }
  143. X  }
  144. X  if(*buffer != 0) format("%s",buffer);
  145. X}
  146. X
  147. Xstatic char *subst(char *template,char *substitution)
  148. X{
  149. X  static char buffer [60],*name;
  150. X
  151. X  name = strchr(substitution,' ') + 1;
  152. X  if(name == (char *) 1) name = substitution;
  153. X  sprintf(buffer,template,name);
  154. X  return buffer;
  155. X}
  156. X
  157. Xstatic void recursivelist(int);
  158. X
  159. Xstatic void recursivelistchain(int this)
  160. X{
  161. X  while(this != 0)
  162. X  {
  163. X    recursivelist(this);
  164. X    this = objects [this].next;
  165. X  }
  166. X}
  167. X
  168. Xstatic void recursivelist(int this)
  169. X{
  170. X  char *longname = objects [this].longname;
  171. X
  172. X  listchain(objects [this].above,subst("On the %s, there is ",longname),".\n");
  173. X  if(! objects [this].objtype.opaque) {
  174. X    listchain(objects [this].below,subst("Under the %s, there is ",longname),".\n");
  175. X    if(objects [this].objtype.alive)
  176. X      listchain(objects [this].inside,subst("The %s is carrying ",longname),".\n");
  177. X    else listchain(objects [this].inside,subst("Inside the %s, there is ",longname),".\n");
  178. X  }
  179. X  recursivelistchain(objects [this].above);
  180. X  if(! objects [this].objtype.opaque) {
  181. X    recursivelistchain(objects [this].below);
  182. X    recursivelistchain(objects [this].inside);
  183. X  }
  184. X}
  185. X
  186. Xstatic bool luminous(int this)
  187. X{
  188. X  if(this == 0) return FALSE;
  189. X  return objects [this].objtype.luminous || luminous(objects [this].above) || luminous(objects [this].below) || luminous(objects [this].inside) || luminous(objects [this].next);
  190. X}
  191. X
  192. Xextern bool illuminated(int room)
  193. X{
  194. X  return objects [room].objtype.luminous || luminous(objects [room].inside);
  195. X}
  196. X
  197. Xextern void describe_room(int player,bool look_called)
  198. X{
  199. X  int room = getroom(player),this = objects [room].inside;
  200. X  char buffer [10] = "";
  201. X  bool verbosedescription = flags [0] == 2
  202. X    || (flags [0] == 0 && ! objects [getroom(player)].objtype.visited) || look_called;
  203. X
  204. X  if(hacker) sprintf(buffer," [%0d]",room);
  205. X  if(illuminated(room)) {
  206. X    if(verbosedescription)
  207. X      format("\n%s%s\n\n%s\n",objects [room].longname,buffer,objects [room].examine);
  208. X    else format("\n%s%s\n",objects [room].longname,buffer);
  209. X    listchain(this,"There is "," here.\n");
  210. X    recursivelistchain(this);
  211. X  } else {
  212. X    format("It's pitch dark.\n\nIn the distance, someone calls, 'Get the gia"
  213. X"nt spider woken up!'\nCloser by, someone shouts, 'Wake up you lazy slob!  Wa"
  214. X"ke up, wake up, I tell you!'\n");
  215. X  }
  216. X
  217. X  if(! objects [getroom(player)].objtype.visited) {
  218. X    objects [getroom(player)].objtype.visited = 1;
  219. X    resumscore();
  220. X  }
  221. X
  222. X  postdescription(player);
  223. X}
  224. X
  225. Xextern void inventory(int player)
  226. X{
  227. X  if(objects [player].inside == 0) {
  228. X    format("You aren't carrying anything!");
  229. X  } else {
  230. X    listchain(objects [player].inside,"You are carrying ",".\n");
  231. X    recursivelistchain(objects [player].inside);
  232. X  }
  233. X}
  234. END_OF_FILE
  235. if test 6045 -ne `wc -c <'describe.c'`; then
  236.     echo shar: \"'describe.c'\" unpacked with wrong size!
  237. fi
  238. # end of 'describe.c'
  239. fi
  240. if test -f 'difftime.c' -a "${1}" != "-c" ; then 
  241.   echo shar: Will not clobber existing file \"'difftime.c'\"
  242. else
  243. echo shar: Extracting \"'difftime.c'\" \(984 characters\)
  244. sed "s/^X//" >'difftime.c' <<'END_OF_FILE'
  245. X/* Copyright (C) 1991 Free Software Foundation, Inc.
  246. XThis file is part of the GNU C Library.
  247. X
  248. XThe GNU C Library is free software; you can redistribute it and/or
  249. Xmodify it under the terms of the GNU Library General Public License as
  250. Xpublished by the Free Software Foundation; either version 2 of the
  251. XLicense, or (at your option) any later version.
  252. X
  253. XThe GNU C Library is distributed in the hope that it will be useful,
  254. Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
  255. XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  256. XLibrary General Public License for more details.
  257. X
  258. XYou should have received a copy of the GNU Library General Public
  259. XLicense along with the GNU C Library; see the file COPYING.LIB.  If
  260. Xnot, write to the Free Software Foundation, Inc., 675 Mass Ave,
  261. XCambridge, MA 02139, USA.  */
  262. X
  263. X#include <time.h>
  264. X
  265. X
  266. X/* Return the difference between TIME1 and TIME0.  */
  267. X
  268. Xdouble difftime (time_t time1, time_t time0)
  269. X{
  270. X  return (double) (time1 - time0);
  271. X}
  272. END_OF_FILE
  273. if test 984 -ne `wc -c <'difftime.c'`; then
  274.     echo shar: \"'difftime.c'\" unpacked with wrong size!
  275. fi
  276. # end of 'difftime.c'
  277. fi
  278. if test -f 'file.c' -a "${1}" != "-c" ; then 
  279.   echo shar: Will not clobber existing file \"'file.c'\"
  280. else
  281. echo shar: Extracting \"'file.c'\" \(2518 characters\)
  282. sed "s/^X//" >'file.c' <<'END_OF_FILE'
  283. X/* Copyright (C) 1992 Pete Chown.
  284. X
  285. X   Here is my latest adventure game, Napoleon (see the documentation
  286. X   if you don't know why it's called that).  Have fun... (don't cheat,
  287. X   even though you've got the source :-) ).
  288. X
  289. X   This game is free software; you can redistribute it and/or modify
  290. X   it under the terms of the GNU General Public License as published by
  291. X   the Free Software Foundation; either version 1, or (at your option)
  292. X   any later version.
  293. X
  294. X   The game is distributed in the hope that it will be useful, but
  295. X   WITHOUT ANY WARRANTY; without even the implied warranty of
  296. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  297. X   General Public License for more details.
  298. X
  299. X   The GNU General Public License is often shipped with GNU software, and
  300. X   is generally kept in a file called COPYING or LICENSE.  If you do not
  301. X   have a copy of the license, write to the Free Software Foundation,
  302. X   675 Mass Ave, Cambridge, MA 02139, USA. */
  303. X
  304. X#include "adv.h"
  305. X
  306. Xstatic const char *filehead = "Napoleon " VERSION;
  307. Xstatic int numobjects;
  308. X
  309. Xextern void loadgame(void)
  310. X{
  311. X  FILE *infile;
  312. X  char *name,buffer [128];
  313. X
  314. X  name = getline("Filename >",LINE_NO_HISTORY);
  315. X  infile = fopen(name,"rb");
  316. X  if(infile == 0) {
  317. X    format("Sorry, can't open that file.\n");
  318. X    return;
  319. X  }
  320. X  fread(buffer,strlen(filehead),1,infile);
  321. X  if(strncmp(buffer,filehead,strlen(filehead))) {
  322. X    format("Sorry, that file is not a Napoleon saved game, or it is a Napole"
  323. X"on saved game from a different version of the program.\n");
  324. X  } else {
  325. X    fread(flags,sizeof(flags),1,infile);
  326. X    fread(objects,sizeof(object),numobjects,infile);
  327. X  }
  328. X  fclose(infile);
  329. X  resumscore();
  330. X  descr = TRUE;
  331. X}
  332. X
  333. Xextern void savegame(void)
  334. X{
  335. X  FILE *outfile;
  336. X  char *name;
  337. X
  338. X  name = getline("Filename >",LINE_NO_HISTORY);
  339. X  outfile = fopen(name,"wb");
  340. X  if(outfile == 0) {
  341. X    format("Sorry, can't open that file.\n");
  342. X    return;
  343. X  }
  344. X  fwrite(filehead,strlen(filehead),1,outfile);
  345. X  fwrite(flags,sizeof(flags),1,outfile);
  346. X  fwrite(objects,sizeof(object),numobjects,outfile);
  347. X  fclose(outfile);
  348. X}
  349. X
  350. Xextern void initialise(void)
  351. X{
  352. X  int i;
  353. X
  354. X  for(numobjects = 0;intobjects [numobjects].examine != (char *) 1;numobjects++);
  355. X  numobjects++;
  356. X
  357. X  if(objects == 0) objects = xmalloc(numobjects * sizeof(object));
  358. X
  359. X  memcpy(objects,intobjects,numobjects * sizeof(object));
  360. X
  361. X  player = -1;
  362. X  for(i = 0;;i++)
  363. X  {
  364. X    if(objects [i].objtype.player) {
  365. X      player = i;
  366. X      break;
  367. X    }
  368. X  }
  369. X  if(player == -1) fail();
  370. X
  371. X  for(i = 0;i < 128;i++) flags [i] = 0;
  372. X}
  373. END_OF_FILE
  374. if test 2518 -ne `wc -c <'file.c'`; then
  375.     echo shar: \"'file.c'\" unpacked with wrong size!
  376. fi
  377. # end of 'file.c'
  378. fi
  379. if test -f 'lex.c' -a "${1}" != "-c" ; then 
  380.   echo shar: Will not clobber existing file \"'lex.c'\"
  381. else
  382. echo shar: Extracting \"'lex.c'\" \(5562 characters\)
  383. sed "s/^X//" >'lex.c' <<'END_OF_FILE'
  384. X/* Copyright (C) 1992 Pete Chown.
  385. X
  386. X   Here is my latest adventure game, Napoleon (see the documentation
  387. X   if you don't know why it's called that).  Have fun... (don't cheat,
  388. X   even though you've got the source :-) ).
  389. X
  390. X   This game is free software; you can redistribute it and/or modify
  391. X   it under the terms of the GNU General Public License as published by
  392. X   the Free Software Foundation; either version 1, or (at your option)
  393. X   any later version.
  394. X
  395. X   The game is distributed in the hope that it will be useful, but
  396. X   WITHOUT ANY WARRANTY; without even the implied warranty of
  397. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  398. X   General Public License for more details.
  399. X
  400. X   The GNU General Public License is often shipped with GNU software, and
  401. X   is generally kept in a file called COPYING or LICENSE.  If you do not
  402. X   have a copy of the license, write to the Free Software Foundation,
  403. X   675 Mass Ave, Cambridge, MA 02139, USA. */
  404. X
  405. X#include "adv.h"
  406. X#include "lang.h"
  407. X
  408. Xstatic int identify(char *command,char *teststring)
  409. X{
  410. X  int i;
  411. X
  412. X  for(i = 1;*teststring != 0;i++)
  413. X  {
  414. X    if(strcmp_ci(command,teststring)) return i;
  415. X    teststring += strlen(teststring) + 1;
  416. X  }
  417. X  return 0;
  418. X}
  419. X
  420. X/* strcmp_ci_t is a routine to compare two strings, allowing any character
  421. X   in the third string as a terminator.  */
  422. X
  423. Xstatic bool strcmp_ci_t(char *a,char *b,char *term)
  424. X{
  425. X  while(tolower(*a) == tolower(*b) || (strchr(term,*a) && strchr(term,*b)))
  426. X  {
  427. X    if(strchr(term,*a)) return TRUE;
  428. X    a++;
  429. X    b++;
  430. X  }
  431. X  return FALSE;
  432. X}
  433. X
  434. X/* findword has the job of searching for a word and determining
  435. X   whether it is a noun or an adjective.  */
  436. X
  437. Xstatic int findword(char *word)
  438. X{
  439. X  int i;
  440. X
  441. X  for(i = 0;objects [i].examine != (char *) 1;i++)
  442. X  {
  443. X    if(objects [i].shortname != 0) {
  444. X      char *lookingat = objects [i].shortname;
  445. X
  446. X      do {
  447. X    if(strcmp_ci_t(lookingat,word,"_")) {
  448. X      if(strchr(lookingat,'_')) return ADJECTIVE;
  449. X      return NOUN;
  450. X    }
  451. X    lookingat = strchr(lookingat,'_') + 1;
  452. X      } while(lookingat != (char *) 1);
  453. X    }
  454. X  }
  455. X  return 0;
  456. X}
  457. X
  458. Xextern int yylex(void)
  459. X{
  460. X  char buffer [64];
  461. X  int word,wordtype,i;
  462. X
  463. X  while(isspace(*yaccstring)) yaccstring++;
  464. X  if(*yaccstring == 0) return 0; /* End of command line */
  465. X  if(isalpha(*yaccstring)) {
  466. X    strncpy(buffer,yaccstring,63);
  467. X    buffer [63] = 0;
  468. X    for(i = 0;isalpha(buffer [i]);i++);
  469. X    buffer [i] = 0;
  470. X    yaccstring += strlen(buffer);
  471. X    word = identify(buffer,"north\0south\0west\0east\0northwest\0northeast\0"
  472. X"southwest\0southeast\0up\0down\0");
  473. X    if(word == 0) word = identify(buffer,"n\0s\0w\0e\0nw\0ne\0sw\0se\0u\0d\0"
  474. X"inventory\0load\0look\0quit\0save\0score\0go\0examine\0all\0everything\0in\0"
  475. X"into\0on\0off\0to\0get\0drop\0take\0put\0inv\0restore\0onto\0under\0undernea"
  476. X"th\0at\0below\0the\0and\0read\0twirl\0turn\0say\0ask\0about\0yes\0no\0hello\0"
  477. X"hi\0goodbye\0bye\0hack\0play\0with\0noughts\0crosses\0give\0throw\0over\0jump"
  478. X"\0touch\0unlock\0open\0brief\0verbose\0normal\0record\0drink\0wait\0kiss\0"
  479. X"search\0climb\0");
  480. X    switch(word)
  481. X    {
  482. X    case 0:
  483. X      wordtype = findword(buffer);
  484. X      switch(wordtype)
  485. X      {
  486. X      case NOUN:
  487. X    strcpy(yylval.string,buffer);
  488. X    return NOUN;
  489. X      case ADJECTIVE:
  490. X    strcpy(yylval.string,buffer);
  491. X    return ADJECTIVE;
  492. X      case 0:
  493. X    format("I don't understand '%s'.",buffer);
  494. X    return 0;
  495. X      default:
  496. X    fail();
  497. X      }
  498. X    case 1: return NORTH;
  499. X    case 2: return SOUTH;
  500. X    case 3: return WEST;
  501. X    case 4: return EAST;
  502. X    case 5: return NORTHWEST;
  503. X    case 6: return NORTHEAST;
  504. X    case 7: return SOUTHWEST;
  505. X    case 8: return SOUTHEAST;
  506. X    case 9: return UP;
  507. X    case 10: return DOWN;
  508. X    case 11: return INVENTORY;
  509. X    case 12: return LOAD;
  510. X    case 13: return LOOK;
  511. X    case 14: return QUIT;
  512. X    case 15: return SAVE;
  513. X    case 16: return SCORE;
  514. X    case 17: return GO;
  515. X    case 18: return EXAMINE;
  516. X    case 19: return ALL;
  517. X    case 20: return EVERYTHING;
  518. X    case 21: return IN;
  519. X    case 22: return INTO;
  520. X    case 23: return ON;
  521. X    case 24: return OFF;
  522. X    case 25: return TO;
  523. X    case 26: return GET;
  524. X    case 27: return DROP;
  525. X    case 28: return TAKE;
  526. X    case 29: return PUT;
  527. X    case 30: return INV;
  528. X    case 31: return RESTORE;
  529. X    case 32: return ONTO;
  530. X    case 33: return UNDER;
  531. X    case 34: return UNDERNEATH;
  532. X    case 35: return AT;
  533. X    case 36: return BELOW;
  534. X    case 37: return THE;
  535. X    case 38: return AND;
  536. X    case 39: return READ;
  537. X    case 40: return TWIRL;
  538. X    case 41: return TURN;
  539. X    case 42: return SAY;
  540. X    case 43: return ASK;
  541. X    case 44: return ABOUT;
  542. X    case 45: return YES;
  543. X    case 46: return NO;
  544. X    case 47: return HELLO;
  545. X    case 48: return HI;
  546. X    case 49: return GOODBYE;
  547. X    case 50: return BYE;
  548. X    case 51: return HACK;
  549. X    case 52: return PLAY;
  550. X    case 53: return WITH;
  551. X    case 54: return NOUGHTS;
  552. X    case 55: return CROSSES;
  553. X    case 56: return GIVE;
  554. X    case 57: return THROW;
  555. X    case 58: return OVER;
  556. X    case 59: return JUMP;
  557. X    case 60: return TOUCH;
  558. X    case 61: return UNLOCK;
  559. X    case 62: return OPEN;
  560. X    case 63: return BRIEF;
  561. X    case 64: return VERBOSE;
  562. X    case 65: return NORMAL;
  563. X    case 66: return RECORD;
  564. X    case 67: return DRINK;
  565. X    case 68: return WAIT;
  566. X    case 69: return KISS;
  567. X    case 70: return SEARCH;
  568. X    case 71: return CLIMB;
  569. X
  570. X    default: fail();
  571. X    }
  572. X  } else {
  573. X    switch(*(yaccstring++))
  574. X    {
  575. X    case '\"': case '\'': return QUOTE;
  576. X    case '.': case '!': return FULLSTOP;
  577. X    case ',': return COMMA;
  578. X    case ';': return SEMICOLON;
  579. X    default:
  580. X      format("What do you mean '%c'?",*(yaccstring - 1));
  581. X      return 0;
  582. X    }
  583. X  }
  584. X  return 0;
  585. X}
  586. END_OF_FILE
  587. if test 5562 -ne `wc -c <'lex.c'`; then
  588.     echo shar: \"'lex.c'\" unpacked with wrong size!
  589. fi
  590. # end of 'lex.c'
  591. fi
  592. if test -f 'line.c' -a "${1}" != "-c" ; then 
  593.   echo shar: Will not clobber existing file \"'line.c'\"
  594. else
  595. echo shar: Extracting \"'line.c'\" \(5356 characters\)
  596. sed "s/^X//" >'line.c' <<'END_OF_FILE'
  597. X/* Copyright (C) 1992 Pete Chown.
  598. X
  599. X   Here is my latest adventure game, Napoleon (see the documentation
  600. X   if you don't know why it's called that).  Have fun... (don't cheat,
  601. X   even though you've got the source :-) ).
  602. X
  603. X   This game is free software; you can redistribute it and/or modify
  604. X   it under the terms of the GNU General Public License as published by
  605. X   the Free Software Foundation; either version 1, or (at your option)
  606. X   any later version.
  607. X
  608. X   The game is distributed in the hope that it will be useful, but
  609. X   WITHOUT ANY WARRANTY; without even the implied warranty of
  610. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  611. X   General Public License for more details.
  612. X
  613. X   The GNU General Public License is often shipped with GNU software, and
  614. X   is generally kept in a file called COPYING or LICENSE.  If you do not
  615. X   have a copy of the license, write to the Free Software Foundation,
  616. X   675 Mass Ave, Cambridge, MA 02139, USA. */
  617. X
  618. X#include "adv.h"
  619. X
  620. X#ifdef UNIX
  621. X
  622. X#include <termios.h>
  623. X
  624. X#ifdef HAS_UNISTD
  625. X#include <unistd.h>
  626. X#endif
  627. X
  628. X#endif
  629. X
  630. X#ifndef TIOCGWINSZ
  631. Xstatic int screenx = 80,screeny = 24;
  632. X#else
  633. Xstatic int screenx = 0,screeny = 0;
  634. X#endif
  635. Xstatic int lineswritten = 0;
  636. X
  637. Xint delay;
  638. X
  639. X#ifdef UNIX
  640. Xstatic void getscreenx(void)
  641. X{
  642. X#ifdef TIOCGWINSZ
  643. X
  644. X  struct winsize window_size;
  645. X
  646. X  ioctl(0,TIOCGWINSZ,& window_size);
  647. X  screenx = (int) window_size.ws_col;
  648. X  screeny = (int) window_size.ws_row;
  649. X
  650. X#else
  651. X
  652. X  fail();
  653. X
  654. X#endif
  655. X}
  656. X#endif
  657. X
  658. X#ifdef UNIX
  659. Xstatic void winchhandler(int signo)
  660. X{
  661. X  signo = signo;
  662. X
  663. X  getscreenx();
  664. X  signal(SIGWINCH,& winchhandler);
  665. X}
  666. X#endif
  667. X
  668. Xextern void more(void)
  669. X{
  670. X  printf("-- more; press return --");
  671. X  while(getchar() != '\n');
  672. X  lineswritten = 0;
  673. X}
  674. X
  675. Xextern void format(char *fmt,...)
  676. X{
  677. X  va_list args;
  678. X  char buf [16384],*here = buf,*linestart = buf,*lineend = buf;
  679. X  bool hardnewline = TRUE;
  680. X
  681. X#ifdef UNIX
  682. X
  683. X  if(screenx == 0) {
  684. X    getscreenx();
  685. X    signal(SIGWINCH,& winchhandler);
  686. X  }
  687. X
  688. X#endif
  689. X
  690. X  va_start(args,fmt);
  691. X  vsprintf(buf,fmt,args);
  692. X  va_end(args);
  693. X
  694. X  do {
  695. X    if(isspace(*here) || *here == 0) {
  696. X      lineend = here;
  697. X      hardnewline = *here == '\n';
  698. X    }
  699. X    if(here - linestart == screenx || *here == '\n') {
  700. X      *lineend = 0;
  701. X      printf("%s\n",linestart);
  702. X      linestart = lineend + 1;
  703. X      if(! hardnewline) while(*linestart == ' ') linestart++;
  704. X      lineswritten++;
  705. X      if(lineswritten == screeny - 1) {
  706. X    more();
  707. X      }
  708. X    }
  709. X    here++;
  710. X  } while(*here != 0);
  711. X  printf("%s\n",linestart);
  712. X}
  713. X
  714. X#ifdef PURE_ANSI
  715. X
  716. Xstatic char *readline(char *prompt)
  717. X{
  718. X  char buffer [16384],*result;
  719. X
  720. X  printf("%s",prompt);
  721. X  fgets(buffer,16384,stdin);
  722. X  buffer [strlen(buffer) - 1] = 0;
  723. X  result = malloc(strlen(buffer) + 1);
  724. X  strcpy(result,buffer);
  725. X  return result;
  726. X}
  727. X
  728. X#endif
  729. X
  730. Xextern char *getline(char *prompt,int function)
  731. X{
  732. X  static char *lineread;
  733. X  time_t starttime,endtime;
  734. X
  735. X  if(lineread != 0) free(lineread);
  736. X
  737. X  starttime = time(0);
  738. X  lineread = readline(prompt);
  739. X  endtime = time(0);
  740. X  delay = (int) difftime(endtime,starttime);
  741. X
  742. X#ifdef UNIX
  743. X
  744. X  switch(function)
  745. X  {
  746. X  case LINE_HISTORY:
  747. X    if(*lineread != 0) add_history(lineread);
  748. X    break;
  749. X  case LINE_NO_HISTORY:
  750. X    break;
  751. X  default:
  752. X    fail();
  753. X  }
  754. X
  755. X#endif
  756. X
  757. X  lineswritten = 0;
  758. X  return lineread;
  759. X}
  760. X
  761. X#ifndef HAS_XMALLOC
  762. X
  763. X/* xmalloc.c -- safe versions of malloc and realloc */
  764. X
  765. X/* Copyright (C) 1991 Free Software Foundation, Inc.
  766. X
  767. X   This file is part of GNU Readline, a library for reading lines
  768. X   of text with interactive input and history editing.
  769. X
  770. X   Readline is free software; you can redistribute it and/or modify it
  771. X   under the terms of the GNU General Public License as published by the
  772. X   Free Software Foundation; either version 1, or (at your option) any
  773. X   later version.
  774. X
  775. X   Readline is distributed in the hope that it will be useful, but
  776. X   WITHOUT ANY WARRANTY; without even the implied warranty of
  777. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  778. X   General Public License for more details.
  779. X
  780. X   You should have received a copy of the GNU General Public License
  781. X   along with Readline; see the file COPYING.  If not, write to the Free
  782. X   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  783. X
  784. X#include <stdio.h>
  785. X
  786. Xstatic void memory_error_and_abort ();
  787. X
  788. X/* **************************************************************** */
  789. X/*                                    */
  790. X/*           Memory Allocation and Deallocation.            */
  791. X/*                                    */
  792. X/* **************************************************************** */
  793. X
  794. X/* Return a pointer to free()able block of memory large enough
  795. X   to hold BYTES number of bytes.  If the memory cannot be allocated,
  796. X   print an error message and abort. */
  797. X
  798. X/* Changed these functions to return a void *, rather than a char *.
  799. X   In other words they are now more like ANSI malloc than K&R malloc.
  800. X   -- PC, 24.09.92  */
  801. X
  802. Xvoid *
  803. Xxmalloc (bytes)
  804. X     int bytes;
  805. X{
  806. X  char *temp = (char *)malloc (bytes);
  807. X
  808. X  if (!temp)
  809. X    memory_error_and_abort ("xmalloc");
  810. X  return (temp);
  811. X}
  812. X
  813. Xvoid *
  814. Xxrealloc (pointer, bytes)
  815. X     void *pointer;
  816. X     int bytes;
  817. X{
  818. X  char *temp;
  819. X
  820. X  if (!pointer)
  821. X    temp = (char *)malloc (bytes);
  822. X  else
  823. X    temp = (char *)realloc (pointer, bytes);
  824. X
  825. X  if (!temp)
  826. X    memory_error_and_abort ("xrealloc");
  827. X  return (temp);
  828. X}
  829. X
  830. Xstatic void
  831. Xmemory_error_and_abort (fname)
  832. X     char *fname;
  833. X{
  834. X  fprintf (stderr, "%s: Out of virtual memory!\n", fname);
  835. X  abort ();
  836. X}
  837. X
  838. X#endif
  839. END_OF_FILE
  840. if test 5356 -ne `wc -c <'line.c'`; then
  841.     echo shar: \"'line.c'\" unpacked with wrong size!
  842. fi
  843. # end of 'line.c'
  844. fi
  845. if test -f 'napoleon.nr' -a "${1}" != "-c" ; then 
  846.   echo shar: Will not clobber existing file \"'napoleon.nr'\"
  847. else
  848. echo shar: Extracting \"'napoleon.nr'\" \(13157 characters\)
  849. sed "s/^X//" >'napoleon.nr' <<'END_OF_FILE'
  850. X.\" -*- nroff -*-
  851. X.Dd February 28, 1993
  852. X.Dt NAPOLEON 1
  853. X.Os
  854. X.Sh NAME
  855. X.Nm napoleon
  856. X.Nd adventure game
  857. X.Sh SYNOPSIS
  858. X.Nm napoleon
  859. X.Sh DESCRIPTION
  860. X.Nm Napoleon
  861. Xis a traditional text adventure game.  On the other hand it is modern
  862. Xin the sense that it has a yacc/bison parser to allow you to type more
  863. Xcomplex commands than the traditional two words.
  864. X.Pp
  865. XYou already know what an adventure game is, I expect... so all that
  866. Xremains is to set the scene for this particular one:
  867. X.Sh INTRODUCTION
  868. XIt was an alarmingly dark night.  In Rusgreve's office, a
  869. Xsolitary candle burned, and spluttered fitfully in the
  870. Xslight breeze.  The Council of War began.  Prendergast lit a
  871. Xsmelly cigarette.
  872. X.Pp
  873. XRusgreve began to explain the problem.  'The difficulty is,'
  874. Xhe said, 'someone is going to have to go in without us
  875. Xhaving first obtained proper information.  It isn't going to
  876. Xbe me.'
  877. X.Pp
  878. XMany, many weeks previously, the investigation had begun. 
  879. XAt first, Rusgreve had claimed there was nothing to worry
  880. Xabout.  After a time, that became a bigger worry than the
  881. Xthings people might have worried about, and so he rewrote
  882. Xhistory so that in fact he had been concerned all along. 
  883. XThe delay rather hindered the efforts to gain information
  884. Xabout the people involved prior to sending in an agent.
  885. X.Pp
  886. XMany, many years previously, the so-called Napoleon gang had
  887. Xbeen normal criminals - yes, they did a bit of time here,
  888. Xand yes, there was the odd bungled attack there.  Then
  889. Xthings changed for the better (although it was worse for
  890. Xeveryone else).  The first and most important change was
  891. Xthat Rusgreve took over as director of the Criminal Re-
  892. Xeducation Bureau, responsible for placing crooks in the nick
  893. Xfor re-education.
  894. X.Pp
  895. XThe second, and less important change was that the Napoleon
  896. Xgang were joined by a fourth member.  This member was known
  897. Xas Professor R. P. P. Tinthywinkle-Croack.  Rusgreve pointed
  898. Xout early on how surprising it was that one of the Napoleon
  899. Xgang was using his real name.  Unfortunately it rapidly
  900. Xbecame obvious that this was not so.  Information was passed
  901. Xout to the Napoleons which was supposed to be top secret,
  902. Xfor your eyes only, printed on red paper.  This led to the
  903. Xuncharitable starting to believe that somewhere in the CRB,
  904. Xa leaker was at work.  An immediate Public Enquiry was set
  905. Xup, which served only to pass still more information into
  906. Xthe hands of Joe Public (who Rusgreve always suspected of
  907. Xbeing a secret Communist - others only suspected Rusgreve of
  908. Xbeing a little simple).
  909. X.Pp
  910. XOne particular piece of information which got into the hands
  911. Xof the Napoleon gang was the knowledge of how to idea-flip. 
  912. XPrendergast was originally employed to try to research this
  913. Xtopic, in order that it could be directed at miscreants, as
  914. Xpart of the re-education programme.  We asked him to explain
  915. Xit to the Council of War so that it could be quoted below:
  916. X.Pp
  917. XWhen you dream, you populate your dreams with other people. 
  918. XHowever those people don't know that they were in your dream
  919. X(unless you tell them, yes, Rusgreve).  Now if we can bring
  920. Xsufficient energy to bear on the problem, we can arrange it
  921. Xso that people's dreams come true; they don't know it, and
  922. Xneither does anyone else unless some action is taken to
  923. Xtransport people to them.  But when this happens, two people
  924. Xcan meet in a dream, and both people will remember the same
  925. Xdream when they wake up.
  926. X.Pp
  927. XNow this is not just of academic interest.  Many people saw
  928. Xa lot of potential in this system for creating everything
  929. Xfrom idyllic gardens to death traps (the use the Napoleon
  930. Xgang were eventually to find).
  931. X.Pp
  932. XWhat was not appreciated was that people's dreams were not
  933. Xbeing realised individually but instead everyone who placed
  934. Xtheir dreams at the disposal of the idea-flipping machine
  935. Xhad their dreams combined into a single very large system. 
  936. XIn the end portions of the system became quite well ordered. 
  937. XIn places this was because people deliberately dreamed in
  938. Xsuch a way as to create improved order while in others it
  939. Xwas due simply to people with efficient minds dreaming.
  940. X.Pp
  941. XThis caused the Napoleon gang a lot of problems.  The point
  942. Xwas that they wanted to create death traps to which people
  943. Xcould be whisked as soon as they fell asleep.  But the
  944. Xmajority of the dreamland was neutral or good, since wide
  945. Xpublication of the invention had been prevented;  apart from
  946. Xthe Napoleon gang, everyone who knew about the invention was
  947. Xconcerned with creating safe places for people to go.
  948. X.Pp
  949. XHowever there are nasty places.  These, however, have been
  950. Xwatered down by the proximity of good areas.  They are now
  951. Xmuch more what you make of them than unreservedly bad.  That
  952. Xis, you have to survive by your wits.
  953. X.Pp
  954. XNext Rusgreve himself gave a short briefing to the meeting,
  955. Xreading from a large pad in front of him on the table:
  956. X.Pp
  957. XNow it wouldn't be so bad if the Napoleon gang hadn't
  958. Xmanaged to steer anyone to the unpleasant areas, but they
  959. Xhave.  They created for themselves a complex of rooms with
  960. Xexits leading to all the bad places; then they entered the
  961. Xdreamland looking for someone important who could be
  962. Xkidnapped and held hostage there.  And they found someone:
  963. Xthe Princess Caroline, who was dreaming naturally and was
  964. Xunaware that she had moved from dream to semi reality.
  965. X.Pp
  966. XShe has been asleep ever since, and cannot be woken.  It has
  967. Xbeen put about that she is ill, but those people knowing
  968. Xabout the idea-flipping secret know that she is not ill.  So
  969. Xdo the Napoleon gang, who have asked for a large fee in
  970. Xreturn for releasing her.  But someone's going to have to go
  971. Xinto the dreamland to let her out.
  972. X.Pp
  973. X\|'Well volunteered,' said Rusgreve to you at about this
  974. Xpoint.
  975. X.Pp
  976. X\|'Hmmm,' said Prendergast, 'I suppose we could easily put
  977. Xsomeone into the Napoleon gang's rooms that lead to all the
  978. Xnasty bits.  It's just if they get killed, they won't come
  979. Xback, just like the Princess Caroline didn't.'
  980. X.Pp
  981. X\|'We won't get anywhere without taking a few risks,' said
  982. XRusgreve, kindly.
  983. X.Pp
  984. X\|'We don't know what unpleasant things the Napoleon gang
  985. Xmight have put there for unexpected visitors, though,' said
  986. XPrendergast.
  987. X.Pp
  988. XThe exchanges went on for quite some time.  In the end
  989. XRusgreve, as director of the Bureau, overruled all
  990. Xobjections and annouced that Something Must be Done.  You
  991. Xare on your way.
  992. X.Pp
  993. X\|'Alright then,' said Prendergast with a sigh.  'We'll be
  994. Xable to keep watch over you until you leave the Napoleons'
  995. Xplace for the various nasty bits, and make sure nothing too
  996. Xnasty happens.  But we won't be able to help you operate
  997. Xwhatever the Napoleons have put there, and we won't be able
  998. Xto help you once you get past there into the rest of the
  999. Xdreamland.'
  1000. X.Pp
  1001. X\|'And good luck,' finished Rusgreve. 'We appreciate what you
  1002. Xare doing.  We will give you the papers you need to carry
  1003. Xout this mission to the best of your ability - and remember
  1004. Xthe most important thing.  Read the scroll in the office at
  1005. Xthe centre of the Napoleons' headquarters.'
  1006. X.Sh SHEET 604
  1007. XTarget Information -- Napoleon Gang (sheet # 604)
  1008. X.Pp
  1009. XUp to date information on the Napoleons is difficult to come
  1010. Xby.  Over the last few years they have moved from being
  1011. Xreally quite ordinary criminals who we have been able to
  1012. Xhave a try at re-educating sometimes to their present form.
  1013. X.Pp
  1014. XIt is popularly believed that they 'hit the big time' as the
  1015. Xleader liked to put it, when the information on idea-
  1016. Xflipping fell into their hands, apparently leaked by someone
  1017. Xat the Bureau.  We would like to stress that this is almost
  1018. Xcertainly not the case and it is thought to be highly
  1019. Xunlikely that anyone at the Bureau could have been
  1020. Xresponsible for the sudden rise to power that the Napoleon
  1021. Xgang have experienced.
  1022. X.Pp
  1023. XThe reason we haven't got much information to place in this
  1024. Xreport is that the Napoleons have become very accustomed to
  1025. Xsecrecy.  Last year one of our operatives had to pretend to
  1026. Xbe a window-cleaner after he was seen fixing an electronic
  1027. Xdevice to their window frame.  It is believed that his cover
  1028. Xmay have been compromised by someone at the Bureau and
  1029. Xeveryone is urged to be uncommonly vigilant to prevent
  1030. Xunauthorised activities such as leaking from being carried
  1031. Xon.  The attached device subsequently only ever recorded
  1032. Xpeople berating the Bureau for inefficiency in catching
  1033. Xcriminals.
  1034. X.Pp
  1035. XThe Napoleon gang is, however, known to have three members,
  1036. Xas well as Professor R. P. P. Tinthywinkle-Croack.  Apart
  1037. Xfrom the Professor, all the members use false names, and so
  1038. Xthe accuracy of what follows cannot be guaranteed.
  1039. X.Pp
  1040. XNapoleon target # 1: Richard Entwhistle-SmytheCumbert
  1041. X.Pp
  1042. XCommonly uses the alias of Fred Smith.
  1043. X.Pp
  1044. XServed five years in jail for robbery with violence, while
  1045. Xthe Napoleons were in a less subtle phase.
  1046. X.Pp
  1047. XCommonly believed to be the leader of the outfit, RESC
  1048. Xseemed to be the first to hear of the opportunity available
  1049. Xwith the idea-flipping machine.  He approached Professor
  1050. XTinthywinkle-Croack to bring him in on the project.  The
  1051. Xmeeting was monitored, but unfortunately took place in a
  1052. Xlanguage for which a translator could not be found for
  1053. Xanother three weeks, by which time it was, of course, far
  1054. Xtoo late.
  1055. X.Pp
  1056. XIf you see RESC, take great care.  He may attack with a
  1057. Xsavagery learnt during his days as a robber.  He may try to
  1058. Xtrick you, using his undoubted verbal skill.  He may ignore
  1059. Xyou and hope you go away.  He might attempt to recruit you,
  1060. Xand we wouldn't want that, would we?
  1061. X.Pp
  1062. XRESC may be recognised in the dreamland by his tendency to
  1063. Xend up leading what ever bizarre operation someone has
  1064. X\|'dreamed' up.  One of nature's leaders, he will lead you
  1065. Xinto compromising the Bureau if you are not careful.  Be
  1066. Xwarned.  If you change sides, the whole arsenal of the
  1067. XBureau's sophisticated tools will be pointed at you.
  1068. X.Pp
  1069. XNapoleon target # 2: Charlie Zzzwocke
  1070. X.Pp
  1071. XChanged his name by Deed Poll in order that he could take
  1072. Xpart in a bank fraud.
  1073. X.Pp
  1074. XCommonly uses the alias of Uncle Z, which is not very
  1075. Xconvincing, but you believe that that is his name when he is
  1076. Xstanding over you asking whether you want to buy any
  1077. Xinsurance.
  1078. X.Pp
  1079. XA natural thug, he is available for any operation involving
  1080. Xcrimes of violence in a dark alley.  He was brought into the
  1081. Xfraud because someone realised that the person most at risk
  1082. Xwas the one with the funny name - and predictably Zzzwocke
  1083. Xgot caught.  He served three months at an open prison before
  1084. Xabsconding.
  1085. X.Pp
  1086. XWhile on the run, he took part in an attack on a bank. 
  1087. XUnfortunately the bank had folded several months previously
  1088. Xand there was now nothing in the branch except a pile of old
  1089. Xpaying-in slips.  He took these, and started to run out
  1090. Xbefore falling over the doormat and letting his gun off
  1091. Xacross the street.  RESC saw him and thought him the ideal
  1092. Xgang member - frightening to anyone not wanting insurance,
  1093. Xbut not intelligent enough to have leadership ambitions. 
  1094. XRESC removed him from under the noses of the police.
  1095. X.Pp
  1096. XOf all the gang members, Zzzwocke is the least at home in
  1097. Xdreamland.  'Namby-pamby' pursuits like dreaming are not for
  1098. Xhim, and a sudden shock will sometimes cause him to wake up.
  1099. X.Pp
  1100. XNapoleon target # 3: Brian Turner
  1101. X.Pp
  1102. X[ Note: the above name is believed to be too ordinary to be
  1103. Xcorrect.  Would anyone who would like to suggest an
  1104. Xalternative name please contact the information desk on the
  1105. Xnumber shown below. ]
  1106. X.Pp
  1107. XNot using any aliases, Brian Turner is a supremely confident
  1108. Xtalker who could sell double glazing to... well, anyone
  1109. Xreally.  He has been involved in organised crime ever since
  1110. Xhis childhood, when he 'organised' people to distract the
  1111. Xstore detective while his friends helped themselves to
  1112. Xchocolate bars.  Predictably, he got caught, and was
  1113. Xcautioned.
  1114. X.Pp
  1115. XLater he turned his attention to selling timeshare holidays. 
  1116. XThis ended when he got so good at it that he sold himself
  1117. Xone, forgetting all the bad points, like that it was still
  1118. Xjust a hole in the ground.
  1119. X.Pp
  1120. XLater he turned his attention to getting people to put
  1121. Xthousands of pounds in brown envelopes and leave them in the
  1122. Xhotel safe.  One of the people he did this to was our own
  1123. XRusgreve, and this was the reason why Rusgreve decided to go
  1124. Xinto crime prevention, in order to get his own back.  This
  1125. Xparticular misdeed therefore had repercussions for the crime
  1126. Xstatistics far beyond its own ability to increment them.
  1127. X.Pp
  1128. XFinally, he joined the Napoleons when a man who had just
  1129. Xbeen cheated turned nasty.  That man was Mr Zzzwocke.
  1130. X.Pp
  1131. XIf you have any further information to add to this dossier,
  1132. Xplease ring 4733 and ask for Peabody.
  1133. X.Pp
  1134. XIf you believe that your cover may have been compromised,
  1135. Xplease ring 8955 and ask to speak to the Editor.
  1136. X.Sh SHEET 904
  1137. XTarget Information -- Bureau Leaker (sheet # 904)
  1138. X.Pp
  1139. X(this page intentionally left blank)
  1140. X.Pp
  1141. XIf you have any further information to add to this dossier,
  1142. Xplease ring 4733 and ask for Peabody.
  1143. X.Pp
  1144. XIf you believe that your cover may have been compromised,
  1145. Xplease ring 8955 and ask to speak to the Editor.
  1146. X.Pp
  1147. X.Sh DIAGNOSTICS
  1148. XExit status is always 0.  All errors are reported interactively by the
  1149. Xprogram.
  1150. X.Sh BUGS
  1151. XSurely not?
  1152. X.Sh HISTORY
  1153. XThis is the first version.  History is just about to start... :-)
  1154. END_OF_FILE
  1155. if test 13157 -ne `wc -c <'napoleon.nr'`; then
  1156.     echo shar: \"'napoleon.nr'\" unpacked with wrong size!
  1157. fi
  1158. # end of 'napoleon.nr'
  1159. fi
  1160. if test -f 'noughts.c' -a "${1}" != "-c" ; then 
  1161.   echo shar: Will not clobber existing file \"'noughts.c'\"
  1162. else
  1163. echo shar: Extracting \"'noughts.c'\" \(4705 characters\)
  1164. sed "s/^X//" >'noughts.c' <<'END_OF_FILE'
  1165. X/* Copyright (C) 1992 Pete Chown.
  1166. X
  1167. X   Here is my latest adventure game, Napoleon (see the documentation
  1168. X   if you don't know why it's called that).  Have fun... (don't cheat,
  1169. X   even though you've got the source :-) ).
  1170. X
  1171. X   This game is free software; you can redistribute it and/or modify
  1172. X   it under the terms of the GNU General Public License as published by
  1173. X   the Free Software Foundation; either version 1, or (at your option)
  1174. X   any later version.
  1175. X
  1176. X   The game is distributed in the hope that it will be useful, but
  1177. X   WITHOUT ANY WARRANTY; without even the implied warranty of
  1178. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  1179. X   General Public License for more details.
  1180. X
  1181. X   The GNU General Public License is often shipped with GNU software, and
  1182. X   is generally kept in a file called COPYING or LICENSE.  If you do not
  1183. X   have a copy of the license, write to the Free Software Foundation,
  1184. X   675 Mass Ave, Cambridge, MA 02139, USA. */
  1185. X
  1186. X#include "adv.h"
  1187. X
  1188. Xstatic void showboard(char *board)
  1189. X{
  1190. X  printf("The board currently contains:\n\n   |   |\n %c | %c | %c\n   |   |"
  1191. X"\n---+---+---\n   |   |\n %c | %c | %c\n   |   |\n---+---+---\n   |   |\n %c"
  1192. X" | %c | %c\n   |   |\n",board [0],board [1],board [2],board [3],board [4],board [5],board [6],board [7],board [8]);
  1193. X}
  1194. X
  1195. Xstatic void playersmove(char *board,char playerch)
  1196. X{
  1197. X  char *line;
  1198. X  signed char square;
  1199. X
  1200. X  printf("\nPlease enter your move:\n");
  1201. X  for(;;)
  1202. X  {
  1203. X    line = getline(">",LINE_NO_HISTORY);
  1204. X    square = atoi(line) - 1;
  1205. X    if(square < 0 || square > 8 || ! isdigit(board [square])) format("The Gr"
  1206. X"andmaster says, 'You are not allowed to play there, my friend.'"); else break;
  1207. X  }
  1208. X  board [square] = playerch;
  1209. X}
  1210. X
  1211. X#define ROW(a,b,c) \
  1212. X  if(board [a] == 'X' && board [b] == 'X' && board [c] == 'X') return 'X';\
  1213. X  if(board [a] == 'O' && board [b] == 'O' && board [c] == 'O') return 'O'
  1214. X
  1215. Xstatic int whowon(char *board)
  1216. X{
  1217. X  ROW(0,1,2);
  1218. X  ROW(3,4,5);
  1219. X  ROW(6,7,8);
  1220. X  ROW(0,3,6);
  1221. X  ROW(1,4,7);
  1222. X  ROW(2,5,8);
  1223. X  ROW(0,4,8);
  1224. X  ROW(2,4,6);
  1225. X
  1226. X  return 0;
  1227. X}
  1228. X
  1229. Xstatic int movecomputer(char *board,char compch,int nummoves,bool undomove)
  1230. X{
  1231. X  char goodmoves [9],numgoodmoves = 0,otherch = compch == 'X' ? 'O' : 'X',winner,i;
  1232. X  signed char score = 2;
  1233. X
  1234. X  if(nummoves == 0) {
  1235. X    board [rnd(9)] = compch;
  1236. X    return 0;
  1237. X  }
  1238. X
  1239. X  winner = whowon(board);
  1240. X  if(winner == compch) return 1;
  1241. X  if(winner == otherch) return -1;
  1242. X  if(nummoves == 9) return 0;
  1243. X
  1244. X  for(i = 0;i < 9;i++)
  1245. X  {
  1246. X    if(isdigit(board [i])) {
  1247. X      signed char thisposition;
  1248. X
  1249. X      board [i] = compch;
  1250. X      thisposition = movecomputer(board,otherch,nummoves + 1,TRUE);
  1251. X      board [i] = i + '1';
  1252. X
  1253. X      if(thisposition < score) {
  1254. X        score = thisposition;
  1255. X    numgoodmoves = 0;
  1256. X      }
  1257. X      if(thisposition == score) {
  1258. X    goodmoves [(int) numgoodmoves++] = i;
  1259. X      }
  1260. X    }
  1261. X  }
  1262. X
  1263. X  if(numgoodmoves == 0 || score == 2) fail();
  1264. X  if(! undomove) board [goodmoves [rnd(numgoodmoves)]] = compch;
  1265. X
  1266. X  return -score;
  1267. X}
  1268. X
  1269. Xstatic int doagame(bool playerstarts)
  1270. X{
  1271. X  char board [] = "123456789",nummoves = 0,winner,playerch,compch;
  1272. X  bool playergo = playerstarts;
  1273. X
  1274. X  if(playerstarts) {
  1275. X    playerch = 'X';
  1276. X    compch = 'O';
  1277. X  } else {
  1278. X    playerch = 'O';
  1279. X    compch = 'X';
  1280. X  }
  1281. X
  1282. X  while(whowon(board) == 0 && nummoves < 9)
  1283. X  {
  1284. X    showboard(board);
  1285. X    if(playergo) playersmove(board,playerch); else {
  1286. X      format("The Grandmaster ponders for a while, and then makes his move:\n");
  1287. X      more();
  1288. X      movecomputer(board,compch,nummoves,FALSE);
  1289. X    }
  1290. X    playergo = ! playergo;
  1291. X    nummoves++;
  1292. X  }
  1293. X
  1294. X  winner = whowon(board);
  1295. X  if(winner == 'X' && playerstarts) return 1;
  1296. X  if(winner == 'O' && playerstarts) return 0;
  1297. X  if(winner == 'X') return 0;
  1298. X  if(winner == 'O') return 1;
  1299. X  return 2;
  1300. X}
  1301. X
  1302. X/* playnoughts() returns 0 for a drawn match (the computer should never lose, at least), 1 for a
  1303. X   match the player just lost, and 2 for a match the player lost by a big margin.  */
  1304. X
  1305. Xextern int playnoughts(void)
  1306. X{
  1307. X  int computer = 0,player = 0,drawn = 0;
  1308. X  bool playerstarts = TRUE;
  1309. X
  1310. X  while(computer + player + drawn < 3)
  1311. X  {
  1312. X    switch(doagame(playerstarts))
  1313. X    {
  1314. X    case 0:
  1315. X      format("The Grandmaster says, 'Noughts and Crosses is a fine game, do "
  1316. X"you not agree?'");
  1317. X      computer++;
  1318. X      break;
  1319. X    case 1:
  1320. X      format("The Grandmaster looks a little bit crestfallen, and wipes out "
  1321. X"the board ready for his next game.");
  1322. X      player++;
  1323. X      break;
  1324. X    case 2:
  1325. X      format("The Grandmaster says, 'Would you believe, some people think th"
  1326. X"at it is always possible to force a draw at noughts and crosses?'");
  1327. X      drawn++;
  1328. X      break;
  1329. X    }
  1330. X    playerstarts = ! playerstarts;
  1331. X  }
  1332. X
  1333. X  if(drawn == 2 && computer == 1) return 1;
  1334. X  if(computer <= player) return 0;
  1335. X  return 2;
  1336. X}
  1337. END_OF_FILE
  1338. if test 4705 -ne `wc -c <'noughts.c'`; then
  1339.     echo shar: \"'noughts.c'\" unpacked with wrong size!
  1340. fi
  1341. # end of 'noughts.c'
  1342. fi
  1343. if test -f 'parse.c' -a "${1}" != "-c" ; then 
  1344.   echo shar: Will not clobber existing file \"'parse.c'\"
  1345. else
  1346. echo shar: Extracting \"'parse.c'\" \(11926 characters\)
  1347. sed "s/^X//" >'parse.c' <<'END_OF_FILE'
  1348. X/* Copyright (C) 1992 Pete Chown.
  1349. X
  1350. X   Here is my latest adventure game, Napoleon (see the documentation
  1351. X   if you don't know why it's called that).  Have fun... (don't cheat,
  1352. X   even though you've got the source :-) ).
  1353. X
  1354. X   This game is free software; you can redistribute it and/or modify
  1355. X   it under the terms of the GNU General Public License as published by
  1356. X   the Free Software Foundation; either version 1, or (at your option)
  1357. X   any later version.
  1358. X
  1359. X   The game is distributed in the hope that it will be useful, but
  1360. X   WITHOUT ANY WARRANTY; without even the implied warranty of
  1361. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  1362. X   General Public License for more details.
  1363. X
  1364. X   The GNU General Public License is often shipped with GNU software, and
  1365. X   is generally kept in a file called COPYING or LICENSE.  If you do not
  1366. X   have a copy of the license, write to the Free Software Foundation,
  1367. X   675 Mass Ave, Cambridge, MA 02139, USA. */
  1368. X
  1369. X#include "adv.h"
  1370. X#include "lang.h"
  1371. X
  1372. Xint listedobjects,objectlist [200],said,subject;
  1373. Xbool all,speechflag;
  1374. Xchar *yaccstring;
  1375. Xint direction,yaccplayer;
  1376. X
  1377. Xstatic char adjectives [4] [20];
  1378. Xstatic int numadjectives;
  1379. X
  1380. Xstatic int getnpc(int what)
  1381. X{
  1382. X  int oldwhat;
  1383. X
  1384. X  do {
  1385. X    oldwhat = what;
  1386. X    what = objects [what].parent;
  1387. X  } while((! objects [what].objtype.alive || objects [what].next == oldwhat
  1388. X       || objects [what].objtype.player)
  1389. X    && ! objects [what].objtype.room);
  1390. X  if(objects [what].objtype.alive) return what;
  1391. X  return 0;
  1392. X}
  1393. X
  1394. Xstatic bool heldbynpc(int what)
  1395. X{
  1396. X  return getnpc(what) != 0;
  1397. X}
  1398. X
  1399. Xextern void moveplayer(void)
  1400. X{
  1401. X  int playerroom = getroom(yaccplayer),dest;
  1402. X  bool failquietly = FALSE;
  1403. X
  1404. X  switch(direction)
  1405. X  {
  1406. X  case NORTH:
  1407. X    dest = objects [playerroom].n;
  1408. X    break;
  1409. X  case SOUTH:
  1410. X    dest = objects [playerroom].s;
  1411. X    break;
  1412. X  case WEST:
  1413. X    dest = objects [playerroom].w;
  1414. X    break;
  1415. X  case EAST:
  1416. X    dest = objects [playerroom].e;
  1417. X    break;
  1418. X  case NORTHWEST:
  1419. X    dest = objects [playerroom].nw;
  1420. X    break;
  1421. X  case NORTHEAST:
  1422. X    dest = objects [playerroom].ne;
  1423. X    break;
  1424. X  case SOUTHWEST:
  1425. X    dest = objects [playerroom].sw;
  1426. X    break;
  1427. X  case SOUTHEAST:
  1428. X    dest = objects [playerroom].se;
  1429. X    break;
  1430. X  case UP:
  1431. X    dest = objects [playerroom].u;
  1432. X    break;
  1433. X  case DOWN:
  1434. X    dest = objects [playerroom].d;
  1435. X    break;
  1436. X  default:
  1437. X    fail();
  1438. X  }
  1439. X  if(dest != 0) failquietly = TRUE;
  1440. X  dest = premove(yaccplayer,dest);
  1441. X  if(dest == 0) {
  1442. X    if(! failquietly) format("You don't seem to be able to get through that "
  1443. X"way.");
  1444. X  } else {
  1445. X    if(! illuminated(getroom(yaccplayer)) && ! illuminated(dest)) {
  1446. X      format("\nYou got eaten by the giant spider in the dark.  Sorry.\n");
  1447. X      dead = TRUE;
  1448. X    } else {
  1449. X      detachfromchain(yaccplayer);
  1450. X      objects [yaccplayer].next = objects [dest].inside;
  1451. X      objects [yaccplayer].parent = dest;
  1452. X      if(objects [dest].inside != 0) objects [objects [dest].inside].parent = yaccplayer;
  1453. X      objects [dest].inside = yaccplayer;
  1454. X      descr = TRUE;
  1455. X    }
  1456. X  }
  1457. X  postmove();
  1458. X}
  1459. X
  1460. Xextern bool strcmp_ci(char *a,char *b)
  1461. X{
  1462. X  while(tolower(*a) == tolower(*b))
  1463. X  {
  1464. X    if(*a == 0) return TRUE;
  1465. X    a++;
  1466. X    b++;
  1467. X  }
  1468. X  return FALSE;
  1469. X}
  1470. X
  1471. Xextern int rnd(int range)
  1472. X{
  1473. X  return ((rand() & 0xffff) * range) >> 16;
  1474. X}
  1475. X
  1476. Xextern void yyerror(char *s)
  1477. X{
  1478. X  switch(rnd(3))
  1479. X  {
  1480. X  case 0:
  1481. X    format("Eh?");
  1482. X    break;
  1483. X  case 1:
  1484. X    format("You're mumbling again.");
  1485. X    break;
  1486. X  case 2:
  1487. X    format("Come again?");
  1488. X    break;
  1489. X  }
  1490. X}
  1491. X
  1492. Xextern void command(int player,char *string)
  1493. X{
  1494. X  static char *oldline;
  1495. X
  1496. X  if(oldline != 0) free(oldline);
  1497. X  yaccstring = oldline = xmalloc(strlen(string) + 1);
  1498. X  strcpy(yaccstring,string);
  1499. X  yaccplayer = player;
  1500. X  listedobjects = 0;
  1501. X  numadjectives = 0;
  1502. X  speechflag = FALSE;
  1503. X  all = FALSE;
  1504. X  yyparse();
  1505. X}
  1506. X
  1507. Xextern void addadjective(char *adj)
  1508. X{
  1509. X  if(numadjectives != 4) strcpy(adjectives [numadjectives++],adj);
  1510. X}
  1511. X
  1512. Xextern void addobject(int objectno)
  1513. X{
  1514. X  if(objectno != -1) {
  1515. X    if(ispresent(objectno,yaccplayer)) objectlist [listedobjects++] = objectno;
  1516. X    else format("I can't see %s anywhere near here.",quickname("the",objectno));
  1517. X  }
  1518. X  else format("I don't know anything like that (1)!");
  1519. X  numadjectives = 0;
  1520. X}
  1521. X
  1522. Xstatic void addchain(int this)
  1523. X{
  1524. X  while(this != 0)
  1525. X  {
  1526. X    objectlist [listedobjects++] = this;
  1527. X    this = objects [this].next;
  1528. X  }
  1529. X}
  1530. X
  1531. Xextern void addfirstdescendants(int parent)
  1532. X{
  1533. X  addchain(objects [parent].above);
  1534. X  addchain(objects [parent].below);
  1535. X  addchain(objects [parent].inside);
  1536. X}
  1537. X
  1538. Xstatic bool checkadjectives(char *name)
  1539. X{
  1540. X  int i;
  1541. X  char buffer [20];
  1542. X
  1543. X  for(i = 0;i < numadjectives;i++)
  1544. X  {
  1545. X    sprintf(buffer,"_%s_",adjectives [i]);
  1546. X    if(! strstr(name,buffer) && strncmp(name,buffer + 1,strlen(buffer + 1))) return FALSE;
  1547. X  }
  1548. X
  1549. X  return TRUE;
  1550. X}
  1551. X
  1552. Xextern int getobject(char *noun)
  1553. X{
  1554. X  int i,result = -1;
  1555. X  char *objectname = noun,*a = "a",*extras = "";
  1556. X  bool goodmatch = FALSE;
  1557. X
  1558. X  while(strchr(objectname,' ')) objectname = strchr(objectname,' ') + 1;
  1559. X  for(i = 0;objectname [i] != 0;i++) objectname [i] = tolower(objectname [i]);
  1560. X
  1561. X  for(i = 0;objects [i].examine != (char *) 1;i++)
  1562. X  {
  1563. X    if(objects [i].shortname != 0) {
  1564. X      if(strlen(objects [i].shortname) >= strlen(noun)) {
  1565. X    if(strcmp_ci(objects [i].shortname + strlen(objects [i].shortname) - strlen(noun),noun)) {
  1566. X      if(checkadjectives(objects [i].shortname)) {
  1567. X        goodmatch = TRUE;
  1568. X        extras = "";
  1569. X        if(ispresent(i,yaccplayer) || speechflag) {
  1570. X          if(heldbynpc(i) && ! speechflag) {
  1571. X        format("%s won't let you do anything with that.",quickname("The",getnpc(i)));
  1572. X        return -1;
  1573. X          } else result = i;
  1574. X        } else {
  1575. X          objectname = quickname("",i);
  1576. X        }
  1577. X      } else {
  1578. X        if(! goodmatch) extras = " like that";
  1579. X      }
  1580. X    }
  1581. X      }
  1582. X    }
  1583. X  }
  1584. X  if(result == -1) {
  1585. X    if(strchr("aeiou",tolower(objectname [0]))) a = "an";
  1586. X    format("I can't see %s %s%s here.",a,objectname,extras);
  1587. X  }
  1588. X  numadjectives = 0;
  1589. X  return result;
  1590. X}
  1591. X
  1592. Xextern char *quickname(char *newword,int i)
  1593. X{
  1594. X  static char buffer [32];
  1595. X  char *a = strchr(objects [i].longname,' ');
  1596. X
  1597. X  if(a == 0) return objects [i].longname;
  1598. X  else sprintf(buffer,"%s %s",newword,a + 1);
  1599. X
  1600. X  return *newword == 0 ? buffer + 1 : buffer;
  1601. X}
  1602. X
  1603. Xextern bool ispresent(int this,int player)
  1604. X{
  1605. X  return getroom(this) == getroom(player);
  1606. X}
  1607. X
  1608. Xextern void examine(void)
  1609. X{
  1610. X  int i;
  1611. X
  1612. X  for(i = 0;i < listedobjects;i++)
  1613. X  {
  1614. X    format("%s\n",objects [objectlist [i]].examine);
  1615. X  }
  1616. X  listedobjects = 0;
  1617. X}
  1618. X
  1619. Xextern void do_read(void)
  1620. X{
  1621. X  int i;
  1622. X
  1623. X  for(i = 0;i < listedobjects;i++)
  1624. X  {
  1625. X    switch(objectlist [i])
  1626. X    {
  1627. X    case 102: /* scroll */ case 123: /* card */
  1628. X      format("%s\n",objects [objectlist [i]].examine);
  1629. X      break;
  1630. X    default:
  1631. X      format("You can't read that!");
  1632. X      break;
  1633. X    }
  1634. X  }
  1635. X  listedobjects = 0;
  1636. X}
  1637. X
  1638. Xextern void get(void)
  1639. X{
  1640. X  int i;
  1641. X  bool gotsomething = FALSE;
  1642. X
  1643. X  if(all) addfirstdescendants(getroom(yaccplayer));
  1644. X  for(i = 0;i < listedobjects;i++)
  1645. X  {
  1646. X    if(objects [objectlist [i]].objtype.virtual == FALSE) {
  1647. X      detachfromchain(objectlist [i]);
  1648. X      addtochain(objectlist [i],yaccplayer,& objects [yaccplayer].inside);
  1649. X      gotsomething = TRUE;
  1650. X      format("You take %s.",quickname("the",objectlist [i]));
  1651. X    } else {
  1652. X      if(! objects [objectlist [i]].objtype.player)
  1653. X    format("You can't take %s!",quickname("the",objectlist [i]));
  1654. X    }
  1655. X  }
  1656. X  listedobjects = 0;
  1657. X  if(all && ! gotsomething) format("There is nothing here that you can reall"
  1658. X"y take!");
  1659. X}
  1660. X
  1661. Xextern void drop(void)
  1662. X{
  1663. X  int i;
  1664. X  bool gotsomething = FALSE;
  1665. X
  1666. X  if(all) addfirstdescendants(yaccplayer);
  1667. X  for(i = 0;i < listedobjects;i++)
  1668. X  {
  1669. X    if(ancestor(yaccplayer,objectlist [i])) {
  1670. X      detachfromchain(objectlist [i]);
  1671. X      addtochain(objectlist [i],getroom(yaccplayer),& objects [getroom(yaccplayer)].inside);
  1672. X      gotsomething = TRUE;
  1673. X      format("You drop %s.",quickname("the",objectlist [i]));
  1674. X    } else {
  1675. X      if(! all) format("You are not carrying %s!",quickname("the",objectlist [i]));
  1676. X    }
  1677. X  }
  1678. X  if(all && ! gotsomething) format("You are not carrying anything!");
  1679. X  listedobjects = 0;
  1680. X}
  1681. X
  1682. Xextern void put(int destination,int *chain)
  1683. X{
  1684. X  int i;
  1685. X  bool gotsomething = FALSE;
  1686. X
  1687. X  if(!objects [destination].objtype.container && chain == & objects [destination].inside) {
  1688. X    format("You won't be able to put things in that very easily!\n");
  1689. X    return;
  1690. X  }
  1691. X
  1692. X  if(all) addfirstdescendants(yaccplayer);
  1693. X  for(i = 0;i < listedobjects;i++)
  1694. X  {
  1695. X    if(! objects [objectlist [i]].objtype.virtual) {
  1696. X      detachfromchain(objectlist [i]);
  1697. X      addtochain(objectlist [i],destination,chain);
  1698. X      gotsomething = TRUE;
  1699. X      format("You put %s in position.",quickname("the",objectlist [i]));
  1700. X      justput(objectlist [i],destination,chain);
  1701. X    } else {
  1702. X      if(! all) format("You can't move %s!",quickname("the",objectlist [i]));
  1703. X    }
  1704. X  }
  1705. X  if(all && ! gotsomething) format("You are not carrying anything!");
  1706. X  listedobjects = 0;
  1707. X}
  1708. X
  1709. Xextern void give(int destination)
  1710. X{
  1711. X  int i;
  1712. X  bool gotsomething = FALSE;
  1713. X
  1714. X  if(all) addfirstdescendants(yaccplayer);
  1715. X  for(i = 0;i < listedobjects;i++)
  1716. X  {
  1717. X    if(ispresent(yaccplayer,objectlist [i])) {
  1718. X      if(wantsit(destination,objectlist [i])) gotsomething = TRUE;
  1719. X    } else {
  1720. X      if(! all) format("You are not carrying %s!",quickname("the",objectlist [i]));
  1721. X    }
  1722. X  }
  1723. X  if(all && ! gotsomething) format("You are not carrying anything!");
  1724. X  listedobjects = 0;
  1725. X}
  1726. X
  1727. Xextern int getbeastie()
  1728. X{
  1729. X  int posn = objects [getroom(yaccplayer)].inside;
  1730. X
  1731. X  while(posn != 0 && (! objects [posn].objtype.alive || objects [posn].objtype.player))
  1732. X    posn = objects [posn].next;
  1733. X  return posn;
  1734. X}
  1735. X
  1736. Xextern void speech(int recipient,int type)
  1737. X{
  1738. X  if(! ispresent(recipient,player)) {
  1739. X    format("You can't see anything like that near here!");
  1740. X    return;
  1741. X  }
  1742. X
  1743. X  if(! objects [recipient].objtype.alive) {
  1744. X    format("Strangely enough, %s takes no notice of you!",quickname("the",recipient));
  1745. X    return;
  1746. X  }
  1747. X
  1748. X  if(type == 0 && said == 1) {
  1749. X    type = 1;
  1750. X    objectlist [0] = subject;
  1751. X    listedobjects = 1;
  1752. X  }
  1753. X
  1754. X  if(type == 0) {
  1755. X    switch(said)
  1756. X    {
  1757. X    case 0:
  1758. X      if(! dogreeting(recipient)) format("%s says, 'Hello!'",quickname("The",recipient));
  1759. X      break;
  1760. X    case 2:
  1761. X      doyes(recipient);
  1762. X      break;
  1763. X    case 3:
  1764. X      dono(recipient);
  1765. X      break;
  1766. X    case 4:
  1767. X      if(! dofarewell(recipient)) format("%s says, 'Goodbye!'",quickname("Th"
  1768. X"e",recipient));
  1769. X      break;
  1770. X    case 5:
  1771. X      if(! referred_to(recipient)) format("%s says, 'You what?!'",quickname("The",recipient));
  1772. X      break;
  1773. X    default:
  1774. X      fail();
  1775. X    }
  1776. X  } else {
  1777. X    int i;
  1778. X    bool gotsomething = FALSE;
  1779. X
  1780. X    if(all) addfirstdescendants(getroom(recipient));
  1781. X    for(i = 0;i < listedobjects;i++)
  1782. X    {
  1783. X      if(ancestor(getroom(recipient),objectlist [i])) {
  1784. X    examineobject(recipient,objectlist [i]);
  1785. X      } else {
  1786. X    if(! all) format("%s says 'What ever's that?'",quickname("The",recipient));
  1787. X      }
  1788. X    }
  1789. X    if(all && ! gotsomething) format("%s says 'I can't see anything!'",quickname("The",recipient));
  1790. X    listedobjects = 0;
  1791. X  }
  1792. X}
  1793. X
  1794. Xextern void hack(void)
  1795. X{
  1796. X  char *password = "";
  1797. X
  1798. X  format("So you want to hack the game, for debugging of course... now enter"
  1799. X" the password:\n");
  1800. X  if(! hacker) password = getline(">",LINE_NO_HISTORY);
  1801. X  if(strcmp_ci(password,"tarnisher") || hacker) {
  1802. X    int dest;
  1803. X
  1804. X    format("Which room do you want?\n");
  1805. X    dest = atoi(getline(">",LINE_NO_HISTORY));
  1806. X    detachfromchain(yaccplayer);
  1807. X    objects [yaccplayer].next = objects [dest].inside;
  1808. X    objects [yaccplayer].parent = dest;
  1809. X    if(objects [dest].inside != 0) objects [objects [dest].inside].parent = yaccplayer;
  1810. X    objects [dest].inside = yaccplayer;
  1811. X    descr = TRUE; 
  1812. X    hacker = TRUE;
  1813. X  } else format("Wrong password");
  1814. X}
  1815. X
  1816. Xextern void destroy(int what)
  1817. X{
  1818. X  detachfromchain(what);
  1819. X  /* Now make the object hang off the storage room.  It is not a good idea to make it hang off the
  1820. X     root, because then we can't go and look at anything (looking in the root object doesn't
  1821. X     work).  */
  1822. X  addtochain(what,59,& objects [59].inside);
  1823. X}
  1824. END_OF_FILE
  1825. if test 11926 -ne `wc -c <'parse.c'`; then
  1826.     echo shar: \"'parse.c'\" unpacked with wrong size!
  1827. fi
  1828. # end of 'parse.c'
  1829. fi
  1830. echo shar: End of archive 3 \(of 4\).
  1831. cp /dev/null ark3isdone
  1832. MISSING=""
  1833. for I in 1 2 3 4 ; do
  1834.     if test ! -f ark${I}isdone ; then
  1835.     MISSING="${MISSING} ${I}"
  1836.     fi
  1837. done
  1838. if test "${MISSING}" = "" ; then
  1839.     echo You have unpacked all 4 archives.
  1840.     rm -f ark[1-9]isdone
  1841. else
  1842.     echo You still need to unpack the following archives:
  1843.     echo "        " ${MISSING}
  1844. fi
  1845. ##  End of shell archive.
  1846. exit 0
  1847.