X-Git-Url: https://jxself.org/git/?p=wumpus.git;a=blobdiff_plain;f=superhack.c;h=c5461a1ff7f3fae5ff1c84a46be6073c55fc1c46;hp=f4f616e79c980464072f99942efb8e928619977b;hb=c933090a7a4c96592d6c3f0df61b7c0224187ada;hpb=94476feed2b8652d0b551f6dd6b34d57c6dd886f diff --git a/superhack.c b/superhack.c index f4f616e..c5461a1 100644 --- a/superhack.c +++ b/superhack.c @@ -13,6 +13,10 @@ #include #include #include +#include +#include +#include +#include static int path[5]; static int j, k, scratchloc, pies; @@ -34,6 +38,8 @@ static int loc[LOCS]; #define LOSE -1 static int finished; +#define IGNORE(r) do{if(r);}while(0) + static int cave[20][3] = { {1,4,7}, @@ -68,7 +74,7 @@ int getlet(prompt) char *prompt; { (void) printf("%s? ", prompt); - if(fgets(inp, sizeof(inp), stdin)) + if (fgets(inp, sizeof(inp), stdin)) return(tolower(inp[0])); else { fputs("\n",stdout); @@ -80,8 +86,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"); @@ -104,7 +108,7 @@ PM("Cambridge, Massachusetts. Your mission is to throw a pie in his face.\n"); PM(" If a pie hits the superhack, you win. If it hits you, you lose!\n"); (void) fputs("", stdout); - (void) fgets(inp, sizeof(inp), stdin); + IGNORE(fgets(inp, sizeof(inp), stdin)); (void) putchar('\n'); PM("Hazards:"); @@ -261,7 +265,6 @@ void throw() } - ammo: if (finished == NOT) { (void) puts("You missed."); @@ -350,9 +353,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 +424,7 @@ char *argv[]; break; } } + return 0; } /* superhack.c ends here */