From 935d8b8e68c90ca5fed1c66cc13ee427af2ca0f7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 23 May 2017 11:28:56 -0400 Subject: [PATCH] Added oldstyle option. --- NEWS | 3 +++ advent.txt | 2 ++ init.c | 3 ++- main.c | 6 +++++- main.h | 3 +++ misc.c | 3 +++ 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 5688644..f1503ba 100644 --- a/NEWS +++ b/NEWS @@ -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. + diff --git a/advent.txt b/advent.txt index 9b955aa..e4db51c 100644 --- a/advent.txt +++ b/advent.txt @@ -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. diff --git a/init.c b/init.c index b821a88..a74dd86 100644 --- a/init.c +++ b/init.c @@ -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(); } diff --git a/main.c b/main.c index c95025a..6841cee 100644 --- a/main.c +++ b/main.c @@ -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; } } diff --git a/main.h b/main.h index 7a1d1c8..fa87d62 100644 --- a/main.h +++ b/main.h @@ -1,3 +1,5 @@ +#include + #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; diff --git a/misc.c b/misc.c index b86c5c5..b1f3f83 100644 --- a/misc.c +++ b/misc.c @@ -1,3 +1,4 @@ +#include #include #include #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) -- 2.31.1