this game builds as 'advent', reflecting the fact that the PDP-10
on which it originally ran limited filenames to 6 characters.
+== OPTIONS ==
+
+-l:: Log commands to specified file.
+
== ENVIRONMENT VARIABLES ==
ADVENTURE::
Path to the text database file describing Colossal Cave.
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
+#include <getopt.h>
#include "main.h"
#include "misc.h"
TRVSIZ = 885, TTEXT[6], TURNS, URN, V1, V2, VASE, VEND, VERB,
VOLCAN, VRBSIZ = 35, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X,
WZDARK = false, ZZWORD;
+FILE *logfp;
extern void initialise();
extern void score(long);
*/
int main(int argc, char *argv[]) {
+ int ch;
/* Adventure (rev 2: 20 treasures) */
* Errata fixed: 78/12/25 */
+/* Options. */
+
+ while ((ch = getopt(argc, argv, "l:")) != EOF) {
+ switch (ch) {
+ case 'l':
+ logfp = fopen(optarg, "w+");
+ if (logfp == NULL)
+ fprintf(stderr,
+ "advent: can't open logfile %s for write\n",
+ optarg);
+ break;
+ }
+ }
+
/* Logical variables:
*
* CLOSED says whether we're all the way closed
RSPEAK(201);
exit(0);
-
-
/* Start-up, dwarf stuff */
L1: SETUP= -1;
KTAB[], *LINES, LINK[], LNLENG, LNPOSN,
PARMS[], PLACE[], PTEXT[], RTEXT[], TABSIZ;
extern signed char INLINE[LINESIZE+1], MAP1[], MAP2[];
+extern FILE *logfp;
if(MAP2[1] == 0)MPINIT();
IGNORE(fgets(INLINE+1,sizeof(INLINE)-1,OPENED));
- if (!feof(OPENED)) {
+ if (feof(OPENED)) {
+ if (logfp)
+ fclose(logfp);
+ } else {
+ if (logfp)
+ IGNORE(fputs(INLINE+1, logfp));
LNLENG=0;
for (I=1; I<=sizeof(INLINE) && INLINE[I]!=0; I++) {
VAL=INLINE[I]+1;