Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/wump Apply patch from PR bin/26501 to fix hang in wump...



details:   https://anonhg.NetBSD.org/src/rev/900fd9189f76
branches:  trunk
changeset: 587301:900fd9189f76
user:      garbled <garbled%NetBSD.org@localhost>
date:      Thu Jan 19 20:15:31 2006 +0000

description:
Apply patch from PR bin/26501 to fix hang in wump if you play too many
games in a row.  Also modify change made in rev 1.18 to work correctly.
take_action() returns 1 if the player dies, causing the game to allways
exit after any death, now the game correctly asks if the player would
like to play again.

diffstat:

 games/wump/wump.c |  15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diffs (55 lines):

diff -r 05628be46724 -r 900fd9189f76 games/wump/wump.c
--- a/games/wump/wump.c Thu Jan 19 19:17:59 2006 +0000
+++ b/games/wump/wump.c Thu Jan 19 20:15:31 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wump.c,v 1.18 2005/03/21 18:45:18 jwise Exp $  */
+/*     $NetBSD: wump.c,v 1.19 2006/01/19 20:15:31 garbled Exp $        */
 
 /*
  * Copyright (c) 1989, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)wump.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: wump.c,v 1.18 2005/03/21 18:45:18 jwise Exp $");
+__RCSID("$NetBSD: wump.c,v 1.19 2006/01/19 20:15:31 garbled Exp $");
 #endif
 #endif /* not lint */
 
@@ -232,6 +232,7 @@
            plural(pit_num), arrow_num);
 
        for (;;) {
+               clear_things_in_cave();
                initialize_things_in_cave();
                arrows_left = arrow_num;
                do {
@@ -239,16 +240,14 @@
                        (void)printf("Move or shoot? (m-s) ");
                        (void)fflush(stdout);
                        if (!fgets(answer, sizeof(answer), stdin)) {
-                               e=1;
+                               e=2;
                                break;
                        }
                } while (!(e = take_action()));
 
-               if (e || !getans("\nCare to play another game? (y-n) "))
+               if (e == 2 || !getans("\nCare to play another game? (y-n) "))
                        exit(0);
-               if (getans("In the same cave? (y-n) "))
-                       clear_things_in_cave();
-               else
+               if (getans("In the same cave? (y-n) ") == 0)
                        cave_init();
        }
        /* NOTREACHED */
@@ -508,7 +507,7 @@
                /* each time you shoot, it's more likely the wumpus moves */
                static int lastchance = 2;
 
-               if (random() % level == EASY ? 12 : 9 < (lastchance += 2)) {
+               if (random() % (level == EASY ? 12 : 9) < (lastchance += 2)) {
                        move_wump();
                        if (wumpus_loc == player_loc)
                                wump_kill();



Home | Main Index | Thread Index | Old Index