projects
/
wumpus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
News update.
[wumpus.git]
/
wumpus.c
diff --git
a/wumpus.c
b/wumpus.c
index 191693f35ef67332716641066d899fd2d9aa889d..5aef1c3a19608601b9d2f7062b48ffee81c5979c 100644
(file)
--- a/
wumpus.c
+++ b/
wumpus.c
@@
-2,10
+2,7
@@
* wumpus.c --- a faithful translation of the classic "Hunt The Wumpus" game.
*
* Translator: Eric S. Raymond <esr@snark.thyrsus.com>
* wumpus.c --- a faithful translation of the classic "Hunt The Wumpus" game.
*
* Translator: Eric S. Raymond <esr@snark.thyrsus.com>
- * Version: $Id$
- *
- * This was the state of the art 20 years ago, in 1972. We've come a long
- * way, baby.
+ * Version: $Id: wumpus.c,v 1.4 1996/05/17 17:30:35 esr Exp esr $
*
* The BASIC source is that posted by Magnus Olsson in USENET article
* <9207071854.AA21847@thep.lu.se>: he wrote
*
* The BASIC source is that posted by Magnus Olsson in USENET article
* <9207071854.AA21847@thep.lu.se>: he wrote
@@
-31,6
+28,8
@@
*/
#include <stdio.h>
*/
#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
/* 5 REM *** HUNT THE WUMPUS *** */
/* 5 REM *** HUNT THE WUMPUS *** */
@@
-102,16
+101,24
@@
int getnum(prompt)
char *prompt;
{
(void) printf("%s\n?", prompt);
char *prompt;
{
(void) printf("%s\n?", prompt);
- (void) fgets(inp, sizeof(inp), stdin);
- return(atoi(inp));
+ if (fgets(inp, sizeof(inp), stdin))
+ return(atoi(inp));
+ else {
+ fputs("\n",stdout);
+ exit(1);
+ }
}
int getlet(prompt)
char *prompt;
{
(void) printf("%s\n?", prompt);
}
int getlet(prompt)
char *prompt;
{
(void) printf("%s\n?", prompt);
- (void) fgets(inp, sizeof(inp), stdin);
- return(inp[0]);
+ if (fgets(inp, sizeof(inp), stdin))
+ return(toupper(inp[0]));
+ else {
+ fputs("\n",stdout);
+ exit(1);
+ }
}
void print_instructions()
}
void print_instructions()
@@
-342,9
+349,7
@@
badrange:
/* this simulates logic at 895 in the BASIC code */
check_shot();
/* this simulates logic at 895 in the BASIC code */
check_shot();
- if (finished == NOT)
- goto ammo;
- else
+ if (finished != NOT)
return;
}
return;
}
@@
-511,7
+516,8
@@
goodmove:
/* 1145 RETURN */
/* 1150 END */
(void) puts("ZAP--SUPER BAT SNATCH! ELSEWHEREVILLE FOR YOU!");
/* 1145 RETURN */
/* 1150 END */
(void) puts("ZAP--SUPER BAT SNATCH! ELSEWHEREVILLE FOR YOU!");
- loc[YOU] = FNA();
+ scratchloc = loc[YOU] = FNA();
+ goto goodmove;
}
}
}
}
@@
-521,10
+527,10
@@
char *argv[];
{
int c;
{
int c;
- if (strcmp(argv[1], "-s") == 0)
- srand(ato
l
(argv[2]));
+ if (
argc >= 2 &&
strcmp(argv[1], "-s") == 0)
+ srand(ato
i
(argv[2]));
else
else
- srand(time((long *) 0));
+ srand(
(int)
time((long *) 0));
/* 15 PRINT "INSTRUCTIONS (Y-N)"; */
/* 20 INPUT I$ */
/* 15 PRINT "INSTRUCTIONS (Y-N)"; */
/* 20 INPUT I$ */