]> granicus.if.org Git - nethack/commitdiff
monmove.c tweaks
authorPatR <rankin@nethack.org>
Wed, 2 Mar 2016 23:01:21 +0000 (15:01 -0800)
committerPatR <rankin@nethack.org>
Wed, 2 Mar 2016 23:01:21 +0000 (15:01 -0800)
While looking at #H4265 ("Bug - Monsters opening doors" about
feedback naming the unseen monster who opened a door), I didn't
find the the problem.  But I did notice a couple of suspicious
constructs.  Fix an assignment that gave a boolean variable a
value of 16, and add parentheses around 'a & b' in (a & b && c).
The latter isn't incorrect, it just looks strange.

src/monmove.c

index d13dc3c617dc170450a66e054ad93255a6257b91..964db35eea371e5cdc5758743646768c1afd0ca4 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 monmove.c       $NHDT-Date: 1455402384 2016/02/13 22:26:24 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.84 $ */
+/* NetHack 3.6 monmove.c       $NHDT-Date: 1456959639 2016/03/02 23:00:39 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.85 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1218,12 +1218,12 @@ postmov:
             }
             ptr = mtmp->data;
 
-            /* open a door, or crash through it, if you can */
+            /* open a door, or crash through it, if 'mtmp' can */
             if (IS_DOOR(levl[mtmp->mx][mtmp->my].typ)
                 && !passes_walls(ptr) /* doesn't need to open doors */
                 && !can_tunnel) {     /* taken care of below */
                 struct rm *here = &levl[mtmp->mx][mtmp->my];
-                boolean btrapped = (here->doormask & D_TRAPPED),
+                boolean btrapped = (here->doormask & D_TRAPPED) != 0,
                         observeit = canseeit && canspotmon(mtmp);
 
                 if ((here->doormask & (D_LOCKED | D_CLOSED)) != 0
@@ -1296,7 +1296,7 @@ postmov:
                             else if (!Deaf)
                                 You_hear("a door crash open.");
                         }
-                        if (here->doormask & D_LOCKED && !rn2(2))
+                        if ((here->doormask & D_LOCKED) != 0 && !rn2(2))
                             here->doormask = D_NODOOR;
                         else
                             here->doormask = D_BROKEN;