X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=superhack.c;h=78531685b9dbdb45eae392b6a1f56ef73c34f11b;hb=0db45863847654d4022e08e55fd93a90e8f29043;hp=f9879fd8ee10b7afc6af792d4ae53a573b3a3bb1;hpb=9be728e4b06b5fd96f63f9e1a95404889bb900f9;p=wumpus.git diff --git a/superhack.c b/superhack.c index f9879fd..7853168 100644 --- a/superhack.c +++ b/superhack.c @@ -3,9 +3,8 @@ * * Author: Eric S. Raymond * - * 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'. * * Any resemblance to persons living or dead is strictly coincidental. And * if you believe *that*... @@ -13,6 +12,10 @@ #include #include +#include +#include +#include +#include static int path[5]; static int j, k, scratchloc, pies; @@ -80,8 +83,6 @@ char *prompt; void print_instructions() { - char ebuf[BUFSIZ]; - PM("Welcome to `Hunt the Superhack'\n") PM(" The superhack lives on the 9th floor of 45 Technology Square in"); @@ -231,7 +232,7 @@ void throw() } for (k = 0; k < j9; k++) - if (path[k] == path[k - 2]) + if (k >= 2 && path[k] == path[k - 2]) { (void) puts("Pies can't fly that crookedly --- try again."); return; @@ -261,7 +262,6 @@ void throw() } - ammo: if (finished == NOT) { (void) puts("You missed."); @@ -332,7 +332,7 @@ goodmove: PM("Yow! You interrupted the superhack."); move_superhack(); } - else if (scratchloc == loc[STARLET1] || scratchloc == loc[STARLET1]) + else if (scratchloc == loc[STARLET1] || scratchloc == loc[STARLET2]) { PM("You begin to babble at an unimpressed starlet. You lose!"); finished = LOSE; @@ -350,9 +350,7 @@ goodmove: } } -main(argc, argv) -int argc; -char *argv[]; +int main(int argc, char *argv[]) { if (argc >= 2 && strcmp(argv[1], "-s") == 0) srand(atoi(argv[2])); @@ -423,6 +421,7 @@ char *argv[]; break; } } + return 0; } /* superhack.c ends here */