summaryrefslogtreecommitdiff
path: root/games/adventure
diff options
context:
space:
mode:
Diffstat (limited to 'games/adventure')
-rw-r--r--games/adventure/hdr.h3
-rw-r--r--games/adventure/io.c21
-rw-r--r--games/adventure/wizard.c2
3 files changed, 21 insertions, 5 deletions
diff --git a/games/adventure/hdr.h b/games/adventure/hdr.h
index e56a8ee3bec..0143e561e0f 100644
--- a/games/adventure/hdr.h
+++ b/games/adventure/hdr.h
@@ -55,6 +55,7 @@
/* hdr.h: included by c advent files */
#include <sys/types.h>
+#include <stdio.h>
int datfd; /* message file descriptor */
int delhit;
@@ -63,7 +64,7 @@ extern char data_file[]; /* Virtual data file */
#define TAB 011
#define LF 012
-#define FLUSHLINE while (getchar()!='\n')
+#define FLUSHLINE do { int c; while ((c = getchar()) != EOF && c != '\n'); } while (0)
#define FLUSHLF while (next()!=LF)
int loc,newloc,oldloc,oldlc2,wzdark,gaveup,kq,k,k2;
diff --git a/games/adventure/io.c b/games/adventure/io.c
index 86f0c850820..fb7686ffacc 100644
--- a/games/adventure/io.c
+++ b/games/adventure/io.c
@@ -83,6 +83,9 @@ char **wrd1,**wrd2; /* no prompt, usually */
*s=0;
return;
}
+ case EOF:
+ printf("user closed input stream, quitting...\n");
+ exit(0);
default:
if (++numch>=MAXSTR) /* string too long */
{ printf("Give me a break!!\n");
@@ -99,10 +102,14 @@ char **wrd1,**wrd2; /* no prompt, usually */
confirm(mesg) /* confirm irreversible action */
char *mesg;
{ register int result;
+ register int c;
printf("%s",mesg); /* tell him what he did */
- if (getchar()=='y') /* was his first letter a 'y'? */
+ if ((c = getchar())=='y') /* was his first letter a 'y'? */
result=1;
- else result=0;
+ else if (c == EOF) {
+ printf("user closed input stream, quitting...\n");
+ exit(0);
+ } else result=0;
FLUSHLINE;
return(result);
}
@@ -110,12 +117,16 @@ char *mesg;
yes(x,y,z) /* confirm with rspeak */
int x,y,z;
{ register int result;
- register char ch;
+ register int ch;
for (;;)
{ rspeak(x); /* tell him what we want*/
if ((ch=getchar())=='y')
result=TRUE;
else if (ch=='n') result=FALSE;
+ else if (ch == EOF) {
+ printf("user closed input stream, quitting...\n");
+ exit(0);
+ }
FLUSHLINE;
if (ch=='y'|| ch=='n') break;
printf("Please answer the question.\n");
@@ -134,6 +145,10 @@ int x,y,z;
if ((ch=getchar())=='y')
result=TRUE;
else if (ch=='n') result=FALSE;
+ else if (ch == EOF) {
+ printf("user closed input stream, quitting...\n");
+ exit(0);
+ }
FLUSHLINE;
if (ch=='y'|| ch=='n') break;
printf("Please answer the question.\n");
diff --git a/games/adventure/wizard.c b/games/adventure/wizard.c
index 2ff3f5f798b..4722391ebe8 100644
--- a/games/adventure/wizard.c
+++ b/games/adventure/wizard.c
@@ -120,7 +120,7 @@ char *cmdfile;
printf("What would you like to call the saved version?\n");
for (c=fname;; c++)
- if ((*c=getchar())=='\n') break;
+ if ((*c=getchar())=='\n' || *c == EOF) break;
*c=0;
if (save(fname) != 0) return; /* Save failed */
printf("To resume, say \"adventure %s\".\n", fname);