- * My update of a classic adventure game. The C is crude because it's
- * a hack on a line-by-line translation of a BASIC `Hunt The Wumpus'.
- * This code is no relation to the elaborate dungeon game called `Hack'.
+ * My update of a classic adventure game. This code is no relation to
+ * the elaborate dungeon game called `Hack'.
static int path[5];
static int j, k, scratchloc, pies;
static char inp[BUFSIZ]; /* common input buffer */
static int path[5];
static int j, k, scratchloc, pies;
static char inp[BUFSIZ]; /* common input buffer */
PM("Welcome to `Hunt the Superhack'\n")
PM(" The superhack lives on the 9th floor of 45 Technology Square in");
PM("Welcome to `Hunt the Superhack'\n")
PM(" The superhack lives on the 9th floor of 45 Technology Square in");
PM(" If a pie hits the superhack, you win. If it hits you, you lose!\n");
(void) fputs("<Press return to continue>", stdout);
PM(" If a pie hits the superhack, you win. If it hits you, you lose!\n");
(void) fputs("<Press return to continue>", stdout);
- j9 = sscanf(inp + isalpha(inp[0]), "%d %d %d %d %d",
+ j9 = sscanf(inp + strcspn(inp, NUMBERS), "%d %d %d %d %d",
&path[0], &path[1], &path[2], &path[3], &path[4]);
&path[0], &path[1], &path[2], &path[3], &path[4]);
- if (sscanf(inp + isalpha(inp[0]), "%d", &scratchloc) < 1)
+ if (sscanf(inp + strcspn(inp, NUMBERS), "%d", &scratchloc) < 1)
- if (argc >= 2 && strcmp(argv[1], "-s") == 0)
- srand(atoi(argv[2]));
- else
- srand((int)time((long *) 0));
+ if (argc >= 2 && strcmp(argv[1], "-s") == 0) {
+ srand(atoi(argv[2]));
+ }
+ else {
+ srand((int)time((long *) 0));
+ }
- for (j = 0; j < LOCS; j++)
- for (k = 0; k < LOCS; k++)
- if (j == k)
- continue;
- else if (loc[j] == loc[k])
- goto badlocs;
+ for (j = 0; j < LOCS; j++) {
+ for (k = 0; k < LOCS; k++) {
+ if (j == k) {
+ continue;
+ }
+ else if (loc[j] == loc[k]) {
+ goto badlocs;
+ }
+ }
+ }
c = getlet("Throw, move or help [t,m,?]");
c = getlet("Throw, move or help [t,m,?]");