Added oldstyle option.

This commit is contained in:
Eric S. Raymond 2017-05-23 11:28:56 -04:00
parent f89f63c6d1
commit 935d8b8e68
6 changed files with 18 additions and 2 deletions

3
NEWS
View file

@ -2,3 +2,6 @@
Repository head::
Forward port of Crowther & Woods's 430-point Adventure 2.5.
Added -l option for logging.
Added command prompt; -o suppresses this.

View file

@ -28,6 +28,8 @@ on which it originally ran limited filenames to 6 characters.
-l:: Log commands to specified file.
-o:: Old-style. Restores original interface, no prompt.
== ENVIRONMENT VARIABLES ==
ADVENTURE::
Path to the text database file describing Colossal Cave.

3
init.c
View file

@ -173,7 +173,8 @@ static int finish_init(void);
static void quick_io(void);
void initialise(void) {
printf("Initialising...\n");
if (oldstyle)
printf("Initialising...\n");
if(!quick_init()){raw_init(); report(); quick_save();}
finish_init();
}

6
main.c
View file

@ -41,6 +41,7 @@ long ABBNUM, ACTSPK[36], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BO
VOLCAN, VRBSIZ = 35, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X,
WZDARK = false, ZZWORD;
FILE *logfp;
bool oldstyle = false;
extern void initialise();
extern void score(long);
@ -63,7 +64,7 @@ int main(int argc, char *argv[]) {
/* Options. */
while ((ch = getopt(argc, argv, "l:")) != EOF) {
while ((ch = getopt(argc, argv, "l:o")) != EOF) {
switch (ch) {
case 'l':
logfp = fopen(optarg, "w+");
@ -72,6 +73,9 @@ int main(int argc, char *argv[]) {
"advent: can't open logfile %s for write\n",
optarg);
break;
case 'o':
oldstyle = true;
break;
}
}

3
main.h
View file

@ -1,3 +1,5 @@
#include <stdbool.h>
#define LINESIZE 100
extern long ABB[], ATAB[], ATLOC[], BLKLIN, DFLAG, DLOC[], FIXED[], HOLDNG,
@ -5,3 +7,4 @@ extern long ABB[], ATAB[], ATLOC[], BLKLIN, DFLAG, DLOC[], FIXED[], HOLDNG,
PARMS[], PLACE[], PTEXT[], RTEXT[], TABSIZ;
extern signed char INLINE[LINESIZE+1], MAP1[], MAP2[];
extern FILE *logfp;
extern bool oldstyle;

3
misc.c
View file

@ -1,3 +1,4 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include "main.h"
@ -884,6 +885,8 @@ long I, VAL;
if(MAP2[1] == 0)MPINIT();
if (!oldstyle && isatty(0))
fputs("> ", stdout);
IGNORE(fgets(INLINE+1,sizeof(INLINE)-1,OPENED));
if (feof(OPENED)) {
if (logfp)